Operations 35 min read
The Most Complete Linux Command Cheat Sheet
This article compiles an extensive list of essential Linux commands covering system information, file and directory management, process control, networking, package handling, compression, backup, user and group administration, and more, providing a handy reference for everyday command‑line tasks.
Linux Tech Enthusiast
Linux Tech Enthusiast
1. Basic System Commands
uname -m # display machine architecture
uname -r # display kernel version
dmidecode -q # display hardware components
hdparm -i /dev/hda # list disk characteristics
hdparm -tT /dev/sda # perform read test on disk
cat /proc/cpuinfo # show CPU information
cat /proc/interrupts # show interrupts
cat /proc/meminfo # show memory usage
cat /proc/swaps # show swap usage
cat /proc/version # show kernel version
cat /proc/net/dev # show network interfaces and statistics
cat /proc/mounts # show mounted filesystems
lspci -tv # list PCI devices
lsusb -tv # list USB devices
date # display system date
cal 2007 # display calendar for year 2007
clock -w # write system time to BIOS2. Shutdown and Reboot
shutdown -h now # immediate shutdown
shutdown -r now # immediate reboot
shutdown -h +10 # shutdown after 10 minutes
shutdown -h 23:30 # shutdown at 23:30
init 0 # alternative shutdown command
telinit 0 # alternative shutdown command
shutdown -c # cancel scheduled shutdown3. File and Directory Operations
cd /home # change to /home directory
cd .. # go up one level
cd ../.. # go up two levels
cd ~user1 # change to user1's home directory
cd - # return to previous directory
pwd # print working directory
ls # list files
ls -F # list files with type indicators
ls -l # detailed list
ls -a # include hidden files
ls *[0-9]* # list files containing numbers
tree # display directory tree
mkdir dir1 # create directory dir1
mkdir -p /tmp/dir1/dir2 # create nested directories
rm -f file1 # force delete file1
rm -r dir1 # recursively delete directory dir1
mv dir1 new_dir # rename or move directory
cp file1 file2 # copy file1 to file2
cp -a /tmp/dir1 . # copy directory preserving attributes
ln -s file1 link1 # create symbolic link
ln file1 hardlink1 # create hard link
chmod ugo+rwx directory1 # set read/write/execute for all
chmod go-rwx directory1 # remove group and others permissions
chown user1 file1 # change file owner
chgrp group1 file1 # change file group
chmod +t file1 # set sticky bit4. File Search
find / -name file1 # search for file1 from root
find /home/user1 -name "*.bin" # search for .bin files in a directory
find /usr/bin -type f -atime +100 # files not accessed in last 100 days
find /usr/bin -type f -mtime -10 # files modified in last 10 days
locate *.ps # quickly locate files ending with .ps (requires updatedb)
whereis halt # locate binary, source, and man page for halt
which halt # show full path of executable5. Mounting Filesystems
mount /dev/hda2 /mnt/hda2 # mount partition
umount /dev/hda2 # unmount partition
fuser -km /mnt/hda2 # force unmount if busy
mount -o loop file.iso /mnt/iso # mount ISO image
mount -t vfat /dev/hda5 /mnt/hda5 # mount FAT32 filesystem
mount -t cifs -o username=user,password=pass //WinClient/share /mnt/share # mount Windows share6. Disk Space and Filesystem Checks
df -h # show mounted partitions with sizes
du -sh dir1 # estimate disk usage of dir1
badblocks -v /dev/hda1 # check for bad blocks
fsck /dev/hda1 # check and repair filesystem
e2fsck -j /dev/hda1 # check ext3 filesystem
fsck.vfat /dev/hda1 # check FAT filesystem7. User and Group Management
groupadd group_name # create a new group
groupdel group_name # delete a group
groupmod -n new_name old_name # rename a group
useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1 # create user with details
userdel -r user1 # delete user and home directory
usermod -c "User FTP" -g system -d /ftp/user1 -s /sbin/nologin user1 # modify user
passwd user1 # change user password
chage -E 2005-12-31 user1 # set password expiration date8. File Permissions
chmod ugo+rwx file1 # give read/write/execute to everyone
chmod go-rwx file1 # remove group and others permissions
chmod u+s file1 # set SUID bit
chmod g+s directory1 # set SGID bit on directory
chmod o+t file1 # set sticky bit9. Special File Attributes (chattr)
chattr +a file1 # allow only append writes
chattr +i file1 # make immutable (cannot delete or modify)
chattr +c file1 # enable automatic compression
chattr -i file1 # remove immutable flag10. Archiving and Compression
tar -cvf archive.tar file1 # create tar archive
tar -xvf archive.tar # extract tar archive
tar -cvzf backup.tar.gz /etc # create gzip‑compressed archive
gzip file1 # compress file
gunzip file1.gz # decompress file
bzip2 file1 # compress with bzip2
bunzip2 file1.bz2 # decompress bzip2 file
zip file1.zip file1 # create zip archive
unzip file1.zip # extract zip archive11. Package Management (RPM)
rpm -ivh package.rpm # install package
rpm -Uvh package.rpm # upgrade package
rpm -e package_name # remove package
rpm -qa # list all installed RPMs
rpm -q package_name # query package information
rpm -ql package_name # list files provided by package12. Package Management (YUM)
yum install package_name # install package and resolve dependencies
yum update package_name # update specific package
yum remove package_name # remove package
yum list all # list all packages
yum search keyword # search for packages
yum clean all # clean all cached data13. Debian/Ubuntu Package Management (APT)
apt-get install package_name # install package
apt-get update # update package list
apt-get upgrade # upgrade all packages
apt-get remove package_name # remove package
apt-cache search keyword # search package cache14. Network Commands
ifconfig eth0 # show Ethernet configuration
ifup eth0 # enable interface
ifdown eth0 # disable interface
dhclient eth0 # obtain IP via DHCP
route -n # display routing table
netstat -tup # list active connections with PIDs
tcpdump -i eth0 port 80 # capture HTTP traffic
hostname # show system hostname
host www.example.com # DNS lookup
nslookup www.example.com # DNS lookup with details15. System Monitoring
top # interactive process viewer
ps aux # snapshot of current processes
free -h # display memory usage
uptime # show system uptime
dmesg # kernel ring buffer messages16. Text Processing
grep "pattern" file.txt # search for pattern
sed 's/old/new/g' file.txt # replace text
awk '{print $1}' file.txt # process columns
sort file.txt # sort lines
uniq file.txt # filter duplicate lines
head -n 10 file.txt # first 10 lines
tail -f /var/log/messages # follow log file17. Miscellaneous Utilities
who # show logged‑in users
w # detailed user activity
chmod +x script.sh # make script executable
chmod -x script.sh # remove execute permission
file file1 # determine file type
tar -cf - . | ssh user@host 'tar -xf - -C /dest' # copy directory over SSHWritten by
Linux Tech Enthusiast
Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.
0 followers
Reader feedback
How this landed with the community
Rate this article
Was this worth your time?
Discussion
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
