Online Linux Terminal Logo
OnlineLinuxTerminal
Developer & Sysadmin Reference Guide

The Ultimate Linux Command Cheat Sheet

A curated, high-density reference guide covering 100+ essential Linux commands, chmod octal permission matrices, grep regex patterns, and bash shortcuts. Click "Run in Sandbox ⚡" to test any command instantly in browser.

Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

#1. Navigation & Directory Traversal

Essential commands for moving through the Linux Filesystem Hierarchy.

pwd

Print current working directory absolute path

ls -la

List all files including hidden dotfiles in detailed format

$ ls -la /var/logRun in Sandbox ⚡
cd ..

Navigate up one parent directory level

cd ~

Jump directly to user home directory

tree -L 2

Display directory structure as a visual tree up to 2 levels

which <app>

Locate executable binary path in system PATH

$ which bashRun in Sandbox ⚡

#2. File & Directory Operations

Creating, copying, moving, viewing, and deleting files and folders safely.

touch <file>

Create empty file or update timestamp

$ touch script.shRun in Sandbox ⚡
mkdir -p <dir>

Create parent and sub-directories in a single command

$ mkdir -p /home/user/projects/webRun in Sandbox ⚡
cp -r <src> <dest>

Copy directory recursively with all subfolders and contents

$ cp -r /home/user/projects /tmp/backupRun in Sandbox ⚡
mv <old> <new>

Move or rename files and directories

$ mv old_name.txt new_name.txtRun in Sandbox ⚡
rm -rf <dir>

Forcefully and recursively remove directory (use with extreme care)

$ rm -rf /tmp/test_dirRun in Sandbox ⚡
cat <file>

Concatenate and print file contents to terminal stdout

$ cat /var/log/syslogRun in Sandbox ⚡
head -n 20 <file>

Output first 20 lines of a file

$ head -n 20 /var/log/syslogRun in Sandbox ⚡
tail -n 20 -f <file>

Output last 20 lines and follow live file growth

$ tail -n 20 /var/log/auth.logRun in Sandbox ⚡
wc -l <file>

Count total number of lines in a file

$ wc -l /var/log/syslogRun in Sandbox ⚡

#3. Text Searching & Pattern Filtering

High-performance text extraction, regex filtering, and stream processing.

grep -i 'pattern' <file>

Case-insensitive search for string pattern in file

$ grep -i 'error' /var/log/syslogRun in Sandbox ⚡
grep -r -n 'pattern' .

Recursively search all files in current directory with line numbers

$ grep -r -n 'TODO' .Run in Sandbox ⚡
grep -v 'pattern' <file>

Invert match to display lines that do NOT contain pattern

$ grep -v '^#' /etc/hostsRun in Sandbox ⚡
find . -name '*.log'

Recursively locate files by wildcard filename pattern

$ find /var/log -name '*.log'Run in Sandbox ⚡
find . -type f -size +10M

Find all regular files larger than 10 Megabytes

$ find . -type f -size +10MRun in Sandbox ⚡
sed 's/old/new/g' <file>

Stream editor search and replace all instances of string

$ sed 's/localhost/127.0.0.1/g' /etc/hostsRun in Sandbox ⚡
awk '{print $1, $3}' <file>

Extract and print specific space-delimited columns

$ awk '{print $1, $3}' /var/log/auth.logRun in Sandbox ⚡

#4. Permissions & Ownership Management

Controlling POSIX file security, read/write/execute bits, and user ownership.

chmod 755 <script>

Owner: Read/Write/Execute (7); Group & Others: Read/Execute (5)

$ chmod 755 deploy.shRun in Sandbox ⚡
chmod 644 <file>

Owner: Read/Write (6); Group & Others: Read-Only (4) - Standard file mode

$ chmod 644 config.txtRun in Sandbox ⚡
chmod 600 <key>

Owner: Read/Write (6); Others: No access (0) - Required for SSH private keys

$ chmod 600 id_rsaRun in Sandbox ⚡
chmod +x <file>

Add executable permission to current user

$ chmod +x run.shRun in Sandbox ⚡
chown user:group <file>

Change owner user and group of file or directory

$ chown user:user deploy.shRun in Sandbox ⚡
chown -R user:group <dir>

Recursively update ownership across entire directory tree

$ chown -R user:user /home/user/projectsRun in Sandbox ⚡

#5. System Monitoring, Memory & Processes

Inspecting live CPU utilization, memory allocations, running processes, and terminating jobs.

top

Interactive real-time process manager and system metrics

htop

Enhanced colorized process viewer with scrollable thread tree

ps aux

Snapshot of all active processes running on the operating system

ps aux | grep nginx

Find specific running process ID by name

