Operations 37 min read

Essential Linux Command Cheat Sheet for System Administration

A comprehensive reference of essential Linux commands covering system information, shutdown, file and directory handling, searching, mounting, disk usage, user and group management, permissions, special attributes, archiving, package management, networking, and VIM editing, providing quick syntax and usage notes for each operation.

Linux Cloud Computing Practice
Linux Cloud Computing Practice
Linux Cloud Computing Practice
Essential Linux Command Cheat Sheet for System Administration

This article provides a comprehensive reference of common Linux commands for system administration.

1. Basic Commands

uname -m               # display processor architecture</code>
<code>uname -r               # display kernel version</code>
<code>dmidecode -q          # show hardware components</code>
<code>hdparm -i /dev/hda    # list disk characteristics</code>
<code>hdparm -tT /dev/sda   # perform a read test on a disk</code>
<code>cat /proc/cpuinfo     # display CPU information</code>
<code>cat /proc/interrupts # show interrupts</code>
<code>cat /proc/meminfo     # check memory usage</code>
<code>cat /proc/swaps       # list active swap spaces</code>
<code>cat /proc/version     # display kernel version</code>
<code>cat /proc/net/dev     # show network interfaces and statistics</code>
<code>cat /proc/mounts      # list mounted filesystems</code>
<code>lspci -tv            # list PCI devices</code>
<code>lsusb -tv            # show USB devices</code>
<code>date                  # display 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              # write system time to BIOS

2. Shutdown and Reboot

shutdown -h now       # halt immediately</code>
<code>init 0                # halt (alternative)</code>
<code>telinit 0            # halt (alternative)</code>
<code>shutdown -h HH:MM    # schedule shutdown</code>
<code>shutdown -c          # cancel scheduled shutdown</code>
<code>shutdown -r now       # reboot immediately</code>
<code>reboot               # reboot</code>
<code>logout               # log out

3. Files and Directories

cd /home              # change to /home</code>
<code>cd ..                 # go up one level</code>
<code>cd ../..              # go up two levels</code>
<code>cd ~                  # go to home directory</code>
<code>cd ~user1            # go to user1's home</code>
<code>cd -                 # return to previous directory</code>
<code>pwd                  # print working directory</code>
<code>ls                   # list files</code>
<code>ls -F                # list with file type indicators</code>
<code>ls -l                # long format listing</code>
<code>ls -a                # show hidden files</code>
<code>ls *[0-9]*           # list names containing digits</code>
<code>tree                 # display directory tree</code>
<code>mkdir dir1           # create directory</code>
<code>mkdir -p /tmp/dir1/dir2 # create nested directories</code>
<code>rm -f file1          # force delete a file</code>
<code>rmdir dir1           # remove empty directory</code>
<code>rm -rf dir1          # delete directory and its contents</code>
<code>mv dir1 new_dir      # rename or move directory</code>
<code>cp file1 file2        # copy a file</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           # display file type</code>
<code>iconv -l             # list known encodings</code>
<code>iconv -f from -t to inputFile > outputFile # convert encoding</code>
<code>find . -maxdepth 1 -name "*.jpg" -exec convert "{}" -resize 80x60 "thumbs/{}" \; # batch resize images

4. 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 for .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 within 10 days</code>
<code>find / -name "*.rpm" -exec chmod 755 "{}" \; # set permissions</code>
<code>locate "*.ps"                    # locate .ps files (requires updatedb)</code>
<code>whereis halt                     # locate binary, source, man page</code>
<code>which halt                       # show full path of executable

5. 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 filesystem</code>
<code>mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share # mount Windows share

6. Disk Space

df -h                     # show mounted partitions</code>
<code>du -sh dir1               # estimate disk usage of dir1</code>
<code>du -sk * | sort -rn      # list files/directories by size</code>
<code>rpm -qa --qf '%10{SIZE}t%{NAME}
' | sort -k1,1n # list RPM packages by size</code>
<code>dpkg-query -W -f='${Installed-Size}\t${Package}
' | sort -k1,1n # list DEB packages by size

7. Users and Groups

groupadd group_name        # create group</code>
<code>groupdel group_name        # delete group</code>
<code>useradd -c "Name" -g admin -d /home/user1 -s /bin/bash user1 # add user to admin group</code>
<code>passwd user1               # change user password</code>
<code>chage -E 2005-12-31 user1 # set password expiration date</code>
<code>newgrp group_name          # switch to a new primary group

8. File Permissions

chmod ugo+rwx directory1    # give read/write/execute to all</code>
<code>chmod go-rwx directory1    # remove rwx from group and others</code>
<code>chown user1 file1          # change file owner</code>
<code>chown -R user1 directory1 # recursively change owner</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 bit</code>
<code>chmod +x file            # make executable

9. Special File Attributes

