Linux Commands Cheat Sheet: Complete Reference Guide

    Linux Commands Cheat Sheet: Complete Reference Guide

    31/08/2025

    Linux Commands Cheat Sheet: Complete Reference Guide

    Introduction

    The Linux command line is a powerful tool for developers, system administrators, and power users. This cheat sheet provides a quick reference to the most essential Linux commands, organized by category.

    Related: Master Git Commands for version control and Docker Commands for containerization.

    File and Directory Management

    Commands for managing files and directories.

    CommandDescriptionExample
    lsLists files and directories in the current directory.ls -l
    pwdDisplays the present working directory.pwd
    cdChanges the current directory.cd /home/user/documents
    mkdirCreates a new directory.mkdir new_folder
    rmdirRemoves an empty directory.rmdir old_folder
    rmRemoves files or directories.rm file.txt or rm -r directory
    cpCopies files or directories.cp source.txt destination.txt
    mvMoves or renames files or directories.mv old_name.txt new_name.txt
    touchCreates an empty file or updates the timestamp of an existing file.touch new_file.txt
    fileDetermines the file type.file document.pdf
    lnCreates a link to a file.ln -s /path/to/original.txt /path/to/link.txt

    Archiving and Compression

    Commands for archiving and compressing files.

    CommandDescriptionExample
    zipCompresses files into a zip archive.zip archive.zip file1.txt file2.txt
    unzipExtracts files from a zip archive.unzip archive.zip
    tarCreates or extracts tar archives.tar -czvf archive.tar.gz /path/to/directory

    File Viewing and Editing

    Commands for viewing and editing files.

    CommandDescriptionExample
    nanoA simple, modeless text editor.nano filename.txt
    vi / vimA powerful, modal text editor.vim filename.txt
    catConcatenates and displays the content of files.cat file.txt
    headDisplays the beginning of a file.head -n 10 file.txt
    tailDisplays the end of a file.tail -f /var/log/syslog

    Text Processing and Searching

    Commands for processing and searching text.

    CommandDescriptionExample
    grepSearches for a pattern in a file.grep "error" /var/log/syslog
    sedA stream editor for filtering and transforming text.sed 's/old/new/g' file.txt
    awkA powerful pattern scanning and processing language.awk '{print $1}' file.txt
    sortSorts lines of text files.sort names.txt
    cutRemoves sections from each line of files.cut -d',' -f1 data.csv
    diffCompares two files line by line.diff file1.txt file2.txt
    teeReads from standard input and writes to standard output and files.`ls -l
    locateFinds files by name using a pre-built database.locate httpd.conf
    findSearches for files in a directory hierarchy.find /home -name "*.txt"

    User and Permission Management

    Commands for managing users and file permissions.

    CommandDescriptionExample
    sudoExecutes a command as another user (usually the superuser).sudo apt-get update
    suSwitches to another user account.su - username
    whoamiDisplays the current username.whoami
    chmodChanges the permissions of a file or directory.chmod 755 script.sh
    chownChanges the owner of a file or directory.chown user:group file.txt
    useraddCreates a new user.useradd newuser
    passwdChanges a user's password.passwd newuser
    userdelDeletes a user account.userdel olduser

    System Information and Monitoring

    Commands for monitoring system information.

    CommandDescriptionExample
    dfDisplays the amount of disk space available on the file system.df -h
    duEstimates file and directory space usage.du -sh /var/log
    topDisplays Linux processes.top
    htopAn interactive process viewer.htop
    psReports a snapshot of the current processes.ps aux
    unamePrints system information.uname -a
    hostnameShows or sets the system's host name.hostname
    historyDisplays the command history.history
    manDisplays the on-line manual pages.man ls

    Process and Service Management

    Commands for managing processes and services.

    CommandDescriptionExample
    timeMeasures the execution time of a program.time ls
    systemctlControls the systemd system and service manager.systemctl start apache2
    watchExecutes a program periodically, showing output fullscreen.watch -n 5 df -h
    jobsLists active jobs.jobs
    killSends a signal to a process.kill 12345
    shutdownShuts down or reboots the system.shutdown -h now

    Networking

    Commands for networking.

    CommandDescriptionExample
    pingSends ICMP ECHO_REQUEST to network hosts.ping google.com
    wgetA non-interactive network downloader.wget https://example.com/file.zip
    curlA tool to transfer data from or to a server.curl -O https://example.com/file.zip
    scpSecurely copies files between hosts on a network.scp user@remote:/file.txt .
    rsyncA fast, versatile, remote (and local) file-copying tool.rsync -avz /local/dir user@remote:/remote/dir
    ipShows or manipulates routing, devices, policy routing and tunnels.ip addr show
    netstatPrints network connections, routing tables, interface statistics, etc.netstat -tuln
    traceroutePrints the route packets trace to network host.traceroute google.com
    nslookupQueries Internet name servers interactively.nslookup google.com
    digA DNS lookup utility.dig google.com

    Package Management

    Commands for managing software packages.

    CommandDescriptionExample
    apt / apt-getPackage handler for Debian/Ubuntu based systems.sudo apt-get install nginx
    dnf / yumPackage manager for Fedora/RHEL based systems.sudo dnf install httpd

    Conclusion

    This cheat sheet covers a wide range of essential Linux commands. Mastering these commands will significantly improve your efficiency and effectiveness when working with Linux systems.

    Summarise

    Transform Your Learning

    Get instant AI-powered summaries of YouTube videos and websites. Save time while enhancing your learning experience.

    Instant video summaries
    Smart insights extraction
    Channel tracking