Master 600 Essential Linux Commands: A Complete Guide for System Administrators
This article provides a comprehensive, step‑by‑step Linux command reference covering basic system information, file and directory management, searching, mounting, disk usage, user and group handling, permissions, packaging, networking, backup, and many other essential operations for administrators.
Today we present a comprehensive Linux command summary that includes the most frequently used operations in daily work.
1. Basic Commands
uname -m # display machine architecture
uname -r # display kernel version
dmidecode -q # show hardware components
hdparm -i /dev/hda # list disk characteristics
hdparm -tT /dev/sda # perform read tests on the disk
arch # display machine architecture
cat /proc/cpuinfo # show CPU information
cat /proc/interrupts# show interrupts
cat /proc/meminfo # check memory usage
cat /proc/swaps # list active swap devices
cat /proc/version # display kernel version
cat /proc/net/dev # show network interfaces and statistics
cat /proc/mounts # list mounted filesystems
lspci -tv # list PCI devices
lsusb -tv # list USB devices
date # show system date
cal 2007 # display calendar for 2007
clock -w # write system time to BIOS2. Shutdown
shutdown -h now # power off immediately (method 1)
init 0 # power off (method 2)
telinit 0 # power off (method 3)
shutdown -h hh:mm # schedule shutdown
shutdown -c # cancel scheduled shutdown
shutdown -r now # reboot immediately
reboot # reboot (method 2)
logout # log out3. Files and Directories
cd /home # change to /home directory
cd .. # go up one level
cd ../.. # go up two levels
cd ~ # go to personal home directory
cd ~user1 # go to user1's home directory
cd - # return to previous directory
pwd # show current working directory
ls # list files in current directory
ls -F # list files with type indicators
ls -l # detailed list of files and directories
ls -a # show hidden files
ls *[0-9]* # list files 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 at once
mkdir -p /tmp/dir1/dir2 # create nested directory tree
rm -f file1 # force delete file1
rmdir dir1 # remove empty directory dir1
rm -rf dir1 # recursively delete directory dir1 and its contents
rm -rf dir1 dir2 # delete two directories together
mv dir1 new_dir # rename or move directory
cp file1 file2 # copy a file
cp dir/* . # copy all files from dir to current directory
cp -a /tmp/dir1 . # copy directory preserving attributes
cp -a dir1 dir2 # copy a directory
ln -s file1 lnk1 # create a symbolic link
ln file1 lnk1 # create a hard link
touch -t 0712250000 file1# set file timestamp (YYMMDDhhmm)
file file1 # display MIME type of file
iconv -l # list known encodings
iconv -f from -t to in > out # convert file encoding
find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; # batch resize images4. 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 files not accessed in last 100 days
find /usr/bin -type f -mtime -10 # find files modified within last 10 days
find / -name \*.rpm -exec chmod 755 "{}" \; # set permissions on .rpm files
find / -xdev -name \*.rpm # search .rpm files ignoring removable media
locate \*.ps # locate .ps files (run updatedb first)
whereis halt # locate binary, source, or man page for halt
which halt # show full path of executable5. Mount a Filesystem
mount /dev/hda2 /mnt/hda2 # mount partition hda2
umount /dev/hda2 # unmount partition hda2
fuser -km /mnt/hda2 # force unmount when busy
umount -n /mnt/hda2 # unmount without updating /etc/mtab
mount /dev/fd0 /mnt/floppy # mount floppy disk
mount /dev/cdrom /mnt/cdrom # mount CD/DVD
mount /dev/hdc /mnt/cdrecorder # mount CD‑RW/DVD
mount -o loop file.iso /mnt/cdrom # mount ISO image
mount -t vfat /dev/hda5 /mnt/hda5 # mount Windows FAT32 filesystem
mount /dev/sda1 /mnt/usbdisk # mount USB flash drive
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share # mount Windows share6. Disk Space
df -h # show mounted partitions with human‑readable sizes
ls -lSr | more # list files sorted by size
du -sh dir1 # estimate disk usage of dir1
du -sk * | sort -rn # list files/directories by size
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n # list installed RPM packages by size
dpkg-query -W -f='${Installed-Size}t${Package}
' | sort -k1,1n # list installed DEB packages by size7. Users and Groups
groupadd group_name # create a new group
groupdel group_name # delete a group
groupmod -n new old # rename a group
useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1 # create user in admin group
useradd user1 # create a new user
userdel -r user1 # delete a user and its home directory
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 # modify user attributes
passwd user1 # change user password (root only)
chage -E 2005-12-31 user1 # set password expiration date
pwck # verify /etc/passwd syntax
grpck # verify /etc/group syntax
newgrp group_name # switch to a new group for newly created files8. File Permissions (use "+" to set, "-" to remove)
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, rename, or link)
chattr +s file1 # allow safe deletion
chattr +S file1 # force sync after write
chattr +u file1 # allow recovery of a deleted file
lsattr # list special attributes9. Special File Attributes (same commands as above)
chattr +a file1
chattr +c file1
chattr +d file1
chattr +i file1
chattr +s file1
chattr +S file1
chattr +u file1
lsattr10. Archive and Compression
bunzip2 file1.bz2 # decompress .bz2 file
bzip2 file1 # compress file with bzip2
gunzip file1.gz # decompress .gz file
gzip file1 # compress file 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 files/dirs 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 -cvf archive.tar file1 file2 dir1 # create tarball with multiple items
tar -tf archive.tar # list contents of tarball
tar -xvf archive.tar # extract tarball
tar -xvf archive.tar -C /tmp # extract to /tmp
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 archive11. RPM Packages
rpm -ivh package.rpm # install RPM package
rpm -ivh --nodeps package.rpm # install ignoring dependencies
rpm -U package.rpm # upgrade without changing config files
rpm -F package.rpm # update already installed package
rpm -e package_name.rpm # remove package
rpm -qa # list all installed RPMs
rpm -qa | grep httpd # filter RPMs containing "httpd"
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 package_name --whatrequires # show packages that depend on this one
rpm -q package_name --whatprovides # show what this package provides
rpm -q package_name --scripts # show install/remove scripts
rpm -q package_name --changelog # show change log
rpm -qf /etc/httpd/conf/httpd.conf # find which RPM provides a file
rpm -qp package.rpm -l # list files in an uninstalled RPM
rpm --import /media/cdrom/RPM-GPG-KEY # import GPG key
rpm --checksig package.rpm # verify package integrity
rpm -V package_name # verify package files
rpm -Va # verify all installed RPMs (use with care)
rpm -Vp package.rpm # verify an uninstalled RPM
rpm2cpio package.rpm | cpio --extract --make-directories *bin* # extract executable from RPM
rpmbuild --rebuild package.src.rpm # rebuild source RPM12. YUM Package Manager
yum install package_name # install package
yum localinstall package.rpm # install local RPM with dependency resolution
yum update package_name.rpm # update all installed packages
yum update package_name # update a specific package
yum remove package_name # remove a package
yum list # list all installed packages
yum search package_name # search repository for a package
yum clean packages # clean downloaded packages
yum clean headers # clean header files
yum clean all # clean all caches13. DEB Packages
dpkg -i package.deb # install or upgrade DEB package
dpkg -r package_name # remove DEB package
dpkg -l # list installed DEB packages
dpkg -l | grep httpd # filter packages containing "httpd"
dpkg -s package_name # show package status/info
dpkg -L package_name # list files provided by package
dpkg --contents package.deb # list contents of an uninstalled package
dpkg -S /bin/ping # find which package provides a file
apt-get install package_name # install/update DEB package
apt-get update # update package index
apt-get upgrade # upgrade all installed packages
apt-get remove package_name # remove DEB package
apt-get check # verify package dependencies
apt-get clean # clean downloaded package files
apt-cache search searched-package # search package names14. View File Contents
cat file1 # display file from start
tac file1 # display file from end
more file1 # paginate long file
less file1 # paginate 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 time15. Text Processing
cat file1 file2 | command > file1_out.txt # pipe through command (sed, grep, awk, etc.)
grep Aug /var/log/messages # search for "Aug" in log
grep ^Aug /var/log/messages # lines starting with "Aug"
grep [0-9] /var/log/messages # lines containing digits
grep Aug -R /var/log/* # recursive search for "Aug"
sed 's/string1/string2/g' example.txt # replace string1 with string2
sed '/^$/d' example.txt # delete empty lines
sed -e '1d' result.txt # delete first line
awk 'NR%2==1' example.txt # keep odd-numbered lines
paste file1 file2 # merge files column‑wise
paste -d '+' file1 file2 # merge with '+' delimiter
sort file1 file2 | uniq # unique lines
sort file1 file2 | uniq -u # lines unique to each file
comm -1 file1 file2 # show lines only in file2
comm -2 file1 file2 # show lines only in file1
comm -3 file1 file2 # show common lines16. Character Set and File Format 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 all supported conversions17. Filesystem Analysis
badblocks -v /dev/hda1 # check for bad blocks
fsck /dev/hda1 # check/repair ext2/3/4 filesystem
fsck.ext2 /dev/hda1
fsck.ext3 /dev/hda1
fsck.vfat /dev/hda1
fsck.msdos /dev/hda118. Initialise a Filesystem
mkfs /dev/hda1 # create generic filesystem
mke2fs /dev/hda1 # create ext2 filesystem
mke2fs -j /dev/hda1 # create ext3 (journaled) filesystem
mkfs -t vfat -F 32 /dev/hda1 # create FAT32 filesystem
fdformat -n /dev/fd0 # format floppy disk
mkswap /dev/hda3 # create swap area19. Swap Filesystem
mkswap /dev/hda3 # create swap area
swapon /dev/hda3 # enable swap
swapon /dev/hda2 /dev/hdb3 # enable two swap partitions20. Backup
dump -0aj -f /tmp/home0.bak /home # full backup of /home
dump -1aj -f /tmp/home0.bak /home # interactive backup of /home
restore -if /tmp/home0.bak # restore interactive backup
rsync -rogpav --delete /home /tmp # sync directories
rsync -rogpav -e ssh --delete /home user@host:/tmp # sync over SSH
dd bs=1M if=/dev/hda | gzip | ssh user@host 'dd of=hda.gz' # remote disk backup via SSH
dd if=/dev/sda of=/tmp/file1 # backup disk to file
tar -Puf backup.tar /home/user # incremental backup of /home/user
find /home/user1 -name '*.txt' | xargs cp -av --parents /home/backup/ # copy txt files preserving hierarchy
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 # archive log files21. Optical Media
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force # erase rewritable CD
mkisofs /dev/cdrom > cd.iso # create ISO image from CD
mkisofs -J -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd # create ISO from directory
cdrecord -v dev=/dev/cdrom cd.iso # burn ISO to CD
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom # burn compressed ISO
mount -o loop cd.iso /mnt/iso # mount ISO image
cd-paranoia -B # extract audio tracks to WAV
dd if=/dev/hdc | md5sum # compute MD5 of CD device22. Network (Ethernet and Wi‑Fi)
ifconfig eth0 # show Ethernet config
ifup eth0 # enable interface
ifdown eth0 # disable interface
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 # set static IP
ifconfig eth0 promisc # enable promiscuous mode
dhclient eth0 # obtain IP via DHCP
route -n # show routing table
route add -net 0/0 gw IP_Gateway # set default gateway
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 # static route
echo 1 > /proc/sys/net/ipv4/ip_forward # enable IP forwarding
hostname # show hostname
host www.example.com # DNS lookup
nslookup www.example.com # DNS lookup (alternative)
ip link show # list network interfaces
mii-tool eth0 # show link status
ethtool eth0 # show interface statistics
netstat -tup # list active connections with PID
netstat -tupl # list listening services with PID
tcpdump tcp port 80 # capture HTTP traffic
iwlist scan # scan Wi‑Fi networks
iwconfig eth1 # show wireless interface config
whois www.example.com # query WHOIS database23. List Directory Contents
ls -a # show all files including hidden
ls -l # detailed list
ls -R # recursive listing
ls -ld # list directory info
pwd # show current directory24. View File Type
file filename # display file type25. Copy Files and Directories
cp -r source_dir target_dir # recursively copy directory
cp -a source_dir target_dir # copy preserving attributes26. Common System Commands
date # view or set system date/time
cal # display calendar
uptime # show system uptime27. VIM
VIM is a powerful command‑line text editor. Use vim filename to open a file, :q to quit, and :w to save. It supports three modes: command, insert, and ex.
28. RPM Package Management Commands
rpm -ivh package.rpm # install package
rpm -e package_name # remove package (keeps modified config files)
rpm -Uvh package.rpm # upgrade package
rpm -Fvh package.rpm # update package if newer version exists
rpm -q package_name # query installed package
rpm -ql package_name # list files provided by package29. Final Note
Errors may exist due to my limited knowledge; I welcome corrections. Thank you all, and see you again!
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.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
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.