chattr +i file1            # make immutable</code>
<code>chattr +a file1            # append‑only</code>
<code>lsattr                    # list special attributes

10. Archiving and Compression

bzip2 file1                # compress with bzip2</code>
<code>gzip -9 file1              # maximum gzip 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 archive

11. RPM Package Management

rpm -ivh package.rpm       # install RPM</code>
<code>rpm -Uvh package.rpm      # upgrade RPM</code>
<code>rpm -e package_name       # erase RPM</code>
<code>rpm -qa                   # list installed RPMs</code>
<code>rpm -qf /etc/httpd/conf/httpd.conf # find owning package

12. YUM Package Manager

yum install package_name   # install package</code>
<code>yum update package_name   # update package</code>
<code>yum remove package_name   # remove package</code>
<code>yum list                  # list all packages</code>
<code>yum clean all             # clean cache

13. DEB Package Management

dpkg -i package.deb       # install DEB</code>
<code>dpkg -r package_name    # remove DEB</code>
<code>apt-get install pkg     # install via APT</code>
<code>apt-get update           # update package lists</code>
<code>apt-get upgrade          # upgrade all packages

14. Viewing File Contents

cat file1                 # display file</code>
<code>more file1                # paginate output</code>
<code>less file1                # paginate with backward navigation</code>
<code>head -2 file1            # first two lines</code>
<code>tail -f /var/log/messages # follow log file

15. Text Processing

grep pattern file         # search for pattern</code>
<code>sed 's/old/new/g' file   # replace text</code>
<code>awk '{print $1}' file    # print first column</code>
<code>sort file | uniq         # unique sorted lines</code>
<code>tr 'a-z' 'A-Z'           # translate to uppercase

16. Character Set Conversion

dos2unix file.txt          # convert DOS to UNIX line endings</code>
<code>unix2dos file.txt          # convert UNIX to DOS line endings

17. Filesystem Analysis

badblocks -v /dev/hda1    # check for bad blocks</code>
<code>fsck /dev/hda1           # check/repair filesystem

18. Initialize Filesystem

mkfs /dev/hda1            # create filesystem</code>
<code>mke2fs -j /dev/hda1      # create ext3 with journaling

19. Swap Management

mkswap /dev/hda3          # create swap area</code>
<code>swapon /dev/hda3          # enable swap

20. Backup and Restore

dump -0aj -f /tmp/home0.bak /home # full backup of /home</code>
<code>restore -if /tmp/home0.bak          # restore backup</code>
<code>rsync -av --delete /home /tmp       # synchronize directories</code>
<code>dd if=/dev/sda of=/tmp/image.img      # disk image copy

21. CD/DVD Operations

mkisofs -o cd.iso /data   # create ISO image</code>
<code>cdrecord dev=/dev/cdrom cd.iso # burn ISO</code>
<code>mount -o loop cd.iso /mnt/iso # mount ISO

22. Network Commands

ifconfig eth0            # show interface config</code>
<code>ifup eth0                # bring interface up</code>
<code>ifdown eth0              # bring interface down</code>
<code>route -n                # display routing table</code>
<code>netstat -tup            # list active connections</code>
<code>tcpdump -i eth0 port 80 # capture HTTP traffic</code>
<code>nslookup www.example.com # DNS lookup

23. Listing Directory Contents

ls -a                    # all files including hidden</code>
<code>ls -l                    # long format</code>
<code>ls -R                    # recursive

24. Determine File Type

file filename            # show file type

25. Copying Files and Directories

cp source dest           # copy file</code>
<code>cp -r src_dir dest_dir   # copy directory recursively</code>
<code>mv oldname newname       # rename or move</code>
<code>rm -rf dir               # delete directory tree

26. Common System Commands

date                     # show current date/time</code>
<code>uptime                   # show system uptime</code>
<code>who                      # list logged‑in users</code>
<code>dmesg                    # kernel ring buffer</code>
<code>free                     # memory usage

27. VIM Editor

vim file                 # open file in VIM</code>
<code>:q                      # quit VIM</code>
<code>:w                      # write (save) file</code>
<code>:wq                     # write and quit</code>
<code>i                       # enter insert mode</code>
<code>Esc                     # return to command mode

28. RPM Package Operations

rpm -ivh package.rpm    # install</code>
<code>rpm -e package_name    # erase</code>
<code>rpm -Uvh package.rpm   # upgrade</code>
<code>rpm -Fvh package.rpm   # update</code>
<code>rpm -q package_name    # query</code>
<code>rpm -ql package_name   # list files in package
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxcommand-linesystem-administration
Linux Cloud Computing Practice
Written by

Linux Cloud Computing Practice

Welcome to Linux Cloud Computing Practice. We offer high-quality articles on Linux, cloud computing, DevOps, networking and related topics. Dive in and start your Linux cloud computing journey!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.