Fundamentals 41 min read

600 Essential Linux Commands Every Sysadmin Should Know

The article compiles a comprehensive list of 600 Linux commands covering system information, file and directory operations, permissions, searching, mounting, disk management, user and group handling, networking, package management, backup, and editing, providing concise usage examples for each command.

Linux Tech Enthusiast
Linux Tech Enthusiast
Linux Tech Enthusiast
600 Essential Linux Commands Every Sysadmin Should Know

1. Basic Commands

uname -m            # display processor architecture
uname -r            # display kernel version
arch                # display processor architecture
cat /proc/cpuinfo   # show CPU info
cat /proc/interrupts
cat /proc/meminfo   # check 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                # show system date
cal 2007            # display calendar for 2007
date 041217002007.00 # set date and time (MMDDhhmmYYYY.ss)
clock -w            # write system time to BIOS

2. Shutdown and Reboot

shutdown -h now    # power off immediately
init 0              # power off (alternative)
telinit 0           # power off (alternative)
shutdown -h HH:MM   # schedule shutdown at specific time
shutdown -c         # cancel scheduled shutdown
shutdown -r now    # reboot immediately
reboot              # reboot (alternative)
logout              # log out

3. Files and Directories

cd /home            # change to /home directory
cd ..               # go up one level
cd ../..            # go up two levels
cd                  # go to home directory
cd ~user1           # go to user1's home directory
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/directories containing numbers
tree                # display directory tree (method 1)
lstree              # display directory tree (method 2)
mkdir dir1          # create directory dir1
mkdir dir1 dir2     # create two directories
mkdir -p /tmp/dir1/dir2   # create nested directories
rm -f file1         # force delete file1
rmdir dir1          # remove empty directory dir1
rm -rf dir1         # remove directory and its contents recursively
mv dir1 new_dir     # rename or move directory
cp file1 file2      # copy file
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
ln file1 lnk1       # create hard link
touch -t 0712250000 file1   # set file timestamp (YYMMDDhhmm)
file file1          # display MIME type of file
iconv -l            # list known encodings
iconv -f fromEncoding -t toEncoding inputFile > outputFile   # convert file encoding
find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \;   # batch resize images

4. File Search

find / -name file1               # search from root for file1
find / -user user1               # search files owned by user1
find /home/user1 -name *.bin    # search for .bin files in /home/user1
find /usr/bin -type f -atime +100   # find executables 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 '{}' \;   # set permissions on .rpm files
find / -xdev -name *.rpm        # search .rpm files ignoring removable devices
locate *.ps                     # locate .ps files (requires updatedb)
whereis halt                    # locate binary, source, and man page for halt
which halt                      # show full path of executable

5. 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 updating /etc/mtab
mount /dev/fd0 /mnt/floppy               # mount floppy
mount /dev/cdrom /mnt/cdrom             # mount CD/DVD
mount /dev/hdc /mnt/cdrecorder           # mount CD-RW/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 drive
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share   # mount Windows share

6. Disk Space

df -h                     # show mounted partitions with sizes
ls -lSr | more           # list files sorted by size
du -sh dir1               # estimate disk usage of dir1
du -sk * | sort -rn      # list directories/files by size
rpm -q -a --qf '%10{SIZE}t%{NAME}
' | sort -k1,1n   # list installed RPM packages by size (RPM/Fedora)
dpkg-query -W -f='${Installed-Size;10}t${Package}
' | sort -k1,1n   # list installed DEB packages by size (Debian/Ubuntu)

7. Users and Groups

groupadd group_name      # create new group
groupdel group_name      # delete group
groupmod -n new_group_name old_group_name   # rename group
useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1   # create user in admin group
useradd user1           # create new user
userdel -r user1         # delete user and home directory
usermod -c "User FTP" -g system -d /ftp/user1 -s /sbin/nologin user1   # modify user attributes
passwd                  # change password (root only for other users)
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 group for file creation

8. File Permissions

ls -lh                   # list with human‑readable permissions
chmod ugo+rwx directory1 # give read/write/execute to user, group, others
chmod go-rwx directory1 # remove permissions 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 set
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 g-s /home/public  # remove SGID
chmod o+t /home/public  # set sticky bit
chmod o-t /home/public  # remove sticky bit
chmod +x file           # add execute permission
chmod -x file           # remove execute permission

9. 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   # secure deletion
chattr +S file1   # sync writes immediately
chattr +u file1   # allow undeletion
lsattr            # list file attributes

10. Archiving and Compression

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 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  # zip multiple files/directories
unzip file1.zip                    # extract zip archive

11. 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 packages
rpm -qi package_name               # query detailed info
rpm -ql package_name               # list files provided by package
rpm -qc package_name               # list config files of package
rpm -q --whatrequires package_name # show packages that depend on this one
rpm -V package_name                # verify package files
rpm --import /path/to/RPM-GPG-KEY # import GPG key
rpm --checksig package.rpm         # verify package signature

12. YUM Package Manager

yum install package_name            # install package
yum localinstall package.rpm        # install local RPM with dependency resolution
yum update package_name            # update package
yum remove package_name             # remove package
yum list                            # list all packages
yum search package_name             # search repository
yum clean packages                  # clean package cache
yum clean all                      # clean all caches

13. DEB Package Management

