Operations 49 min read

600 Essential Linux Commands to Solve 99% of Everyday Tasks

This article compiles a comprehensive list of about 600 Linux commands covering system information, file and directory management, searching, mounting, disk usage, user and group handling, permissions, special attributes, archiving, package management, networking, and text editing, enabling users to handle the vast majority of routine Linux tasks efficiently.

Linux Tech Enthusiast
Linux Tech Enthusiast
Linux Tech Enthusiast
600 Essential Linux Commands to Solve 99% of Everyday Tasks

1. Basic Commands

uname -m    Show the machine's processor architecture</code>
<code>uname -r    Display the kernel version in use</code>
<code>dmidecode -q    Show hardware system components (SMBIOS/DMI)</code>
<code>hdparm -i /dev/hda    List a disk's architectural features</code>
<code>hdparm -tT /dev/sda    Perform a test read on the disk</code>
<code>arch    Show the machine's processor architecture</code>
<code>cat /proc/cpuinfo    Display CPU information</code>
<code>cat /proc/interrupts    Show interrupt statistics</code>
<code>cat /proc/meminfo    Verify memory usage</code>
<code>cat /proc/swaps    List active swap devices</code>
<code>cat /proc/version    Show the kernel version</code>
<code>cat /proc/net/dev    Show network adapters and statistics</code>
<code>cat /proc/mounts    List mounted file systems</code>
<code>lspci -tv    List PCI devices</code>
<code>lsusb -tv    Show USB devices</code>
<code>date    Show the system date</code>
<code>cal 2007    Show the calendar for the year 2007</code>
<code>date 041217002007.00    Set date and time (MMDDhhmmYY.ss)</code>
<code>clock -w    Save the current time to the BIOS</code>

<h2>2. Shutdown and Reboot</h2>
<pre><code>shutdown -h now    Power off the system (method 1)</code>
<code>init 0    Power off the system (method 2)</code>
<code>telinit 0    Power off the system (method 3)</code>
<code>shutdown -h HH:MM    Schedule a shutdown at a specific time</code>
<code>shutdown -c    Cancel a scheduled shutdown</code>
<code>shutdown -r now    Reboot the system (method 1)</code>
<code>reboot    Reboot the system (method 2)</code>
<code>logout    Log out of the current session</code>

<h2>3. Files and Directories</h2>
<pre><code>cd /home    Enter the /home directory</code>
<code>cd ..    Go up one directory level</code>
<code>cd ../..    Go up two directory levels</code>
<code>cd    Go to the user's home directory</code>
<code>cd ~user1    Go to user1's home directory</code>
<code>cd -    Return to the previous directory</code>
<code>pwd    Show the current working directory</code>
<code>ls    List files in the current directory</code>
<code>ls -F    List files with type indicators</code>
<code>ls -l    Show detailed information for files and directories</code>
<code>ls -a    Show hidden files</code>
<code>ls *[0-9]*    List files and directories containing numbers</code>
<code>tree    Display a tree view of files and directories from the root</code>
<code>lstree    Alternative command for tree view</code>
<code>mkdir dir1    Create a directory named dir1</code>
<code>mkdir dir1 dir2    Create two directories simultaneously</code>
<code>mkdir -p /tmp/dir1/dir2    Create a nested directory tree</code>
<code>rm -f file1    Force delete file1</code>
<code>rmdir dir1    Remove an empty directory named dir1</code>
<code>rm -rf dir1    Recursively delete dir1 and its contents</code>
<code>rm -rf dir1 dir2    Recursively delete two directories</code>
<code>mv dir1 new_dir    Rename or move a directory</code>
<code>cp file1 file2    Copy a file</code>
<code>cp dir/* .    Copy all files from a directory to the current directory</code>
<code>cp -a /tmp/dir1 .    Archive-copy a directory to the current location</code>
<code>cp -a dir1 dir2    Archive-copy a directory</code>
<code>ln -s file1 lnk1    Create a symbolic link to file1 named lnk1</code>
<code>ln file1 lnk1    Create a hard link to file1 named lnk1</code>
<code>touch -t 0712250000 file1    Change a file's timestamp (YYMMDDhhmm)</code>
<code>file file1    Output the MIME type of file1</code>
<code>iconv -l    List known encodings</code>
<code>iconv -f fromEncoding -t toEncoding inputFile > outputFile    Convert file encoding</code>
<code>find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \;    Batch resize images in the current directory

4. File Search

find / -name file1    Search for file1 starting from the root</code>
<code>find / -user user1    Find files owned by user1</code>
<code>find /home/user1 -name \*.bin    Search for files ending with .bin in /home/user1</code>
<code>find /usr/bin -type f -atime +100    Find executable files not accessed in the last 100 days</code>
<code>find /usr/bin -type f -mtime -10    Find files created or modified within the last 10 days</code>
<code>find / -name \*.rpm -exec chmod 755 '{}' \;    Find .rpm files and set permissions to 755</code>
<code>find / -xdev -name \*.rpm    Find .rpm files while ignoring removable devices</code>
<code>locate \*.ps    Locate files ending with .ps (run updatedb first)</code>
<code>whereis halt    Show locations of the binary, source, and man page for halt</code>
<code>which halt    Show the full path of the halt executable

5. Mounting a File System

mount /dev/hda2 /mnt/hda2    Mount the partition hda2 (ensure /mnt/hda2 exists)</code>
<code>umount /dev/hda2    Unmount the partition hda2 (ensure no processes are using it)</code>
<code>fuser -km /mnt/hda2    Force unmount when the device is busy</code>
<code>umount -n /mnt/hda2    Unmount without writing to /etc/mtab (useful for read‑only media)</code>
<code>mount /dev/fd0 /mnt/floppy    Mount a floppy disk</code>
<code>mount /dev/cdrom /mnt/cdrom    Mount a CD-ROM or DVD-ROM</code>
<code>mount /dev/hdc /mnt/cdrecorder    Mount a CD‑RW or DVD‑ROM</code>
<code>mount -o loop file.iso /mnt/cdrom    Mount an ISO image file</code>
<code>mount -t vfat /dev/hda5 /mnt/hda5    Mount a Windows FAT32 file system</code>
<code>mount /dev/sda1 /mnt/usbdisk    Mount a USB flash drive</code>
<code>mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share    Mount a Windows network share

6. Disk Space

df -h    Show mounted partitions with human‑readable sizes</code>
<code>ls -lSr | more    List files sorted by size (smallest first)</code>
<code>du -sh dir1    Estimate the disk usage of dir1</code>
<code>du -sk * | sort -rn    List files and directories sorted by size (largest first)</code>
<code>rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n    List installed RPM packages sorted by size (Fedora/RedHat)</code>
<code>dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n    List installed DEB packages sorted by size (Debian/Ubuntu)

7. Users and Groups

groupadd group_name    Create a new user group</code>
<code>groupdel group_name    Delete a user group</code>
<code>groupmod -n new_group_name old_group_name    Rename a user group</code>
<code>useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1    Create a user belonging to the admin group</code>
<code>useradd user1    Create a new user</code>
<code>userdel -r user1    Delete a user and remove its home directory</code>
<code>usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1    Modify user attributes</code>
<code>passwd    Change a password (root only)</code>
<code>passwd user1    Change password for user1</code>
<code>chage -E 2005-12-31 user1    Set password expiration date</code>
<code>pwck    Verify /etc/passwd syntax and integrity</code>
<code>grpck    Verify /etc/group syntax and integrity</code>
<code>newgrp group_name    Switch to a new primary group

8. File Permissions

ls -lh    Show permissions in a human‑readable format</code>
<code>chmod ugo+rwx directory1    Grant read, write, and execute to user, group, and others</code>
<code>chmod go-rwx directory1    Remove read, write, and execute from group and others</code>
<code>chown user1 file1    Change file owner</code>
<code>chown -R user1 directory1    Recursively change ownership</code>
<code>chgrp group1 file1    Change file group</code>
<code>chown user1:group1 file1    Change both owner and group</code>
<code>find / -perm -u+s    List files with the SUID bit set</code>
<code>chmod u+s /bin/file1    Set the SUID bit on a binary</code>
<code>chmod u-s /bin/file1    Remove the SUID bit</code>
<code>chmod g+s /home/public    Set the SGID bit on a directory</code>
<code>chmod g-s /home/public    Remove the SGID bit</code>
<code>chmod o+t /home/public    Set the sticky bit on a directory</code>
<code>chmod o-t /home/public    Remove the sticky bit</code>
<code>chmod +x path    Add execute permission for all</code>
<code>chmod -x path    Remove execute permission for all</code>
<code>chmod u+x path    Add execute permission for the owner</code>
<code>chmod g+x path    Add execute permission for the group</code>
<code>chmod o+x path    Add execute permission for others</code>
<code>chmod ug+x path    Add execute permission for owner and group</code>
<code>chmod =wx path    Grant write and execute, remove read for everyone</code>
<code>chmod ug=wx path    Grant write and execute to owner and group, remove read

9. Special File Attributes

Use “+” to set an attribute and “-” to clear it.

chattr +a file1    Allow only append operations</code>
<code>chattr +c file1    Enable automatic compression/decompression by the kernel</code>
<code>chattr +d file1    Exclude the file from dump backups</code>
<code>chattr +i file1    Make the file immutable (cannot be deleted, renamed, or linked)</code>
<code>chattr +s file1    Securely delete the file</code>
<code>chattr +S file1    Force synchronous writes after each write operation</code>
<code>chattr +u file1    Allow recovery of a deleted file</code>
<code>lsattr    Display special attributes

10. Archiving and Compression

bunzip2 file1.bz2    Decompress a .bz2 file</code>
<code>bzip2 file1    Compress a file using bzip2</code>
<code>gunzip file1.gz    Decompress a .gz file</code>
<code>gzip file1    Compress a file using gzip</code>
<code>gzip -9 file1    Compress with maximum compression</code>
<code>rar a file1.rar test_file    Create a .rar archive</code>
<code>rar a file1.rar file1 file2 dir1    Add multiple files and a directory to a .rar archive</code>
<code>rar x file1.rar    Extract a .rar archive</code>
<code>unrar x file1.rar    Extract a .rar archive</code>
<code>tar -cvf archive.tar file1    Create an uncompressed tarball</code>
<code>tar -tvf archive.tar    List contents of a tarball</code>
<code>tar -xvf archive.tar    Extract a tarball</code>
<code>tar -xvf archive.tar -C /tmp    Extract to /tmp</code>
<code>tar -cvfj archive.tar.bz2 dir1    Create a bzip2‑compressed tarball</code>
<code>tar -xvfj archive.tar.bz2    Extract a bzip2‑compressed tarball</code>
<code>tar -cvfz archive.tar.gz dir1    Create a gzip‑compressed tarball</code>
<code>tar -xvfz archive.tar.gz    Extract a gzip‑compressed tarball</code>
<code>zip file1.zip file1    Create a zip archive</code>
<code>zip -r file1.zip file1 file2 dir1    Recursively add files and directories to a zip archive</code>
<code>unzip file1.zip    Extract a zip archive

11. RPM Packages (Fedora/RedHat)

rpm -ivh package.rpm    Install an RPM package</code>
<code>rpm -ivh --nodeps package.rpm    Install ignoring dependency warnings</code>
<code>rpm -U package.rpm    Upgrade a package without changing config files</code>
<code>rpm -F package.rpm    Refresh an already‑installed package</code>
<code>rpm -e package.rpm    Remove an RPM package</code>
<code>rpm -qa    List all installed RPM packages</code>
<code>rpm -qa | grep httpd    Find installed packages containing "httpd"</code>
<code>rpm -qi package_name    Show detailed information about a package</code>
<code>rpm -qg "System Environment/Daemons"    List packages belonging to a component group</code>
<code>rpm -ql package_name    List files provided by an installed package</code>
<code>rpm -qc package_name    List configuration files of a package</code>
<code>rpm -q package_name --whatrequires    Show packages that depend on this package</code>
<code>rpm -q package_name --whatprovides    Show what this package provides</code>
<code>rpm -q package_name --scripts    Show install/remove scripts</code>
<code>rpm -q package_name --changelog    Show the package changelog</code>
<code>rpm -qf /etc/httpd/conf/httpd.conf    Find which package owns a file</code>
<code>rpm -qp package.rpm -l    List files in an uninstalled RPM</code>
<code>rpm --import /media/cdrom/RPM-GPG-KEY    Import a GPG key</code>
<code>rpm --checksig package.rpm    Verify package signature</code>
<code>rpm -V package_name    Verify file size, permissions, type, owner, MD5, timestamps</code>
<code>rpm -Va    Verify all installed RPMs (use with caution)</code>
<code>rpm -Vp package.rpm    Verify an uninstalled RPM</code>
<code>rpm2cpio package.rpm | cpio --extract --make-directories *bin*    Extract an executable from an RPM</code>
<code>rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm    Install a built RPM from source</code>
<code>rpmbuild --rebuild package.src.rpm    Rebuild an RPM from source

12. YUM Package Manager (Fedora/RedHat)

yum install package_name    Download and install an RPM package</code>
<code>yum localinstall package.rpm    Install an RPM using local repositories to resolve dependencies</code>
<code>yum update package_name.rpm    Update all installed RPMs</code>
<code>yum update package_name    Update a specific package</code>
<code>yum remove package_name    Remove an RPM package</code>
<code>yum list    List all installed packages</code>
<code>yum search package_name    Search for a package in repositories</code>
<code>yum clean packages    Remove downloaded package files</code>
<code>yum clean headers    Remove header files</code>
<code>yum clean all    Clean all cached data

13. DEB Packages (Debian/Ubuntu)

dpkg -i package.deb    Install or upgrade a DEB package</code>
<code>dpkg -r package_name    Remove a DEB package</code>
<code>dpkg -l    List all installed DEB packages</code>
<code>dpkg -l | grep httpd    Find installed packages containing "httpd"</code>
<code>dpkg -s package_name    Show status information for a package</code>
<code>dpkg -L package_name    List files installed by a package</code>
<code>dpkg --contents package.deb    List contents of an uninstalled DEB</code>
<code>dpkg -S /bin/ping    Find which package provides a file</code>
<code>apt-get install package_name    Install or upgrade a DEB package</code>
<code>apt-cdrom install package_name    Install from a CD-ROM</code>
<code>apt-get update    Refresh package lists</code>
<code>apt-get upgrade    Upgrade all installed packages</code>
<code>apt-get remove package_name    Remove a DEB package</code>
<code>apt-get check    Verify that package dependencies are satisfied</code>
<code>apt-get clean    Clean the local repository of retrieved package files</code>
<code>apt-cache search term    Search package names and descriptions

14. Viewing File Contents

cat file1    Display the contents of a file</code>
<code>tac file1    Display a file in reverse line order</code>
<code>more file1    Page through a long file</code>
<code>less file1    Page through a file with forward and backward navigation</code>
<code>head -2 file1    Show the first two lines of a file</code>
<code>tail -2 file1    Show the last two lines of a file</code>
<code>tail -f /var/log/messages    Follow a file as it grows (e.g., logs)

15. Text Processing

cat file1 file2 ... | command > file1_out.txt    Pipe files through a command and redirect output</code>
<code>cat file1 | sed 's/string1/string2/g' > result.txt    Replace all occurrences of string1 with string2</code>
<code>grep Aug /var/log/messages    Search for the keyword "Aug" in a log file</code>
<code>grep ^Aug /var/log/messages    Find lines starting with "Aug"</code>
<code>grep [0-9] /var/log/messages    Find lines containing digits</code>
<code>grep Aug -R /var/log/*    Recursively search for "Aug" in /var/log</code>
<code>sed '/^$/d' example.txt    Delete all blank lines</code>
<code>sed '/ *#/d; /^$/d' example.txt    Delete comments and blank lines</code>
<code>tr '[:lower:]' '[:upper:]'    Convert lower‑case to upper‑case</code>
<code>awk 'NR%2==1' example.txt    Print odd‑numbered lines</code>
<code>awk '{print $1}'    Print the first column</code>
<code>paste file1 file2    Merge two files column‑wise</code>
<code>sort file1 file2 | uniq    Show unique lines</code>
<code>comm -1 file1 file2    Show lines unique to file2

16. Character Set Conversion

dos2unix filedos.txt fileunix.txt    Convert a file from DOS to UNIX line endings</code>
<code>unix2dos fileunix.txt filedos.txt    Convert a file from UNIX to DOS line endings</code>
<code>recode ..HTML < page.txt > page.html    Convert a text file to HTML</code>
<code>recode -l    List all supported conversions

17. File System Checks

badblocks -v /dev/hda1    Scan for bad blocks on a disk</code>
<code>fsck /dev/hda1    Check and repair a Linux file system</code>
<code>fsck.ext2 /dev/hda1    Check/repair an ext2 file system</code>
<code>e2fsck -j /dev/hda1    Check/repair an ext3 file system (with journal)</code>
<code>fsck.vfat /dev/hda1    Check/repair a FAT file system

18. Initializing a File System

mkfs /dev/hda1    Create a generic file system</code>
<code>mke2fs /dev/hda1    Create an ext2 file system</code>
<code>mke2fs -j /dev/hda1    Create an ext3 (journaled) file system</code>
<code>mkfs -t vfat -F 32 /dev/hda1    Create a FAT32 file system</code>
<code>fdformat -n /dev/fd0    Format a floppy disk</code>
<code>mkswap /dev/hda3    Create a swap area

19. Swap File System

mkswap /dev/hda3    Create a swap partition</code>
<code>swapon /dev/hda3    Enable a swap partition</code>
<code>swapon /dev/hda2 /dev/hdb3    Enable two swap partitions

20. Backup

dump -0aj -f /tmp/home0.bak /home    Full backup of /home</code>
<code>dump -1aj -f /tmp/home0.bak /home    Interactive backup of /home</code>
<code>restore -if /tmp/home0.bak    Restore an interactive backup</code>
<code>rsync -rogpav --delete /home /tmp    Synchronize two directories</code>
<code>rsync -az -e ssh --delete user@host:/home/public /home/local    Sync remote to local via SSH with compression</code>
<code>dd if=/dev/sda of=/tmp/file1    Copy raw disk data to a file</code>
<code>tar -Puf backup.tar /home/user    Incremental backup of a directory</code>
<code>( cd /tmp/local && tar c . ) | ssh -C user@host "cd /home/share && tar x -p"    Copy a directory to a remote host over SSH</code>
<code>tar cf - . | (cd /tmp/backup ; tar xf - )    Copy a directory locally while preserving permissions</code>
<code>find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents    Find and copy all .txt files preserving directory structure</code>
<code>dd if=/dev/hda of=/dev/fd0 bs=512 count=1    Copy the MBR to a floppy</code>
<code>dd if=/dev/fd0 of=/dev/hda bs=512 count=1    Restore the MBR from a floppy

21. Optical Discs

cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force    Blank a rewritable CD</code>
<code>mkisofs /dev/cdrom > cd.iso    Create an ISO image of a disc</code>
<code>mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd    Create an ISO with volume label</code>
<code>cdrecord -v dev=/dev/cdrom cd.iso    Burn an ISO image to CD</code>
<code>mount -o loop cd.iso /mnt/iso    Mount an ISO image</code>
<code>cd-paranoia -B    Rip audio tracks from a CD to WAV files</code>
<code>dd if=/dev/hdc | md5sum    Compute MD5 checksum of a CD

22. Network

ifconfig eth0    Show Ethernet interface configuration</code>
<code>ifup eth0    Bring up the eth0 interface</code>
<code>ifdown eth0    Bring down the eth0 interface</code>
<code>ifconfig eth0 192.168.1.1 netmask 255.255.255.0    Set static IP address</code>
<code>ifconfig eth0 promisc    Enable promiscuous mode for packet sniffing</code>
<code>dhclient eth0    Obtain an IP address via DHCP</code>
<code>route -n    Show the routing table</code>
<code>route add -net 0/0 gw IP_Gateway    Add a default gateway</code>
<code>route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1    Add a static route</code>
<code>echo "1" > /proc/sys/net/ipv4/ip_forward    Enable IP forwarding</code>
<code>hostname    Show the system hostname</code>
<code>host www.example.com    Resolve a hostname to an IP address</code>
<code>nslookup www.example.com    DNS lookup</code>
<code>ip link show    Show status of all network interfaces</code>
<code>netstat -tup    Show active TCP/UDP connections with PIDs</code>
<code>tcpdump tcp port 80    Capture HTTP traffic</code>
<code>iwlist scan    Scan for wireless networks</code>
<code>whois www.example.com    Query the WHOIS database

23. Listing Directory Contents

ls -a    Show all files, including hidden ones</code>
<code>ls -l    Show detailed file information</code>
<code>ls -R    Recursively list sub‑directories</code>
<code>ls -ld    Show directory and link information</code>
<code>pwd    Print the current working directory

24. Determine File Type

file file1    Identify the file type

25. Copying Files and Directories

cp source destination    Copy a file or directory</code>
<code>cp -r source_dir dest_dir    Recursively copy a directory tree</code>
<code>touch file1    Create an empty file or update its timestamp</code>
<code>mv old_name new_name    Rename or move a file/directory</code>
<code>rm -f file1    Force delete a file</code>
<code>rmdir dir1    Remove an empty directory</code>
<code>rm -rf dir1    Recursively delete a directory and its contents

26. Common System Commands

date    Show or set the current date and time</code>
<code>hwclock    Show the hardware clock (requires root)</code>
<code>cal    Display a calendar</code>
<code>uptime    Show how long the system has been running</code>
<code>echo "text"    Print text to the terminal or a file</code>
<code>cat file    Display file contents</code>
<code>head -n file    Show the first n lines of a file</code>
<code>tail -n file    Show the last n lines of a file</code>
<code>tail -f file    Follow a file as it grows</code>
<code>more file    Page forward through a file</code>
<code>less file    Page forward and backward through a file</code>
<code>iostat, vmstat, free, dmesg    Various system diagnostics

27. VIM Editor

VIM is a powerful command‑line text editor. Launch it with vim followed by a file path. If the file exists, it opens for editing; otherwise, a new file is created. :q Quit VIM VIM has three modes:

Command mode – default mode for navigation and issuing commands.

Insert mode – press i to insert text; press Esc to return to command mode.

Ex mode – press : to enter command‑line mode for saving, quitting, etc.

Common command‑mode shortcuts: i – Insert before the cursor. o – Open a new line below. dd – Delete the current line. yy – Yank (copy) the current line. nyy – Yank n lines. p – Paste after the cursor. u – Undo the last change. /pattern – Search for a pattern.

Ex‑mode commands: :w – Write (save) changes. :q – Quit. :q! – Quit without saving. :x – Save and quit (equivalent to :wq). :set number – Show line numbers. :! command – Execute a shell command. :sh – Drop to a shell; Ctrl‑D returns to VIM.

28. RPM Package Management Commands

rpm -ivh package.rpm    Install a package (show progress with #)</code>
<code>rpm -e package    Remove a package (does not delete modified config files)</code>
<code>rpm -Uvh package.rpm    Upgrade a package to a newer version</code>
<code>rpm -Fvh package.rpm    Refresh (reinstall) a package</code>
<code>rpm -q package    Query information about an installed package</code>
<code>rpm -ql package    List files installed by a package

29. Additional Notes

The article concludes with a reminder to follow the author’s public account for updates and to give the post a like.

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 lineSystem AdministrationBashLinux commands
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.