$ ps aux | grep bashRun in Sandbox ⚡
kill -9 <PID>

Forcefully terminate process by its Process ID

$ kill -9 1234Run in Sandbox ⚡
free -h

Display total, used, and available RAM and Swap in human-readable GB/MB

uname -a

Print Linux kernel version, architecture, and hostname

uptime

Show how long the system has been running and load averages

#6. Disk Space & Storage Inspection

Analyzing filesystem capacity, partition usage, and directory size footprints.

df -h

Show disk space usage of all mounted filesystems in human-readable format

du -sh *

Summarize total disk size of each folder in current working directory

du -h --max-depth=1 /var

Inspect directory sizes exactly 1 level deep

$ du -h --max-depth=1 /varRun in Sandbox ⚡

#7. Networking, Connectivity & Downloads

Transferring data over HTTP/HTTPS, testing latency, and checking open sockets.

curl -I <url>

Fetch only HTTP response headers without body

$ curl -I https://onlinelinuxterminal.comRun in Sandbox ⚡
curl -O <url>

Download remote file and save under its original filename

$ curl -O https://example.com/file.tar.gzRun in Sandbox ⚡
wget <url>

Download file from web server in background

$ wget https://example.com/data.zipRun in Sandbox ⚡
ping -c 4 <host>

Send 4 ICMP ECHO_REQUEST packets to verify network reachability

$ ping -c 4 8.8.8.8Run in Sandbox ⚡
netstat -tuln

List all listening TCP and UDP network ports without resolving names

$ netstat -tulnRun in Sandbox ⚡

#8. Archiving, Tarballs & Compression

Bundling multiple files into tarballs and compressing archives with gzip.

tar -czvf archive.tar.gz /path

Create gzipped tarball archive of target directory

$ tar -czvf backup.tar.gz /home/user/projectsRun in Sandbox ⚡
tar -xzvf archive.tar.gz

Extract gzipped tarball archive into current directory

$ tar -xzvf backup.tar.gzRun in Sandbox ⚡
tar -tvf archive.tar.gz

List files inside tar archive without extracting

$ tar -tvf backup.tar.gzRun in Sandbox ⚡
gzip <file>

Compress file into .gz format and replace original

$ gzip server.logRun in Sandbox ⚡
gunzip <file.gz>

Decompress .gz file back to original uncompressed file

$ gunzip server.log.gzRun in Sandbox ⚡
Security & Permissions Matrix

Linux File Permissions & Chmod Octal Calculator

Linux permissions are divided into three user classes: User (Owner), Group, and Others. Each class receives permissions calculated by summing the binary octal values: Read (4), Write (2), and Execute (1).

Octal ModeSymbolic FormatOwner (User)GroupOthers (World)Common Use Case
777rwxrwxrwxRead/Write/ExecRead/Write/ExecRead/Write/ExecFull Public Access (Security Hazard in Production)
755rwxr-xr-xRead/Write/ExecRead/ExecRead/ExecStandard Executable Scripts & Public Web Directories
644rw-r--r--Read/WriteRead-OnlyRead-OnlyStandard File Permission (HTML, CSS, text documents)
600rw-------Read/WriteNoneNoneSensitive Files (SSH private keys, password files)
700rwx------Read/Write/ExecNoneNonePrivate Directories (e.g. ~/.ssh/ folder)

Essential Bash Shell Keyboard Shortcuts

Master terminal navigation and speed up your productivity using command-line hotkeys.

Ctrl + C

Send SIGINT to terminate the currently running foreground process.

Ctrl + L

Clear the terminal screen buffer (equivalent to running clear).

Ctrl + R

Reverse-i-search history buffer to search previously executed commands.

Ctrl + A / Ctrl + E

Jump cursor directly to beginning (A) or end (E) of the current command line.

Ctrl + U / Ctrl + K

Cut text from cursor to the start (U) or from cursor to the end (K) of line.

Tab (or Tab × 2)

Autocomplete command, argument, or directory path name automatically.

Linux Filesystem Hierarchy Standard (FHS) Quick Map

Understanding what resides inside root system directories is crucial for systems administration and troubleshooting.

/etc

System-wide configuration files (e.g. /etc/hosts, /etc/passwd, /etc/ssh).

/var/log

System and application log files (e.g. /var/log/syslog, /var/log/auth.log).

/home

User personal home directories containing documents, project files, and personal configs.

/tmp

Temporary files created by system and applications, cleared automatically on reboot.

/bin & /usr/bin

Essential user command binaries (e.g. ls, grep, cat, curl).

/opt

Optional third-party standalone software packages and custom server installations.

Ready to Put These Commands to Practice?

Launch our zero-lag browser terminal sandbox and test any of the 100+ commands above with zero installation.