dpkg -i package.deb                 # install or upgrade DEB package
dpkg -r package_name                # remove package
dpkg -l                             # list installed DEB packages
dpkg -s package_name                # show status of package
dpkg -L package_name                 # list files installed by package
apt-get install package_name        # install package via APT
apt-get update                      # update package index
apt-get upgrade                     # upgrade all upgradable packages
apt-get remove package_name         # remove package
apt-cache search keyword            # search package names

14. Viewing File Contents

cat file1                         # display file
tac file1                         # display file in reverse order
more file1                        # paginate long file
less file1                        # paginate with backward navigation
head -2 file1                     # show first two lines
tail -2 file1                     # show last two lines
tail -f /var/log/messages         # follow appended output

15. Text Processing

grep pattern file                 # search for pattern in file
sed 's/old/new/g' file           # replace text
awk '{print $1}' file            # field extraction
tr '[:lower:]' '[:upper:]' < file # translate case
sort file                         # sort lines
uniq file                         # filter duplicate lines
comm file1 file2                 # compare two files

16. Character Set Conversion and File Format

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                         # list supported conversions

17. Filesystem Analysis

badblocks -v /dev/hda1            # check for bad blocks
fsck /dev/hda1                    # check/repair filesystem
fsck.ext2 /dev/hda1               # check/repair ext2 filesystem
fsck.ext3 /dev/hda1               # check/repair ext3 filesystem
fsck.vfat /dev/hda1               # check/repair FAT filesystem

18. Initializing a Filesystem

mkfs /dev/hda1                    # create generic filesystem
mke2fs /dev/hda1                 # create ext2 filesystem
mke2fs -j /dev/hda1              # create ext3 (with journaling)
mkfs -t vfat /dev/hda1           # create FAT32 filesystem
fdformat -n /dev/fd0             # format floppy
mkswap /dev/hda3                  # create swap area

19. Swap Filesystem

mkswap /dev/hda3                 # create swap partition
swapon /dev/hda3                 # enable swap
swapon /dev/hda2 /dev/hdb3       # enable multiple swap partitions

20. Backup

dump -0aj -f /tmp/home0.bak /home   # full backup of /home
dump -1aj -f /tmp/home0.bak /home   # incremental backup of /home
restore -if /tmp/home0.bak           # restore incremental backup
rsync -rogpav --delete /home /tmp    # sync directories
rsync -az -e ssh --delete ip:/home /local   # remote sync with compression
dd if=/dev/sda of=/tmp/file1        # copy raw disk to file
tar -Puf backup.tar /home/user      # interactive backup with tar
(cd /tmp/local && tar c .) | ssh user@host 'cd /home/share && tar x -p'   # copy directory over SSH

21. CD/DVD Operations

cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force   # erase rewritable CD
mkisofs /dev/cdrom > cd.iso                                 # create ISO image
mkisofs -J -R -V "Label CD" -o ./cd.iso data_cd            # create ISO with Joliet and Rock Ridge
cdrecord -v dev=/dev/cdrom cd.iso                         # burn ISO to CD
mount -o loop cd.iso /mnt/iso                               # mount ISO image

22. Networking (Ethernet and Wi‑Fi)

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 routing table
route add -net 0/0 gw IP_Gateway  # set default gateway
hostname                         # show hostname
host www.example.com              # DNS lookup
nslookup www.example.com           # DNS lookup (alternative)
netstat -tup                     # list active connections with PIDs
tcpdump tcp port 80               # capture HTTP traffic
iwlist scan                      # scan Wi‑Fi networks
iwconfig eth1                     # show wireless interface config

23. Listing Directory Contents

ls -a            # all files including hidden
ls -l            # detailed list
ls -R            # recursive list
ls -ld           # list directory itself
pwd              # print working directory

24. Determining File Type

file filename    # display file type

25. Copying Files and Directories

cp source dest                 # copy file or directory
cp -r src_dir dest_dir        # recursive copy of directory tree

26. Common System Commands

date                         # view or set system date/time
hwclock                      # view hardware clock (requires root)
cal                          # display calendar
uptime                       # show system uptime
echo "text" >> file          # append text to file
cat file                     # display file content
cat file1 file2 > combined    # concatenate files
head -n 10 file              # first 10 lines
tail -n 10 file              # last 10 lines
tail -f file                 # follow file growth
more file                    # paginate forward only
less file                    # paginate with backward navigation
ls -al | less               # long list with paging
dmesg                        # kernel ring buffer messages
df -h                        # disk space usage
du -sh dir                   # summarize disk usage of directory
free -h                      # memory usage

27. VIM Editor

vim file                     # 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
:qa                          # quit all windows
: wq                         # write and quit
:set number                  # show line numbers

28. RPM Package Management Commands

rpm -ivh package.rpm          # install package (show progress)
rpm -e package_name           # erase package (keeps modified config files)
rpm -Uvh package.rpm          # upgrade package (replace older version)
rpm -Fvh package.rpm          # update package (only if newer)
rpm -q package_name           # query installed package
rpm -ql package_name          # list files provided by package
rpm -qi package_name          # detailed info about package

29. Software Package Management (RPM)

rpm –ivh wu-ftpd-2.6.2-8.i386.rpm   # install example package
rpm –e wu-ftpd                     # erase example package
rpm –Uvh wu-ftpd-2.6.2-8.i386.rpm   # upgrade example package
rpm –Fvh wu-ftpd-2.6.2-8.i386.rpm   # update example package if newer
rpm –q wu-ftpd                     # query package info
rpm –ql xv                         # list files of package xv
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.

LinuxShellCommand LineUnixSystem Administration
Linux Tech Enthusiast
Written 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

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.