40 Most-Used Linux Commands You Should Know

Linux commands are powerful tools for interacting with and managing a Linux-based system. Here’s a list of 40 most-used Linux commands that are essential for beginners and advanced users alike.

File and Directory Management:

  1. ls: List the contents of a directory.
    bash
    ls -l # Lists files with detailed information
  2. cd: Change directory.
    bash
    cd /path/to/directory
  3. pwd: Print the current working directory.
    bash
    pwd
  4. mkdir: Create a new directory.
    bash
    mkdir new_directory
  5. rmdir: Remove an empty directory.
    bash
    rmdir empty_directory
  6. rm: Remove files or directories.
    bash
    rm file.txt # Remove a file rm -r folder # Remove a directory and its contents
  7. cp: Copy files or directories.
    bash
    cp file1.txt /path/to/destination cp -r directory1 /path/to/destination
  8. mv: Move or rename files or directories.
    bash
    mv file1.txt /path/to/destination mv oldname.txt newname.txt # Rename a file
  9. touch: Create an empty file or update the timestamp of an existing file.
    bash
    touch newfile.txt
  10. cat: Display the contents of a file.
    bash
    cat file.txt
  11. more: View file content one screen at a time.
    bash
    more file.txt
  12. less: View file content with more control (can scroll up and down).
    bash
    less file.txt
  13. head: View the first few lines of a file.
    bash
    head file.txt
  14. tail: View the last few lines of a file.
    bash
    tail file.txt tail -f file.txt # Follow file updates in real time (useful for logs)

System Information and Monitoring:

  1. uname: Display system information.
    bash
    uname -a # Show detailed system info
  2. df: Display disk space usage.
    bash
    df -h # Human-readable format
  3. du: Show disk usage of files and directories.
    bash
    du -sh # Summary for a directory
  4. top: Display real-time system processes and resource usage.
    bash
    top
  5. htop: A more user-friendly alternative to top (needs to be installed).
    bash
    htop
  6. free: Show memory usage.
    bash
    free -h # Human-readable format
  7. ps: Display currently running processes.
    bash
    ps aux # Show detailed process list
  8. kill: Terminate a process by its PID (Process ID).
    bash
    kill 1234 # Replace 1234 with the process PID
  9. uptime: Show how long the system has been running.
    bash
    uptime
  10. whoami: Display the current user.
    bash
    whoami
  11. uname: Show system kernel information.
    bash
    uname -r # Show kernel version

File Permissions and Ownership:

  1. chmod: Change file permissions.
    bash
    chmod 755 file.txt # Set read/write/execute permissions
  2. chown: Change file or directory ownership.
    bash
    chown user:group file.txt
  3. chgrp: Change group ownership of a file.
    bash
    chgrp groupname file.txt

Text Manipulation:

  1. grep: Search for patterns within files.
    bash
    grep “search_term” file.txt grep -r “search_term” /path/to/directory # Search recursively
  2. find: Search for files and directories.
    bash
    find /path/to/search -name “filename”
  3. awk: Process and analyze text files.
    bash
    awk ‘{print $1}’ file.txt # Print the first column
  4. sed: Stream editor for modifying files.
    bash
    sed ‘s/old/new/g’ file.txt # Replace all instances of ‘old’ with ‘new’

Networking:

  1. ping: Test network connectivity.
    bash
    ping google.com
  2. ifconfig: Display or configure network interfaces (older tool, replaced by ip).
    bash
    ifconfig
  3. ip: Show/manipulate routing, devices, and tunnels (modern replacement for ifconfig).
    bash
    ip addr show
  4. wget: Download files from the web.
    bash
    wget http://example.com/file.zip
  5. curl: Transfer data from or to a server (supports more protocols than wget).
    bash
    curl http://example.com
  6. netstat: Display network connections, routing tables, and interface statistics.
    bash
    netstat -tuln # Show listening ports
  7. ssh: Connect to a remote server via Secure Shell.
    bash
    ssh user@remote_server
  8. scp: Securely copy files between hosts over SSH.
    bash
    scp file.txt user@remote:/path/to/destination

Bonus:

  • history: View command history.
    bash
    history
  • alias: Create shortcuts for long commands.
    bash
    alias ll=’ls -l’

Mastering these commands can significantly improve your efficiency and control over a Linux system. Each command has multiple options and variations that extend their functionality even further!

Check Also

Gout Meal Planner: A Comprehensive Guide to Managing Gout Through Diet

3 Gout, a form of inflammatory arthritis, can significantly impact an individual’s quality of life. …