DEV Community

Cover image for Decoding the Linux Command Line: 75 Indispensable Utilities Explained
Sujit Kumar
Sujit Kumar

Posted on • Edited on

1 1 1

Decoding the Linux Command Line: 75 Indispensable Utilities Explained

Top 75 Linux Commands Every Regular User Must Know

As a regular Linux user, mastering these essential commands can greatly enhance your productivity and efficiency. Let's dive into the top 75 Linux commands with practical examples.

  1. ls (List)

    • ls - List files and directories in the current directory.
    • ls -a - List all files, including hidden ones.
    • ls -l - List files with detailed information (permissions, owner, size, etc.).
    • ls -h - List files with detailed information in human readable format.
  2. pwd (Print Working Directory)

    • pwd - Display the current working directory.
  3. cd (Change Directory)

    • cd /path/to/directory - Navigate to the specified directory.
    • cd .. - Move up one directory level.
    • cd ~ - Navigate to your home directory.
    • cd - - Go back to the last directory.
  4. mkdir (Make Directory)

    • mkdir new_directory - Create a new directory.
    • mkdir -p /path/to/nested/directories - Create nested directories.
  5. touch (Create File)

    • touch new_file.txt - Create a new, empty file.
  6. mv (Move)

    • mv file.txt /path/to/directory - Move a file to a different directory.
    • mv old_name.txt new_name.txt - Rename a file.
  7. cp (Copy)

    • cp file.txt /path/to/directory - Copy a file to a different directory.
    • cp -r directory1 /path/to/directory2 - Copy a directory and its contents.
  8. rm (Remove)

    • rm file.txt - Delete a file.
    • rm -r directory - Delete a directory and its contents (use with caution!).
  9. cat (Concatenate)

    • cat file.txt - Display the contents of a file.
    • cat file1.txt file2.txt > combined.txt - Combine two files into one.
  10. echo (Print)

    • echo "Hello, World!" - Print a string.
    • echo $PATH - Print the value of an environment variable.
  11. clear

    • clear - Clear the terminal screen.
  12. man (Manual)

    • man ls - Display the manual page for the ls command.
  13. uname (System Information)

    • uname -a - Display detailed information about the system.
  14. whoami (User Information)

    • whoami - Print the current user's username.
  15. head (Show Top Lines)

    • head -n 10 file.txt - Display the first 10 lines of a file.
  16. tail (Show Bottom Lines)

    • tail -n 20 log.txt - Display the last 20 lines of a file.
  17. diff (Compare Files)

    • diff file1.txt file2.txt - Compare the contents of two files.
  18. cmp (Compare Files)

    • cmp file1.txt file2.txt - Check if two files are identical byte-by-byte.
  19. comm (Compare Files)

    • comm -13 file1.txt file2.txt - Show lines unique to each file and common lines.
  20. sort (Sort)

    • sort file.txt - Sort the lines of a file in alphabetical order.
    • sort -n file.txt - Sort the lines of a file numerically.
  21. tar (Archive)

    • tar -czf archive.tar.gz directory - Create a compressed tar archive of a directory.
    • tar -xzf archive.tar.gz - Extract files from a compressed tar archive.
  22. grep (Search)

    • grep "pattern" file.txt - Search for a pattern in a file.
    • ps aux | grep process_name - Find processes containing a specific name.
  23. ln (Create Link)

    • ln -s /path/to/file link_name - Create a symbolic link to a file.
  24. export (Set Environment Variables)

    • export PATH=$PATH:/new/path - Add a new path to the PATH environment variable.
  25. zip (Compress Files)

    • zip archive.zip file1.txt file2.txt - Create a ZIP archive with multiple files.
  26. unzip (Extract Files)

    • unzip archive.zip - Extract files from a ZIP archive.
  27. ssh (Secure Shell)

    • ssh user@remote_host - Connect to a remote system via SSH.
  28. service (Manage Services)

    • service apache2 start - Start the Apache web server service.
    • service mysql status - Check the status of the MySQL service.
  29. ps (Process Status)

    • ps aux - Display detailed information about running processes.
  30. kill and killall (Terminate Processes)

    • kill 1234 - Terminate a process with the specified PID (1234).
    • killall process_name - Terminate all processes with a specific name.
  31. df (Disk Usage)

    • df -h - Display disk usage in a human-readable format.
  32. mount (Mount File Systems)

    • mount /dev/sdb1 /mnt/usb - Mount a USB drive to the /mnt/usb directory.
  33. chmod (Change Permissions)

    • chmod 755 file.sh - Grant read, write, and execute permissions to the owner, and read and execute permissions to group and others.
  34. chown (Change Ownership)

    • chown user:group file.txt - Change the owner and group of a file.
  35. ifconfig (Network Configuration)

    • ifconfig - Display information about network interfaces and IP addresses.
  36. traceroute (Trace Network Route)

    • traceroute example.com - Trace the network path to a remote host.
  37. wget (Web Get)

    • wget https://example.com/file.zip - Download a file from a web server.
  38. ufw (Uncomplicated Firewall)

    • ufw enable - Enable the firewall.
    • ufw allow 22 - Allow incoming connections on port 22 (SSH).
  39. iptables (Firewall)

    • iptables -L - List current firewall rules.
    • iptables -A INPUT -p tcp --dport 80 -j ACCEPT - Allow incoming TCP connections on port 80 (HTTP).
  40. apt, pacman, yum, rpm (Package Managers)

    • apt update && apt upgrade (Ubuntu/Debian) - Update package lists and upgrade installed packages.
    • pacman -Syu (Arch Linux) - Synchronize package databases and upgrade installed packages.
    • yum update (CentOS/RHEL) - Update installed packages.
    • rpm -ivh package.rpm - Install an RPM package.
  41. sudo (Escalate Privileges)

    • sudo command - Run a command with superuser (root) privileges.
  42. cal (Calendar)

    • cal - Display the current month's calendar.
    • cal 2024 - Display the entire year's calendar for 2024.
  43. alias (Create Command Shortcuts)

    • alias ll='ls -l' - Create an alias for the ls -l command.
  44. dd (Data Duplicator)

    • dd if=/dev/zero of=/path/to/file bs=1M count=1024 - Create a 1GB file filled with zeros.
    • dd if=/path/to/iso of=/dev/sdx - Write an ISO image to a USB drive.
  45. whereis (Locate Command)

    • whereis ls - Find the binary, source, and manual page files for the ls command.
  46. whatis (Command Description)

    • whatis ls - Display a brief description of the ls command.
  47. top (Process Monitor)

    • top - Display real-time information about running processes and system resource usage.
  48. useradd and usermod (User Management)

    • useradd new_user - Create a new user account.
    • usermod -aG sudo new_user - Add an existing user to the sudo group.
  49. passwd (Change Password)

    • passwd - Change the password for the current user.
    • passwd user_name (as root) - Change the password for a specific user.
  50. curl (Transfer Data)

    • curl https://example.com - Fetch the contents of a URL.
    • curl ifconfig.me - Display your public IP address.
  51. ping (Test Network Connectivity)

    • ping google.com - Test connectivity to a remote host.
    • ping -c 2 google.com - Send 2 ping packets and stop.
  52. netstat (Network Statistics)

