⚡
usefultools.dev
🐧

Linux Commands Cheatsheet

NEW

Linux commands cheatsheet for the terminal: files, grep, find, permissions, processes, disk, network, tar, users and apt or dnf. Searchable with one-click copy.

Runs 100% in your browser — your input is never uploaded or stored on our servers.

105 entries in 12 sections

Navigation

  • pwd

    Print the current directory.

  • ls -lah

    List files with details, hidden files and human-readable sizes.

  • cd <dir>

    Change directory.

  • cd ~

    Go to your home directory.

  • cd -

    Go back to the previous directory.

  • cd ..

    Go up one directory.

Files & folders

  • touch <file>

    Create an empty file or update its modified time.

  • mkdir -p a/b/c

    Create a folder and any missing parent folders.

  • cp <src> <dest>

    Copy a file.

  • cp -r <dir> <dest>

    Copy a folder with its contents.

  • mv <src> <dest>

    Move or rename a file or folder.

  • rm <file>

    Delete a file.

  • rm -r <dir>

    Delete a folder and everything in it. There is no trash, so double-check the path.

  • ln -s <target> <link>

    Create a symbolic link.

  • file <name>

    Show what type of file something is.

View & search

  • cat <file>

    Print a file.

  • less <file>

    Page through a file (q to quit, / to search).

  • head -n 20 <file>

    Show the first 20 lines.

  • tail -n 20 <file>

    Show the last 20 lines.

  • tail -f <file>

    Follow a file as new lines are added, handy for logs.

  • wc -l <file>

    Count lines in a file.

  • grep "text" <file>

    Print lines that contain text.

  • grep -rn "text" .

    Search recursively and show line numbers.

  • grep -i "text" <file>

    Search ignoring case.

  • find . -name "*.log"

    Find files by name under the current folder.

  • find . -type f -mtime -1

    Find files modified in the last 24 hours.

  • awk '{print $1}' <file>

    Print the first column of each line.

  • sed 's/old/new/g' <file>

    Replace text and print the result (the file is not changed).

  • sed -i 's/old/new/g' <file>

    Replace text in the file itself (GNU sed).

  • sort <file> | uniq -c

    Count how often each distinct line appears.

Permissions

Numbers: r=4, w=2, x=1, added per owner, group, others.

  • chmod 644 <file>

    Owner can read and write, everyone else can only read.

  • chmod 755 <file>

    Owner can read, write and run; others can read and run.

  • chmod +x <file>

    Make a file executable.

  • chmod u+rw,go-w <file>

    Symbolic form: add read/write for owner, remove write for group and others.

  • chown user:group <file>

    Change the owner and group of a file.

  • chown -R user:group <dir>

    Change owner and group recursively.

  • ls -l

    Show permissions as strings like -rwxr-xr-x.

Processes

  • ps aux

    List all running processes.

  • ps aux | grep <name>

    Find a process by name.

  • top

    Live view of processes and resource use.

  • htop

    Friendlier live process viewer (often needs to be installed).

  • kill <pid>

    Ask a process to stop (sends SIGTERM).

  • kill -9 <pid>

    Force a process to stop (SIGKILL). Use only if a normal kill fails.

  • pkill <name>

    Stop processes by name.

  • command &

    Run a command in the background.

  • jobs

    List background jobs of the current shell.

  • nohup <command> &

    Keep a command running after you close the terminal.

Disk

  • df -h

    Show free and used space for each mounted disk.

  • du -sh <dir>

    Show the total size of a folder.

  • du -sh * | sort -h

    Size of each item here, sorted from smallest to largest.

  • lsblk

    List disks and partitions.

  • mount

    Show mounted file systems.

  • free -h

    Show used and free memory.

Network

  • ping -c 4 <host>

    Send 4 echo requests to check a host is reachable.

  • curl -I <url>

    Fetch only the response headers of a URL.

  • curl -O <url>

    Download a file and keep its name.

  • wget <url>

    Download a file.

  • ip addr

    Show network interfaces and IP addresses.

  • ss -tulpn

    List listening TCP and UDP ports with the owning process (may need sudo).

  • dig <domain>

    Look up DNS records for a domain.

  • traceroute <host>

    Show the route packets take to a host.

  • ssh user@host

    Open a secure shell on a remote machine.

  • scp <file> user@host:/path

    Copy a file to a remote machine over SSH.

Archive & compress

  • tar -czf archive.tar.gz <dir>

    Create a gzip-compressed tar archive.

  • tar -xzf archive.tar.gz

    Extract a .tar.gz archive here.

  • tar -xzf archive.tar.gz -C <dir>

    Extract into a specific folder.

  • tar -tf archive.tar.gz

    List the contents of an archive without extracting.

  • zip -r archive.zip <dir>

    Create a zip file from a folder.

  • unzip archive.zip

    Extract a zip file.

  • gzip <file>

    Compress a file to file.gz (the original is replaced).

Users & sudo

  • whoami

    Print your user name.

  • id

    Show your user id and groups.

  • sudo <command>

    Run a command as the administrator (root).

  • su - <user>

    Switch to another user with their environment.

  • sudo adduser <name>

    Create a user (Debian and Ubuntu).

  • sudo usermod -aG <group> <user>

    Add a user to a group without removing existing groups.

  • passwd

    Change your password.

System info

  • uname -a

    Show kernel and system information.

  • cat /etc/os-release

    Show the Linux distribution name and version.

  • uptime

    Show how long the system has been running and the load.

  • date

    Print the current date and time.

  • lscpu

    Show CPU details.

  • env

    List environment variables.

  • history

    List commands you ran before.

  • man <command>

    Open the manual page of a command.

Package managers

  • sudo apt update

    Refresh the package list (Debian, Ubuntu).

  • sudo apt upgrade

    Install available updates (Debian, Ubuntu).

  • sudo apt install <package>

    Install a package with apt.

  • sudo apt remove <package>

    Remove a package with apt.

  • apt search <term>

    Search packages with apt.

  • sudo dnf install <package>

    Install a package with dnf (Fedora, RHEL, Rocky, Alma).

  • sudo dnf remove <package>

    Remove a package with dnf.

  • sudo dnf upgrade

    Update all packages with dnf.

  • dnf search <term>

    Search packages with dnf.

Pipes & redirection

  • cmd1 | cmd2

    Send the output of cmd1 into cmd2.

  • cmd > file

    Write output to a file, replacing it.

  • cmd >> file

    Append output to a file.

  • cmd < file

    Read input from a file.

  • cmd 2> errors.txt

    Write only error messages to a file.

  • cmd > out.txt 2>&1

    Write both normal output and errors to one file.

  • cmd > /dev/null 2>&1

    Throw away all output.

  • cmd1 && cmd2

    Run cmd2 only if cmd1 succeeded.

  • cmd1 || cmd2

    Run cmd2 only if cmd1 failed.

  • cmd | tee file

    Show output and save it to a file at the same time.

  • xargs

    Turn input lines into arguments, e.g. find . -name "*.tmp" | xargs rm.

⚡

Quick Examples

Typical inputs and the results this tool produces.

Logs
Follow a log file live
tail -f <file>
Permissions
Make a file executable
chmod +x <file>
Disk
Folder sizes, smallest first
du -sh * | sort -h
Archive
Create a gzip tar archive
tar -czf archive.tar.gz <dir>
📖

Overview

The Linux command line is powerful, but the right flags are easy to forget. This Linux commands cheatsheet lists the everyday commands for navigation, files, viewing and searching text with grep, find, awk and sed, permissions, processes, disk, network, archives, users and system information.

It also covers the apt and dnf package managers and the pipes and redirection operators that let you chain commands together. Commands that delete data, such as rm -r and kill -9, are described plainly so you know what they do before you run them.

Use the filter to narrow the list, then copy a command and replace placeholders like <file>. Everything runs in your browser and nothing you type is sent anywhere.

Why use this tool?

  • Recall the right flags in seconds
  • Covers files, network, disk and processes
  • apt and dnf side by side
  • Plain explanations, no jargon
  • Copy any command with one click
⭐

Features

📂

Files and navigation

ls, cd, cp, mv, rm, ln and mkdir -p with common options.

🔎

Search and text

grep, find, awk, sed, sort and uniq for working with output.

🔐

Permissions

chmod numbers and symbolic forms, plus chown.

🌐

Network tools

curl, wget, ip, ss, dig, ssh and scp.

📦

apt and dnf

Install, remove, update and search packages on both families.

🔗

Pipes and redirection

Operators like |, >, >>, 2>&1, && and tee.

🛠️

How to Use

1

Choose a section

Scroll to Files, Processes, Network or the topic you need.

2

Or filter

Type a word such as "port" or "tar" in the "Filter this cheatsheet" box.

3

Read what it does

Check the one-line description, especially for commands that delete data.

4

Copy and adapt

Press Copy, paste into your terminal and replace placeholders like <file>.

🤔

Frequently Asked Questions