Essential Linux Command Cheat Sheet: 100+ Commands Every Sysadmin Needs
This comprehensive guide compiles over a hundred essential Linux commands covering system information, shutdown/reboot, file and directory management, searching, mounting, disk usage, user and group handling, permissions, special attributes, compression, backup, networking, package management, and more, providing a handy reference for system administrators and developers alike.
1. Basic Commands
uname -m # display processor architecture
uname -r # display kernel version
dmidecode -q # display hardware components (SMBIOS/DMI)
hdparm -i /dev/hda # list disk architecture features
hdparm -tT /dev/sda # perform test read operations on a disk
arch # display processor architecture
cat /proc/cpuinfo # show CPU information
cat /proc/interrupts # show interrupts
cat /proc/meminfo # check memory usage
cat /proc/swaps # show used swap devices
cat /proc/version # display kernel version
cat /proc/net/dev # show network adapters and statistics
cat /proc/mounts # list mounted filesystems
lspci -tv # list PCI devices
lsusb -tv # display USB devices
date # show system date
cal 2007 # display calendar for year 2007
date 041217002007.00 # set date and time (MMDDhhmmYY.ss)
clock -w # save time to BIOS2. Shutdown and Reboot
shutdown -h now # immediate shutdown
init 0 # shutdown (method 2)
shutdown -h 23:30 # schedule shutdown at 23:30
shutdown -c # cancel scheduled shutdown
shutdown -r now # immediate reboot
reboot # reboot the system
logout # log out3. File and Directory Operations
cd /home # change to /home directory
cd .. # go up one level
cd ../.. # go up two levels
cd ~user1 # go to user1's home directory
cd - # return to previous directory
pwd # show current working directory
ls # list files in current directory
ls -F # list files with type indicators
ls -l # detailed file list
ls -a # show hidden files
ls *[0-9]* # list files/directories containing numbers
tree # display directory tree
lstree # alternative tree view
mkdir dir1 # create directory dir1
mkdir dir1 dir2 # create two directories simultaneously
mkdir -p /tmp/dir1/dir2 # create nested directory tree
rm -f file1 # force delete file1
rmdir dir1 # remove empty directory dir1
rm -rf dir1 # delete directory dir1 and its contents recursively
mv dir1 new_dir # rename/move directory
cp file1 file2 # copy file1 to file2
cp dir/* . # copy all files from dir to current directory
cp -a /tmp/dir1 . # copy directory preserving attributes
ln -s file1 lnk1 # create symbolic link to file1
ln file1 lnk1 # create hard link to file1
touch -t 0712250000 file1 # set file timestamp (YYMMDDhhmm)
file file1 # display MIME type of file14. File Search
find / -name file1 # search from root for file1
find / -user user1 # find files owned by user1
find /home/user1 -name \*.bin # find .bin files in /home/user1
find /usr/bin -type f -atime +100 # find executable files not accessed in 100 days
find /usr/bin -type f -mtime -10 # find files modified within last 10 days
find / -name \*.rpm -exec chmod 755 {} \; # change permissions of .rpm files
find / -xdev -name \*.rpm # find .rpm files ignoring removable devices
locate \*.ps # locate .ps files (run updatedb first)
whereis halt # locate binary, source, or man page for halt
which halt # show full path of halt executable5. Mounting Filesystems
mount /dev/hda2 /mnt/hda2 # mount partition hda2
umount /dev/hda2 # unmount partition
fuser -km /mnt/hda2 # force unmount if busy
umount -n /mnt/hda2 # unmount without writing /etc/mtab
mount /dev/fd0 /mnt/floppy # mount floppy disk
mount /dev/cdrom /mnt/cdrom # mount CD/DVD
mount /dev/hdc /mnt/cdrecorder # mount CD-RW or DVD-RW
mount -o loop file.iso /mnt/cdrom # mount ISO image
mount -t vfat /dev/hda5 /mnt/hda5 # mount FAT32 filesystem
mount /dev/sda1 /mnt/usbdisk # mount USB flash drive
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share # mount Windows share6. Disk Space
df -h # display mounted partitions and usage
ls -lSr | more # list files sorted by size
du -sh dir1 # estimate disk usage of dir1
du -sk * | sort -rn # sort directories/files by size
rpm -q -a --qf '%10{SIZE}t%{NAME}
' | sort -k1,1n # list installed RPM packages by size
dpkg-query -W -f='${Installed-Size}\t${Package}
' | sort -k1,1n # list installed DEB packages by size7. Users and Groups
groupadd group_name # create new group
groupdel group_name # delete group
groupmod -n new_name old_name # rename group
useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1 # add user to admin group
useradd user1 # add new user
userdel -r user1 # delete user and home directory
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 # modify user attributes
passwd # change password
passwd user1 # change password for user1
chage -E 2005-12-31 user1 # set password expiration date
pwck # verify /etc/passwd format
grpck # verify /etc/group format
newgrp group_name # switch to new group8. File Permissions
ls -lh # show permissions
chmod ugo+rwx directory1 # give read/write/execute to user, group, others
chmod go-rwx directory1 # remove read/write/execute from group and others
chown user1 file1 # change file owner
chown -R user1 directory1 # change owner recursively
chgrp group1 file1 # change group ownership
chown user1:group1 file1 # change owner and group
find / -perm -u+s # list files with SUID bit set
chmod u+s /bin/file1 # set SUID on a binary
chmod u-s /bin/file1 # remove SUID
chmod g+s /home/public # set SGID on a directory
chmod g-s /home/public # remove SGID
chmod o+t /home/public # set sticky bit on a directory
chmod o-t /home/public # remove sticky bit
chmod +x file_path # add execute permission
chmod -x file_path # remove execute permission9. Special File Attributes
chattr +a file1 # allow only append writes
chattr +c file1 # enable automatic compression
chattr +d file1 # exclude from dump backups
chattr +i file1 # make immutable (cannot delete/modify)
chattr +s file1 # enable secure deletion
chattr +S file1 # write changes immediately to disk
chattr +u file1 # allow recovery after deletion
lsattr # list special attributes10. Compression and Archiving
bunzip2 file1.bz2 # decompress bzip2 file
bzip2 file1 # compress file with bzip2
gunzip file1.gz # decompress gzip file
gzip file1 # compress file with gzip
gzip -9 file1 # maximum compression
rar a file1.rar test_file # create RAR archive
rar a file1.rar file1 file2 dir1 # add multiple files/directories to RAR
rar x file1.rar # extract RAR archive
unrar x file1.rar # extract RAR archive
tar -cvf archive.tar file1 # create uncompressed tarball
tar -cvf archive.tar file1 file2 dir1 # create tarball with multiple items
tar -tf archive.tar # list contents of tarball
tar -xvf archive.tar # extract tarball
tar -xvf archive.tar -C /tmp # extract to specific directory
tar -cvfj archive.tar.bz2 dir1 # create bzip2-compressed tarball
tar -xvfj archive.tar.bz2 # extract bzip2-compressed tarball
tar -cvfz archive.tar.gz dir1 # create gzip-compressed tarball
tar -xvfz archive.tar.gz # extract gzip-compressed tarball
zip file1.zip file1 # create zip archive
zip -r file1.zip file1 file2 dir1 # recursively zip multiple items
unzip file1.zip # extract zip archive11. RPM Package Management
rpm -ivh package.rpm # install RPM package
rpm -ivh --nodeps package.rpm # install ignoring dependencies
rpm -U package.rpm # upgrade package without changing config files
rpm -F package.rpm # upgrade already installed package
rpm -e package_name.rpm # erase package
rpm -qa # list all installed RPMs
rpm -qa | grep httpd # filter installed RPMs containing "httpd"
rpm -qi package_name # show detailed info about installed package
rpm -qg "System Environment/Daemons" # list RPMs in a group
rpm -ql package_name # list files provided by installed package
rpm -qc package_name # list config files of installed package
rpm -q package_name --whatrequires # show packages that depend on this one
rpm -q package_name --whatprovides # show what this package provides
rpm -q package_name --scripts # show install/remove scripts
rpm -q package_name --changelog # show changelog
rpm -qf /etc/httpd/conf/httpd.conf # find which RPM provides a file
rpm -qp package.rpm -l # list files in an uninstalled RPM
rpm --import /media/cdrom/RPM-GPG-KEY # import GPG key
rpm --checksig package.rpm # verify package signature
rpm -V package_name # verify package files
rpm -Va # verify all installed packages (use with care)
rpm -Vp package.rpm # verify an uninstalled RPM
rpm2cpio package.rpm | cpio --extract --make-directories *bin* # extract executable from RPM
rpm -ivh /usr/src/redhat/RPMS/$(arch)/package.rpm # install built RPM from source
rpmbuild --rebuild package_name.src.rpm # rebuild source RPM12. YUM Package Management
yum install package_name # download and install RPM package
yum localinstall package_name.rpm # install local RPM with dependency resolution
yum update package_name.rpm # update all installed RPMs
yum update package_name # update specific package
yum remove package_name # remove RPM package
yum list # list all installed packages
yum search package_name # search repository for package
yum clean packages # clean package cache
yum clean headers # clean header files
yum clean all # clean all cached data13. DEB Package Management
dpkg -i package.deb # install or upgrade DEB package
dpkg -r package_name # remove DEB package
dpkg -l # list installed DEB packages
dpkg -l | grep httpd # filter installed DEBs containing "httpd"
dpkg -s package_name # show information about installed package
dpkg -L package_name # list files provided by installed DEB
dpkg --contents package.deb # list files in an uninstalled DEB
dpkg -S /bin/ping # find which DEB provides a file
apt-get install package_name # install or upgrade DEB package
apt-cdrom install package_name # install from CD-ROM
apt-get update # refresh package list
apt-get upgrade # upgrade all installed packages
apt-get remove package_name # remove DEB package
apt-get check # verify repository integrity
apt-get clean # clean downloaded package cache
apt-cache search searched-package # search package names14. Network Commands (Ethernet and Wi‑Fi)
ifconfig eth0 # show Ethernet configuration
ifup eth0 # enable network interface
ifdown eth0 # disable network interface
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 # set static IP
ifconfig eth0 promisc # enable promiscuous mode
dhclient eth0 # obtain IP via DHCP
route -n # display routing table
route add -net 0.0.0.0/0 gw IP_Gateway # set default gateway
route del 0.0.0.0/0 gw IP_Gateway # delete static route
echo "1" > /proc/sys/net/ipv4/ip_forward # enable IP forwarding
hostname show # display system hostname
host www.example.com # resolve hostname to IP
nslookup www.example.com # DNS lookup
ip link show # show link status of all interfaces
mii-tool eth0 # show link status of eth0
ethtool eth0 # show statistics of eth0
netstat -tup # list active network connections with PID
netstat -tupl # list listening services with PID
tcpdump tcp port 80 # capture HTTP traffic
iwlist scan # scan for wireless networks
iwconfig eth1 # show wireless interface configuration
whois www.example.com # query WHOIS database15. System Information and Monitoring
date # show or set system date/time
hwclock # show hardware clock (requires root)
cal # display calendar
uptime # show system uptime
echo "text" # display text
cat file1 # display file contents
head -n 10 file1 # show first 10 lines
tail -n 10 file1 # show last 10 lines
more file1 # paginate output (forward only)
less file1 # paginate output (forward/backward)
ls -al | more # long format list with pagination
ls -al | less # long format list with scrollable view
dmesg # kernel ring buffer messages
df -h # filesystem disk space usage
du -sh dir1 # estimate disk usage of dir1
free -m # show memory usage
ps aux # list running processes
top # interactive process viewer16. File System Utilities
file file1 # determine file type
mount -o loop file.iso /mnt/iso # mount ISO image
umount /mnt/iso # unmount ISO
mkfs /dev/hda1 # create filesystem on partition
mke2fs /dev/hda1 # create ext2 filesystem
mke2fs -j /dev/hda1 # create ext3 filesystem with journaling
mkfs -t vfat -F 32 /dev/hda1 # create FAT32 filesystem
fdformat -n /dev/fd0 # format floppy disk
mkswap /dev/hda3 # create swap partition
swapon /dev/hda3 # enable swap
swapon /dev/hda2 /dev/hdb3 # enable multiple swap partitions17. Backup and Restore
dump -0aj -f /tmp/home0.bak /home # full backup of /home
dump -1aj -f /tmp/home0.bak /home # interactive backup of /home
restore -if /tmp/home0.bak # interactive restore
rsync -rogpav --delete /home /tmp # sync directories
rsync -az -e ssh --delete /home user@host:/tmp # rsync over SSH with compression
dd if=/dev/hda | gzip | ssh user@host "dd of=hda.gz" # remote backup via SSH
dd if=/dev/sda of=/tmp/file1 # copy disk to file
tar -Puf backup.tar /home/user # incremental backup
(cd /tmp/local && tar c .) | ssh user@host "cd /home/share && tar x -p" # copy directory via SSH
find /home/user1 -name "*.txt" | xargs cp -av --target-directory=/home/backup/ --parents # copy matching files preserving hierarchy
find /var/log -name "*.log" | tar cv --files-from=- | bzip2 > log.tar.bz2 # archive log files
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 # copy MBR to floppy
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 # restore MBR from floppy18. Miscellaneous Commands
who # list logged‑in users
w # detailed user activity
dmesg # kernel messages
lsblk # list block devices
blkid # display block device attributes
chmod 644 file # set standard permissions
chown user:group file # change owner and group
ln -s target link # create symbolic link
ln target link # create hard link
tar cf - . | (cd /tmp/backup && tar xf -) # copy directory preserving permissions19. VIM Editor Basics
vim filename # open file in VIM
:i # insert mode before cursor
:o # insert mode on new line below
:dd # delete current line
:yy # yank (copy) current line
:n yy # yank n lines
:p # paste after cursor
:u # undo last change
:r # replace character under cursor
:/pattern # search for pattern
:!command # execute external command
:sh # drop to shell
:set number # show line numbers
:w # write (save) file
:q # quit VIM
:q! # quit without saving
:x # write and quit (same as :wq)20. Software Package Management (RPM)
rpm -ivh package.rpm # install
rpm -e package_name # erase
rpm -Uvh package.rpm # upgrade
rpm -Fvh package.rpm # freshen (upgrade if installed)
rpm -qa # query all installed packages
rpm -q package_name # query specific package
rpm -ql package_name # list files of installed package
rpm -qi package_name # detailed info
rpm -qc package_name # list config files
rpm -qf /path/to/file # find which package provides a file21. Software Package Management (DEB)
dpkg -i package.deb # install
dpkg -r package_name # remove
dpkg -l # list installed packages
apt-get install package_name # install/upgrade via APT
apt-get remove package_name # remove package
apt-get update # update package lists
apt-get upgrade # upgrade all packages
apt-cache search keyword # search packages22. Additional Tools
grep pattern file # search for pattern in file
awk '{print $1}' file # process text columns
sed 's/old/new/g' file # stream editor substitution
cut -d':' -f1 /etc/passwd # extract fields
sort file | uniq # unique sorted lines
tr '[:lower:]' '[:upper:]' < file # translate case
wc -l file # count lines
chmod 755 script.sh # make script executableSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