netstat -tunlp - Display listening network ports and associated processes.

  1. rsync (Remote Sync)

    • rsync -avz /path/to/source /path/to/destination - Sync files between directories locally or remotely.
  2. scp (Secure Copy)

    • scp file.txt user@remote_host:/path/to/destination - Copy files between hosts on a network.
  3. find (Find Files)

    • find /path -name filename - Search for files in a directory hierarchy.
  4. locate (Locate Files)

    • locate filename - Find the location of a file quickly.
  5. chmod (Change File Permissions)

    • chmod 755 file.sh - Change the permission of a file or directory.
  6. chown (Change File Owner)

    • chown user:group file.txt - Change the owner and group of a file.
  7. su (Switch User)

    • su - - Switch to the root user.
    • su - username - Switch to another user.
  8. usermod (Modify User)

    • usermod -aG groupname username - Add a user to a group.
  9. groupadd (Add Group)

    • groupadd groupname - Create a new group.
  10. groups (List Groups)

    • groups username - Display groups for a user.
  11. last (Last Logins)

    • last - Show a listing of last logged in users.
  12. hostname (Show or Set Hostname)

    • hostname - Show the system's hostname.
    • hostname new_hostname - Set the system's hostname.
  13. history (Command History)

    • history - Display the command history.
    • !n - Execute command number n from history.
  14. crontab (Cron Jobs)

    • crontab -e - Edit the cron jobs.
    • crontab -l - List the cron jobs.
  15. bg (Background Jobs)

    • bg - Resume a suspended job in the background.
  16. fg (Foreground Jobs)

    • fg - Bring a background job to the foreground.
  17. jobs (List Jobs)

    • jobs - List all jobs.
  18. at (Schedule Tasks)

    • at 10:00 - Schedule a command to run at 10:00 AM.
    • atq - List the pending jobs of users.
  19. basename (File Name)

    • basename /path/to/file - Display file name without the directory path.
  20. dirname (Directory Name)

    • dirname /path/to/file - Display the directory path of a file.
  21. file (File Type)

    • file filename - Determine the file type.
  22. watch (Execute/Watch Command)

    • watch -n 5 df -h - Execute a program periodically, showing output fullscreen.
  23. shutdown (Shutdown System)

    • shutdown -h now - Shutdown the system immediately.
    • shutdown -r now - Reboot the system immediately.

With these 75 essential Linux commands under your belt, you'll be well-equipped to navigate the command line, manage files and processes, customize your system, and supercharge your productivity on the Linux operating system.
Happy Coding!!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs