18 Most-Used Linux Commands You Should Know

Linux commands form the foundation of managing and interacting with Linux-based systems. Whether you're a beginner or an experienced user, these commands are essential for navigating, managing files, and performing system tasks efficiently. In this guide, we’ll explore 18 most-used Linux commands, breaking down their purpose and usage with examples.

1. ls – List Files and Directories

  • Description: Lists all files and directories in the current directory.
  • Example:
    ls
    ls -l   # Detailed list with permissions, size, and modification date

2. cd – Change Directory

  • Description: Navigates between directories.
  • Example:
    cd /home/user/documents  # Navigate to the 'documents' directory
    cd ..                    # Move up one directory level

3. mkdir – Create New Directory

  • Description: Creates one or more directories.
  • Example:
    mkdir my_folder
    mkdir -p parent/child   # Create parent and child directories

4. rm – Remove Files or Directories

  • Description: Deletes files or directories.
  • Example:
    rm file.txt             # Remove a single file
    rm -r folder_name       # Remove a directory and its contents

5. mv – Move or Rename Files

  • Description: Moves or renames files and directories.
  • Example:
    mv old_name.txt new_name.txt  # Rename a file
    mv file.txt /home/user/docs   # Move a file to another directory

6. chmod – Change File Permissions

  • Description: Modifies file or directory permissions.
  • Example:
    chmod 755 script.sh           # Assign read, write, and execute permissions
    chmod u+x script.sh           # Grant execute permission to the user

7. cp – Copy Files or Directories

  • Description: Copies files or directories.
  • Example:
    cp file.txt /backup/          # Copy a file to another directory
    cp -r folder_name /backup/    # Copy a folder and its contents

8. find – Search for Files

  • Description: Locates files and directories based on conditions.
  • Example:
    find /home -name "*.txt"      # Find all .txt files in /home directory

9. grep – Search for Patterns

  • Description: Searches for a specific pattern in files.
  • Example:
    grep "error" log.txt          # Search for "error" in log.txt
    grep -r "function" .          # Recursively search in the current directory

10. vi – Edit Files

  • Description: Opens the vi editor to modify files.
  • Example:
    vi file.txt
    

Tip: Use i to insert text and :wq to save and exit.

11. cat – Display File Contents

  • Description: Displays the content of a file.
  • Example:
    cat file.txt                 # Display the contents of a file

12. tar – Archive Files

  • Description: Creates or extracts tarball archive files.
  • Example:
    tar -cvf archive.tar folder/ # Create an archive
    tar -xvf archive.tar         # Extract an archive

13. ps – Display Process Information

  • Description: Displays the status of active processes.
  • Example:
    ps                          # List processes in the current shell
    ps aux                      # List all processes with details

14. kill – Terminate Processes

  • Description: Terminates a process by its ID.
  • Example:
    kill 1234                   # Terminate process with PID 1234

15. top – Monitor System Resources

  • Description: Displays real-time information about system processes and resource usage.
  • Example:
    top

16. ifconfig – Configure Network Interfaces

  • Description: Displays or configures network interfaces.
  • Example:
    ifconfig                    # Display network information
    

Note: Use ip addr as a modern alternative.

17. ping – Test Network Connectivity

  • Description: Sends ICMP packets to test connectivity.
  • Example:
    ping google.com             # Check connectivity to Google's servers

18. du – Check Disk Usage

  • Description: Estimates file or directory space usage.
  • Example:
    du -h                       # Display file sizes in a human-readable format
    du -sh folder/              # Summarize folder size

Conclusion

Mastering these 18 essential Linux commands equips you to navigate and manage Linux systems efficiently. Whether you’re a beginner or a seasoned developer, these commands are foundational for working in Linux environments.

Which of these commands do you use the most? Let us know in the comments!

Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare