Essential Linux Command Cheat Sheet for System Administrators
This comprehensive guide lists essential Linux commands covering system information, shutdown, file and directory management, searching, mounting, disk usage, user and group handling, permissions, special attributes, packaging, backup, networking, and more, providing a quick reference for administrators and power users.
1. Basic Commands
uname -m # Show machine architecture</code>
<code>uname -r # Show kernel version</code>
<code>dmidecode -q # Show hardware components</code>
<code>hdparm -i /dev/hda # List disk features</code>
<code>hdparm -tT /dev/sda # Perform read test on disk</code>
<code>arch # Show architecture</code>
<code>cat /proc/cpuinfo # Show CPU info</code>
<code>cat /proc/interrupts # Show interrupts</code>
<code>cat /proc/meminfo # Check memory usage</code>
<code>cat /proc/swaps # Show active swap devices</code>
<code>cat /proc/version # Show kernel version</code>
<code>cat /proc/net/dev # Show network adapters and stats</code>
<code>cat /proc/mounts # Show mounted filesystems</code>
<code>lspci -tv # List PCI devices</code>
<code>lsusb -tv # List USB devices</code>
<code>date # Show system date</code>
<code>cal 2007 # Show calendar for 2007</code>
<code>date 041217002007.00 # Set date and time (MMDDhhmmYY.ss)</code>
<code>clock -w # Save time to BIOS2. Shutdown and Reboot
shutdown -h now # Power off now</code>
<code>init 0 # Power off (alternative)</code>
<code>telinit 0 # Power off (alternative)</code>
<code>shutdown -h HH:MM # Schedule shutdown</code>
<code>shutdown -c # Cancel scheduled shutdown</code>
<code>shutdown -r now # Reboot now</code>
<code>reboot # Reboot</code>
<code>logout # Log out3. Files and Directories
cd /home # Change to /home</code>
<code>cd .. # Up one level</code>
<code>cd ../.. # Up two levels</code>
<code>cd ~ # Go to home directory</code>
<code>cd ~user1 # Home of user1</code>
<code>cd - # Return to previous directory</code>
<code>pwd # Print working directory</code>
<code>ls # List files</code>
<code>ls -F # List with type indicators</code>
<code>ls -l # Detailed list</code>
<code>ls -a # Show hidden files</code>
<code>ls *[0-9]* # Show names containing digits</code>
<code>tree # Tree view of directories</code>
<code>mkdir dir1 # Create directory</code>
<code>mkdir dir1 dir2 # Create two directories</code>
<code>mkdir -p /tmp/dir1/dir2 # Create nested directories</code>
<code>rm -f file1 # Force delete file</code>
<code>rmdir dir1 # Remove empty directory</code>
<code>rm -rf dir1 # Remove directory and its contents</code>
<code>mv dir1 new_dir # Rename or move directory</code>
<code>cp file1 file2 # Copy file</code>
<code>cp dir/* . # Copy all files from dir to current</code>
<code>ln -s file1 link1 # Create symbolic link</code>
<code>ln file1 link1 # Create hard link</code>
<code>touch -t 0712250000 file1 # Set timestamp (YYMMDDhhmm)</code>
<code>file file1 # Show MIME type</code>
<code>iconv -l # List known encodings</code>
<code>iconv -f from -t to input > output # Convert encoding</code>
<code>find . -maxdepth 1 -name *.jpg -exec convert "{}" -resize 80x60 "thumbs/{}" \; # Batch resize images4. File Search
find / -name file1 # Search from root</code>
<code>find / -user user1 # Files owned by user1</code>
<code>find /home/user1 -name \*.bin # Search .bin files</code>
<code>find /usr/bin -type f -atime +100 # Files not accessed in 100 days</code>
<code>find /usr/bin -type f -mtime -10 # Files modified in last 10 days</code>
<code>find / -name \*.rpm -exec chmod 755 '{}' \; # Change permissions of .rpm files</code>
<code>locate \*.ps # Find .ps files (requires updatedb)</code>
<code>whereis halt # Locate binary, source, man page</code>
<code>which halt # Show full path of executable5. Mounting Filesystems
mount /dev/hda2 /mnt/hda2 # Mount partition</code>
<code>umount /dev/hda2 # Unmount partition</code>
<code>fuser -km /mnt/hda2 # Force unmount if busy</code>
<code>mount -o loop file.iso /mnt/cdrom # Mount ISO image</code>
<code>mount -t vfat /dev/hda5 /mnt/hda5 # Mount FAT32</code>
<code>mount /dev/sda1 /mnt/usbdisk # Mount USB drive</code>
<code>mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share # Mount Windows share6. Disk Space
df -h # Show mounted partitions</code>
<code>du -sh dir1 # Estimate disk usage of dir1</code>
<code>rpm -qa | sort -k1,1n # List installed RPMs by size</code>
<code>dpkg-query -W -f='${Installed-Size}\t${Package}
' | sort -k1,1n # List installed DEBs by size7. Users and Groups
groupadd group_name # Create group</code>
<code>useradd -c "Name" -g admin -d /home/user1 -s /bin/bash user1 # Add user to group admin</code>
<code>passwd user1 # Change password (root only)</code>
<code>chage -E 2005-12-31 user1 # Set password expiry date</code>
<code>newgrp group_name # Switch primary group8. File Permissions
chmod ugo+rwx file # Grant rwx to user, group, others</code>
<code>chmod go-rwx file # Remove rwx from group and others</code>
<code>chown user1 file # Change owner</code>
<code>chgrp group1 file # Change group</code>
<code>chmod u+s /bin/file1 # Set SUID bit</code>
<code>chmod g+s /home/public # Set SGID on directory</code>
<code>chmod o+t /home/public # Set sticky bit9. Special File Attributes
chattr +i file1 # Make immutable</code>
<code>chattr +a file1 # Append‑only</code>
<code>lsattr # List attributes10. Archiving and Compression
bzip2 file1 # Compress</code>
<code>gzip -9 file1 # Maximum compression</code>
<code>tar -cvf archive.tar file1 # Create tarball</code>
<code>tar -xvf archive.tar # Extract tarball</code>
<code>zip file1.zip file1 # Create zip archive</code>
<code>unzip file1.zip # Extract zip archive11. RPM Package Management (Fedora/RedHat)
rpm -ivh package.rpm # Install</code>
<code>rpm -U package.rpm # Upgrade</code>
<code>rpm -e package_name # Remove</code>
<code>rpm -qa # List installed RPMs</code>
<code>rpm -q package_name # Query package12. YUM Package Manager (Fedora/RedHat)
yum install pkg # Install</code>
<code>yum update pkg # Update</code>
<code>yum remove pkg # Remove</code>
<code>yum list # List all packages13. DEB Package Management (Debian/Ubuntu)
dpkg -i package.deb # Install/upgrade</code>
<code>apt-get install pkg # Install via APT</code>
<code>apt-get update # Refresh package lists</code>
<code>apt-get upgrade # Upgrade all packages14. Viewing File Contents
cat file1 # Show file</code>
<code>less file1 # Paginated view</code>
<code>head -2 file1 # First two lines</code>
<code>tail -f /var/log/messages # Follow log15. Text Processing
grep pattern file # Search</code>
<code>sed 's/old/new/g' file # Replace</code>
<code>awk '{print $1}' file # Print first column</code>
<code>sort file | uniq # Unique lines16. Character Set Conversion
dos2unix file.txt # Convert DOS to UNIX line endings</code>
<code>unix2dos file.txt # Convert UNIX to DOS17. Filesystem Checks
fsck /dev/hda1 # Check/repair filesystem</code>
<code>badblocks -v /dev/hda1 # Find bad blocks18. Creating Filesystems
mkfs /dev/hda1 # Create generic filesystem</code>
<code>mke2fs -j /dev/hda1 # Create ext3 with journaling19. Swap Management
mkswap /dev/hda3 # Create swap area</code>
<code>swapon /dev/hda3 # Enable swap20. Backup and Restore
dump -0aj -f /tmp/home0.bak /home # Full backup</code>
<code>restore -if /tmp/home0.bak # Restore</code>
<code>rsync -avz /home /tmp # Sync directories</code>
<code>dd if=/dev/sda of=/tmp/image.img # Disk image copy21. Network Commands
ifconfig eth0 # Show interface config</code>
<code>ping www.example.com # Test connectivity</code>
<code>netstat -tup # List active connections</code>
<code>tcpdump -i eth0 port 80 # Capture HTTP traffic22. VIM Editor Basics
:q # Quit VIM</code>
<code>i # Insert mode</code>
<code>dd # Delete line</code>
<code>yy # Yank (copy) line</code>
<code>p # Paste</code>
<code>:w # Write (save)</code>
<code>:wq # Write and quit23. Additional System Utilities
date # Show or set date</code>
<code>uptime # System uptime</code>
<code>top # Interactive process viewer</code>
<code>dmesg # Kernel ring buffer</code>
<code>free -h # Memory usageThis reference compiles over a hundred frequently used Linux commands, grouped by functional areas, to serve as a quick‑lookup cheat sheet for system administrators, developers, and anyone working in a Unix‑like environment.
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.
