Linux Commands Cheat Sheet
Searchable quick reference for essential Linux commands. Find processes by port, configure file permissions (chmod), search logs with grep, and inspect system resources with one-click copy.
Grants owner read, write, and execute permissions (rwx); group and others can read and execute (r-x).
chmod 755 deploy.shGrants owner read and write (rw-); group and others have read-only access (r--). Common for web and config files.
chmod 644 config.jsonGrants read and write access strictly to the current owner. Required by SSH clients to prevent key exposure.
chmod 600 ~/.ssh/id_rsaRestricts all access to the directory exclusively to the owner. Required for ~/.ssh folders.
chmod 700 ~/.sshRecursively sets both owner and group to 'www-data' across all files and child directories.
chown -R www-data:www-data /var/www/htmlPrints octal permission numbers (e.g. 755, 644) alongside each filename in the current directory.
stat -c '%a %n' *Recursively (-r) searches directory './src' for whole-word (-w) pattern with line numbers (-n).
grep -rnw './src' -e 'API_SECRET'Locates all regular files in current directory and subdirectories modified within the last 1 day.
find . -type f -mtime -1Searches for all files ending with .log and immediately removes them.
find . -name '*.log' -type f -deleteCreates a gzip-compressed tarball (-c create, -z gzip, -v verbose, -f filename).
tar -czvf archive.tar.gz /path/to/folderExtracts gzip archive contents into the specified destination folder (-C).
tar -xzvf archive.tar.gz -C ./target_folderStreams live incoming log lines in real-time as they are written to disk.
tail -f /var/log/nginx/access.logEmpties the file instantly without unlinking or restarting the running process holding the file handle.
: > /var/log/application.logDisplays the PID, process name, and user currently binding TCP port 3000.
lsof -i :3000Measures human-readable directory sizes at root and sorts them in ascending order.
du -sh /* 2>/dev/null | sort -hDisplays total, used, free, shared, and available memory in human-readable units (GiB, MiB).
free -hShows file system disk capacity, percent used, and available space on all mounted drives.
df -hPrints operating system kernel name, release version, and machine hardware architecture (e.g. x86_64, aarch64).
uname -srmLists the process ID (PID) and full command line for all running processes matching 'node'.
pgrep -fl nodeSends SIGTERM (15) to allow graceful shutdown, falling back to SIGKILL (9) if unresponsive.
kill -15 <PID> || kill -9 <PID>Inspects service execution state, active uptime, memory consumption, and recent log snippets.
systemctl status nginx.serviceStreams live stdout/stderr logs from a systemd unit starting with the last 100 lines.
journalctl -u my-app.service -f -n 100Enables service auto-start on server reboot and starts the service immediately.
sudo systemctl enable --now redis-serverPerforms HEAD HTTP request printing TLS handshake, HTTP status codes, and server response headers.
curl -Iv https://api.example.com/healthModern replacement for netstat. Displays all listening ports with associated PIDs and protocol names.
ss -tulpnQueries DNS server and returns only resolved IPv4 address without diagnostic headers.
dig +short A api.example.comUses Netcat to test if PostgreSQL port 5432 is open and accepting socket connections.
nc -zv 192.168.1.50 5432Emits a 24-character random high-entropy token using cryptographic pseudorandom bytes.
openssl rand -base64 24Executes script disconnected from terminal SIGHUP signals, redirecting all output to file.
nohup ./worker.sh > worker.log 2>&1 &Chmod Permissions Calculator
Calculate octal numbers (755, 644) and symbolic notation visually.
Open Chmod ToolcURL to Code Converter
Convert terminal cURL requests into JavaScript fetch, Axios, Python, and Go.
Open cURL ConverterToken & Secret Generator
Generate high-entropy random tokens, API keys, and NanoIDs client-side.
Open Token GeneratorFrequently Asked Questions
How do I check which process is using a specific port in Linux?
Run 'lsof -i :<port>' or 'ss -tulpn | grep :<port>'. The output will display the Process ID (PID) and process name. To stop it, run 'kill -9 <PID>'.
What is the difference between chmod 755 and chmod 644?
Chmod 755 (rwxr-xr-x) grants the owner full read, write, and execute permissions, while group members and others can only read and execute. It is standard for directories and executable scripts. Chmod 644 (rw-r--r--) grants the owner read and write access, with read-only access for others, which is standard for static web files and documents.
How do I search for a specific string inside all files recursively?
Run 'grep -rnw "./path" -e "search_string"'. The '-r' flag enables recursive traversal, '-n' outputs matching line numbers, and '-w' matches whole words.
How can I safely run a command in the background after logging out of SSH?
Use 'nohup <command> > output.log 2>&1 &' or run it inside a terminal multiplexer like 'tmux' or 'screen'. 'nohup' intercepts SIGHUP signals sent when closing your SSH session.