ToolStack
KO

Linux Commands Cheatsheet

Essential Linux commands for files, permissions, processes, and networking

Your data never leaves the browser — all processing is done locally 0 server requests

01

Files & Directories

  • ls -al

    List detailed directory contents including hidden files

  • pwd

    Print the current working directory path

  • cd /var/log

    Change directory (cd - returns to previous location)

  • mkdir -p a/b/c

    Create directories including all intermediate paths at once

  • rm -rf dir

    Force-delete a directory and all its contents ※ irreversible, double-check the path

  • cp -r src dst

    Copy a directory recursively including all subdirectories

  • mv old new

    Move or rename a file or directory

  • touch file.txt

    Create an empty file or update its modification timestamp

  • ln -s 원본 링크명

    Create a symbolic link (shortcut) to a file or directory

  • find . -name "*.log"

    Find files matching a name pattern under the current path

  • find . -mtime -1

    Find files modified within the last 24 hours

02

Viewing & Searching File Contents

  • cat file.txt

    Print the entire file contents at once

  • less file.txt

    Scroll through a long file (q to quit, / to search)

  • head -n 20 file.txt

    Print only the first 20 lines of a file

  • tail -f app.log

    Follow the end of a file in real time (useful for log monitoring)

  • grep -rn "검색어" .

    Search for text recursively and show file names and line numbers

  • grep -i "error" app.log

    Search without case sensitivity

  • wc -l file.txt

    Count the number of lines in a file

  • diff a.txt b.txt

    Compare two files and show their differences

  • sort access.log | uniq -c | sort -nr

    Count duplicate lines and sort from most to least frequent

03

Permissions & Ownership

  • chmod 755 script.sh

    Set permissions to rwxr-xr-x (owner: all; group/others: read+execute)

  • chmod +x script.sh

    Add execute permission to a file

  • chown user:group file

    Change the owner and group of a file

  • chown -R www-data:www-data /var/www

    Recursively change ownership of a directory and all its contents

  • sudo 명령

    Execute a command with administrator (root) privileges

  • su - username

    Switch to another user (- applies the login environment)

04

Processes & Services

  • ps aux | grep nginx

    Search running processes for a specific name

  • top

    Monitor CPU and memory usage in real time (htop is more user-friendly)

  • kill -9 PID

    Force-kill a process (try -15 for graceful shutdown first)

  • pkill -f "python app.py"

    Kill processes matching a command-line pattern

  • nohup ./run.sh &

    Keep a process running in the background after the terminal closes

  • jobs

    List background jobs in the current shell (fg %1 to bring one to foreground)

  • systemctl status nginx

    Check the status of a service

  • sudo systemctl restart nginx

    Restart a service (also: start/stop/reload)

  • sudo systemctl enable --now nginx

    Enable a service to start on boot and start it immediately

  • journalctl -u nginx -f

    Follow service logs in real time

05

Networking

  • ip a

    Show network interfaces and their IP addresses

  • ping -c 4 google.com

    Send exactly 4 pings to check connectivity

  • curl -I https://example.com

    Fetch only the HTTP response headers

  • wget https://example.com/file.zip

    Download a file from a URL

  • ss -tulpn

    Show open ports and the processes using them (replaces netstat)

  • ssh user@host -p 22

    Connect to a remote server via SSH

  • scp file.txt user@host:/path/

    Copy a file to a remote server over SSH

  • rsync -avz src/ user@host:/dst/

    Sync only changed files (efficient for large transfers)

06

Disk & Compression

  • df -h

    Show disk usage in human-readable units

  • du -sh */

    Summarize disk usage per directory in the current location

  • free -h

    Show memory usage in human-readable units

  • lsblk

    Display disk and partition layout as a tree

  • tar -czvf backup.tar.gz dir/

    Compress a directory into a tar.gz archive

  • tar -xzvf backup.tar.gz

    Extract a tar.gz archive

  • zip -r archive.zip dir/

    Compress a directory into a zip archive

  • unzip archive.zip

    Extract a zip archive

07

System Info & Packages

  • uname -a

    Print kernel version and system information

  • cat /etc/os-release

    Show the Linux distribution name and version

  • uptime

    Show system uptime and load averages

  • hostname -I

    Print only the server's IP address(es)

  • sudo apt update && sudo apt upgrade

    Refresh package lists and upgrade all packages (Debian/Ubuntu)

  • sudo apt install 패키지명

    Install a package (use dnf install on RHEL-based systems)

  • history | grep ssh

    Search through previously entered commands

Linux Commands: The Essential Toolkit

Linux commands follow a consistent pattern: command, options (flags starting with -), and arguments. Learning a core set of commands covering files, permissions, processes, and networking covers the vast majority of everyday tasks.

For file operations, master ls, cd, cp, mv, rm, find, and grep. For process management, ps aux, kill, systemctl, and journalctl cover most scenarios. For networking, ip a, ss -tulpn, and curl handle typical diagnostics.

⚠ Commands like rm -rf, chmod -R 777, and sudo operations are irreversible or can affect system security. Always verify the target path or scope before running them.

FAQ

How do I list all files including hidden ones?
Use ls -al. The -a flag shows hidden files (those starting with a dot) and -l shows the long format with permissions, owner, size, and modification date.
How do I find and kill a process using a specific port?
Run ss -tulpn | grep :PORT to find the PID, then kill -15 PID for a graceful shutdown or kill -9 PID to force kill. Always try -15 first.
What is the difference between rm -rf and rmdir?
rmdir only removes empty directories. rm -rf removes a directory and everything inside it without prompting. Always double-check your path before running rm -rf — it is irreversible.

Related Tools