Essential Linux Command Cheat Sheet for System Administrators
A comprehensive, categorized list of essential Linux commands covering system information, file management, process control, networking, package handling, disk operations, backups, and text editing, providing quick reference examples and usage syntax for everyday system administration tasks.
Basic Commands
uname -m # Show processor architecture
uname -r # Show kernel version
uname -a # Show all system information
arch # Show processor architecture
cat /proc/cpuinfo # Display CPU details
cat /proc/interrupts
cat /proc/meminfo # Show memory usage
cat /proc/swaps # List active swap spaces
cat /proc/version # Show kernel version
cat /proc/net/dev # Show network interfaces
cat /proc/mounts # List mounted filesystems
lspci -tv # List PCI devices
lsusb -tv # List USB devices
date # Show system date and time
cal 2007 # Show calendar for year 2007
clock -w # Save hardware clockShutdown and Reboot
shutdown -h now # Immediate shutdown
init 0 # Shutdown (alternative)
telinit 0 # Shutdown (alternative)
shutdown -h hh:mm # Schedule shutdown
shutdown -c # Cancel scheduled shutdown
shutdown -r now # Reboot now
reboot # Reboot
logout # Log out of sessionFile 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
cd - # Return to previous directory
pwd # Show current working directory
ls # List files
ls -F # List files with type indicators
ls -l # Detailed list
ls -a # Show hidden files
ls *[0-9]* # List files containing numbers
tree # Tree view of directories
mkdir dir1 # Create directory dir1
mkdir dir1 dir2 # Create multiple directories
mkdir -p /tmp/dir1/dir2 # Create nested directories
rm -f file1 # Force delete file1
rmdir dir1 # Remove empty directory
rm -rf dir1 # Remove directory and contents recursively
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 link1 # Create hard link
touch -t 0712250000 file1 # Set file timestamp (YYMMDDhhmm)
file file1 # Show MIME type of file
iconv -l # List known encodings
iconv -f from -t to inputFile > outputFile # Convert file encoding
find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; # Batch resize imagesFile 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 specific directory
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 in last 10 days
find / -name \*.rpm -exec chmod 755 {} \; # Change permissions of .rpm files
locate \*.ps # Find .ps files (run updatedb first)
whereis halt # Locate binary, source, and man page
which halt # Show full path of executableMounting 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
mount /dev/cdrom /mnt/cdrom # Mount CD/DVD
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 drive
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share # Mount Windows shareDisk Space
df -h # Show mounted partitions with human‑readable sizes
ls -lSr | more # List files sorted by size
du -sh dir1 # Summarize disk usage of dir1
du -sk * | sort -rn # Sort directories/files by size
rpm -qa | grep httpd # List installed RPM packages containing "httpd"
dpkg-query -W -f='${Installed-Size}\t${Package}
' | sort -k1,1n # List installed DEB packages by sizeUser and Group Management
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 with details
useradd user1 # Simple user creation
userdel -r user1 # Delete user and home directory
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 # Modify user
passwd # Change own password
passwd user1 # Change password for user1 (root only)
chage -E 2005-12-31 user1 # Set password expiration date
pwck # Verify /etc/passwd format
grpck # Verify /etc/group format
newgrp group_name # Switch primary groupFile Permissions
ls -lh # Show permissions in long format
chmod ugo+rwx directory1 # Grant rwx to user, group, others
chmod go-rwx directory1 # Remove rwx 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 both owner and group
find / -perm -u+s # List files with SUID bit
chmod u+s /bin/file1 # Set SUID on binary
chmod u-s /bin/file1 # Remove SUID
chmod g+s /home/public # Set SGID on directory
chmod o+t /home/public # Set sticky bit on directory
chmod +x /path/to/file # Add execute permission
chmod -x /path/to/file # Remove execute permission
chmod ug+wx file # Grant write and execute to user and group
chmod =wx file # Set only write and execute, remove readSpecial File Attributes
chattr +a file1 # Append‑only attribute
chattr +c file1 # Enable automatic compression
chattr +d file1 # Exclude from dump backups
chattr +i file1 # Make immutable (cannot delete/modify)
chattr +s file1 # Secure deletion
chattr +S file1 # Sync changes immediately after write
chattr +u file1 # Allow undeletion
lsattr # List special attributesArchiving and Compression
bunzip2 file1.bz2 # Decompress bzip2 file
bzip2 file1 # Compress with bzip2
gunzip file1.gz # Decompress gzip file
gzip file1 # Compress 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 items 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 -tf archive.tar # List contents of tarball
tar -xvf archive.tar # Extract tarball
tar -cvfj archive.tar.bz2 dir1 # Create bzip2‑compressed tarball
tar -xvfj archive.tar.bz2 # Extract bzip2 tarball
tar -cvfz archive.tar.gz dir1 # Create gzip‑compressed tarball
tar -xvfz archive.tar.gz # Extract gzip tarball
zip file1.zip file1 # Create zip archive
zip -r file1.zip file1 file2 dir1 # Recursively zip multiple items
unzip file1.zip # Extract zip archiveRPM Package Management (Fedora/RedHat)
rpm -ivh package.rpm # Install package
rpm -U package.rpm # Upgrade package without changing config
rpm -F package.rpm # Update already installed package
rpm -e package_name # Remove package
rpm -qa # List all installed RPMs
rpm -qi package_name # Show detailed info of a package
rpm -ql package_name # List files provided by package
rpm -qf /etc/httpd/conf/httpd.conf # Find which package owns a file
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 -Vp package.rpm # Verify an uninstalled package
rpm2cpio package.rpm | cpio --extract --make-directories *bin* # Extract executable from RPM
rpmbuild --rebuild package.src.rpm # Rebuild package from sourceYUM Package Manager (Fedora/RedHat)
yum install package_name # Install package
yum localinstall package.rpm # Install local RPM with dependency resolution
yum update package_name # Update specific package
yum remove package_name # Remove package
yum list # List all installed packages
yum search keyword # Search repository for package
yum clean packages # Remove downloaded packages
yum clean all # Clean all cached dataDEB Package Management (Debian/Ubuntu)
dpkg -i package.deb # Install/upgrade DEB package
dpkg -r package_name # Remove DEB package
dpkg -l # List installed DEB packages
dpkg -s package_name # Show status of a package
dpkg -L package_name # List files installed by package
dpkg -S /bin/ping # Find which package provides a file
apt-get install package_name # Install package via APT
apt-get update # Refresh package lists
apt-get upgrade # Upgrade all installed packages
apt-get remove package_name # Remove package
apt-cache search keyword # Search package cacheViewing File Contents
cat file1 # Show file from start
tac file1 # Show file in reverse order
more file1 # Page through long file
less file1 # Page with forward/backward navigation
head -2 file1 # Show first two lines
tail -2 file1 # Show last two lines
tail -f /var/log/messages # Follow file growth in real timeText Processing
cat file1 file2 | command > output.txt # Pipe files into command
grep pattern file # Search for pattern
sed 's/old/new/g' file # Replace text globally
awk '{print $1}' file # Print first column
sort file | uniq -c # Count unique lines
comm -1 file1 file2 # Show lines unique to file1
paste file1 file2 # Merge files column‑wiseCharacter Set Conversion
dos2unix filedos.txt fileunix.txt # Convert DOS to UNIX line endings
unix2dos fileunix.txt filedos.txt # Convert UNIX to DOS line endings
recode ..HTML < page.txt > page.html # Convert text to HTML
recode -l | more # List supported conversionsFilesystem Checks and Creation
badblocks -v /dev/hda1 # Scan for bad blocks
fsck /dev/hda1 # Check and repair filesystem
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
mkswap /dev/hda3 # Create swap partitionBackup and Restore
dump -0aj -f /tmp/home0.bak /home # Full backup of /home
dump -1aj -f /tmp/home0.bak /home # Interactive backup
restore -if /tmp/home0.bak # Restore interactive backup
rsync -rogpav --delete /home /tmp # Sync directories
rsync -az -e ssh user@host:/dev/hda | gzip > hda.gz # Remote backup via SSH
dd if=/dev/sda of=/tmp/file1 # Disk image copy
tar -Puf backup.tar /home/user # Incremental tar backupOptical Media
cdrecord -v dev=/dev/cdrom -eject blank=fast # Erase rewritable CD
mkisofs /dev/cdrom > cd.iso # Create ISO image
mount -o loop cd.iso /mnt/iso # Mount ISO image
cd-paranoia -B # Extract audio tracks to WAV
dd if=/dev/hdc | md5sum # Verify CD image checksumNetworking
ifconfig eth0 # Show Ethernet config
ifup eth0 # Bring interface up
ifdown eth0 # Bring interface down
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 # Set static IP
dhclient eth0 # Obtain IP via DHCP
route -n show # Show routing table
route add -net 0.0.0.0 gw 192.168.1.1 # Set default gateway
netstat -tup # List active connections with PIDs
tcpdump tcp port 80 # Capture HTTP traffic
iwlist scan # Scan wireless networks
hostname # Show system hostname
host www.example.com # DNS lookup
nslookup www.example.com # DNS lookup
whois www.example.com # Query WHOIS databaseDirectory Listing
ls -a # List all files, including hidden
ls -l # Detailed list
ls -R # Recursive listing
ls -ld # List directory info
pwd # Show current directoryFile Type Identification
file filename # Display file typeCopying Files and Directories
cp source dest # Copy file
cp -r src_dir dest_dir # Recursive copy of directory
mv old_name new_name # Rename or move file/directory
rm file1 # Delete file
rm -r dir1 # Delete directory recursively
rmdir dir1 # Remove empty directorySystem Commands Overview
date # Show or set system date/time
cal # Show calendar
uptime # Show system uptime
echo "text" >> file # Append text to file
cat file # Display file content
head -n 10 file # Show first 10 lines
tail -n 10 file # Show last 10 lines
more file # Page forward
less file # Page forward/backward
ls -al | less # Long list with paging
lspci -v # Show PCI devices verbosely
lsusb -v # Show USB devices verbosely
lsmod # List loaded kernel modules
shutdown -h now # Immediate shutdown
reboot # Immediate rebootVIM Editor Basics
vim file # Open file in VIM
:i # Enter insert mode
:Esc # Return to command mode
dd # Delete current line
yy # Yank (copy) current line
p # Paste after cursor
u # Undo last change
/keyword # Search for keyword
:w # Write (save) file
:q # Quit VIM
:wq or :x # Save and quit
:set number # Show line numbers
:! command # Execute shell command from VIMRPM Package Management Commands
rpm -ivh package.rpm # Install package
rpm -e package # Remove package
rpm -Uvh package.rpm # Upgrade package
rpm -Fvh package.rpm # Update package
rpm -qa | grep httpd # List installed packages matching httpd
rpm -qi package # Query detailed info
rpm -ql package # List files in package
rpm -qf /etc/httpd/conf/httpd.conf # Find owning package of a fileFeel free to bookmark this cheat sheet for quick reference during daily Linux system administration tasks.
Signed-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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
