Dev Tool

Linux Terminal Commands — Quick Reference

Essential Bash commands for file ops, navigation, search, processes, networking, and permissions

AllOmnitools Editorial Team
File Operations
File ls — list directory contents
ls # current directory
ls -la # all files with details
ls -lh # human-readable sizes
ls *.txt # pattern match
-a shows hidden files. -l long format. -h with -l for readable sizes.
File cp — copy files/directories
cp file.txt dest/ # copy file
cp -r dir/ dest/ # recursive copy directory
cp -i file.txt bak/ # prompt before overwrite
-r for directories. -v verbose. -i interactive (safe). -p preserve attributes.
File mv — move or rename
mv file.txt newname.txt # rename
mv file.txt /path/dir/ # move
mv -i *.txt backup/ # interactive bulk
Overwrites by default. Use -i (interactive) or -n (no-clobber) to prevent.
File rm — remove files/directories
rm file.txt # remove file
rm -r dir/ # remove directory recursively
rm -rf dir/ # force, no prompts (DANGEROUS)
rm -i *.log # prompt before each removal
rm -rf is irreversible. Triple-check path. Use trash-cli for safer deletion.

Directory Ops

mkdir — make directory
mkdir newdir
mkdir -p a/b/c # create nested
rmdir — remove empty dir
rmdir emptydir
rmdir -p a/b # remove parents if empty
File touch — create empty file or update timestamp
touch newfile.txt # create empty
touch file1 file2 file3 # multiple files
Also used to update file timestamps without modifying content. -t option sets explicit timestamp.

View File Contents

cat — concatenate/print file
cat file.txt
cat f1 f2 > combined.txt
less — scrollable viewer (preferred)
less longfile.log
j/k scroll, q quit, /search
more — basic paginator
more file.txt
space next, Enter line
Use less for large files. cat is best for small files or piping.
Navigation

Directory Navigation

pwd — print working dir
pwd
cd — change directory
cd /path/to/dir
cd .. # parent
cd ~ # home
cd - # previous dir
Search & Find
Search grep — search text in files
grep "pattern" file.txt
grep -r "TODO" . # recursive in current dir
grep -i "error" log.txt # case-insensitive
grep -n "fn" file.js # show line numbers
grep -v "debug" code.js # invert: exclude lines
-r recursive. -i case-insensitive. -n line numbers. -v invert match (exclude).
Search find — search for files/dirs
find . -name "*.txt" # by name pattern
find /var/log -type f # only files
find . -size +10M # larger than 10 MB
find . -mtime -7 # modified in last 7 days
find . -exec rm {} \; # execute on each result
-name (case-sensitive), -iname (case-insensitive). -exec runs command on matches. {} is placeholder.

Locate Binaries

which — path of executable
which node
which -a python # all matches
whereis — binary, source, man loc
whereis gcc
Process Management

View Processes

ps — snapshot of processes
ps aux # all processes
ps -ef | grep node # filter
top — live process viewer
top
q to quit, M sort by mem
htop — enhanced top
htop
(install: apt/brew)

Kill Processes

kill — send signal by PID
kill 1234 # SIGTERM
kill -9 1234 # SIGKILL (force)
pkill — by process name
pkill -f "node app.js"
killall — kill by exact name
killall chrome
kill -9 (SIGKILL) does not allow graceful shutdown. Try kill (SIGTERM) first.
Process jobs / bg / fg — background tasks
command & # start in background
jobs # list background jobs
fg %1 # bring job 1 to foreground
bg %1 # resume job in background
Use Ctrl+Z to suspend current foreground job, then bg or fg to resume.
Permissions
Perm chmod — change file permissions
chmod +x script.sh # add execute
chmod 755 app.js # rwxr-xr-x
chmod 644 config.json # rw-r--r--
chmod -R 755 dir/ # recursive
Numeric: read=4, write=2, exec=1. Sum per class (user/group/others).
755 = rwx (7) r-x (5) r-x (5)
644 = rw- (6) r-- (4) r-- (4)
Perm chown — change file owner/group
chown alice file.txt # change owner
chown alice:staff file.txt # owner and group
chown -R www-data:www-data /var/www # recursive
Requires sudo on most systems. Incorrect ownership can break services.
Networking

Download / HTTP

curl — transfer data (CLI browser)
curl -O https://url/file.zip
curl -I https://site.com # headers only
wget — download file
wget URL
wget -c file.zip # continue partial

Network Diagnostics

ping — test connectivity
ping google.com
ping -c 4 host # count=4
traceroute — path to host
traceroute google.com
nslookup — DNS lookup
nslookup example.com
Net ss / netstat — socket statistics
ss -tulpn # listening ports
netstat -tulpn # traditional (older)
ss is modern replacement for netstat on Linux. -t TCP, -u UDP, -l listening, -p process.
System Info

Disk Usage

df — disk free (filesystem)
df -h # human-readable
df -i # inode usage
du — disk usage (directory)
du -sh dir/ # summary human-readable
du -h --max-depth=1 # per-subdir

Memory / System

free — memory usage
free -h
uname — system info
uname -a # all details
uname -r # kernel version
Compression & Archives
File tar — tape archive (bundles files)
tar -cvf archive.tar dir/ # create tar
tar -xvf archive.tar # extract
tar -czvf archive.tar.gz dir/ # create gzipped
tar -xzvf archive.tar.gz # extract gzipped
tar -tjvf archive.tar # list contents
Flags: -c create, -x extract, -v verbose, -f file, -z gzip, -j bzip2.
Order doesn't matter: tar -zcvf = tar -czvf.

Compress Single Files

gzip — compress file
gzip file.txt
gunzip file.txt.gz
zip — zip archive
zip -r out.zip dir/
unzip — extract zip
unzip out.zip
gzip compresses files in-place (replaces original with .gz). Use tar for directories.
Text Processing

Basic Text

echo — print to stdout
echo "text"
echo $PATH # variable
head — first N lines
head file.txt
head -n 20 # 20 lines
tail — last N lines
tail -f logfile # follow live
tail -n 50 # last 50 lines
Text wc — word/line/byte count
wc file.txt # lines words bytes
wc -l file.txt # line count only
wc -w file.txt # word count
ls -1 | wc -l # count files in dir

Sort & Unique

sort — sort lines
sort file.txt
sort -r # reverse
sort -n # numeric
uniq — remove duplicates
uniq sorted.txt
sort file | uniq -c # count per value
uniq only removes adjacent duplicates. Pipe through sort first for full deduplication.

Stream Editors

sed — stream editor
sed 's/old/new/g' file.txt
sed -i 's/foo/bar/g' file # in-place
awk — pattern scanning
awk '{print $1}' file
awk -F: '{print $1}' /etc/passwd
sed 's/old/new/' replaces first occurrence. g flag = global (all). -i edits file in-place.

Linux terminal commands — the ones you actually need

This covers the commands that come up in real development and server work. Not exhaustive — focused on what you'll run regularly on Linux servers, in Docker containers, or in a local terminal.

Files and navigation

  • ls -la — list all files including hidden, with permissions and sizes
  • cd - — go back to previous directory
  • find . -name "*.log" -mtime +7 — find log files older than 7 days
  • cp -r src/ dest/ — recursively copy directory
  • mv oldname newname — rename or move
  • rm -rf dirname/ — delete directory and contents (no confirmation, be careful)
  • du -sh */ — show disk usage of each directory in current folder

Searching text

  • grep -r "search term" ./ — search recursively in all files
  • grep -i "search" file.txt — case-insensitive search
  • grep -n "error" app.log — show line numbers
  • grep -v "debug" app.log — exclude lines matching pattern
  • cat file.txt | grep "error" | tail -50 — pipe: last 50 error lines

Processes and system

  • ps aux | grep node — find running Node processes
  • kill -9 <PID> — force kill a process by ID
  • lsof -i :3000 — find what's using port 3000
  • top or htop — live process monitor (htop is better if available)
  • df -h — disk space usage across mounted filesystems
  • free -h — RAM usage summary

Permissions

  • chmod 755 script.sh — owner can rwx, others can rx
  • chmod +x script.sh — make executable
  • chown user:group file — change file owner
  • sudo !! — re-run last command with sudo

Complete Developer Toolkit

Linux terminal commands are the backbone of server management, CI/CD pipelines, and development workflows. Pair this cheat sheet with our Git command cheat sheet — you'll use both constantly in any terminal session. Our cron generator builds the schedule expressions for Linux cron jobs, and our crontab descriptor decodes existing schedules you find in /etc/crontab or user crontabs. The regex tester is essential for grep, sed, and awk patterns — test your regex in the browser before running it against production log files.

For debugging server issues, our DNS lookup verifies domain resolution, our SSL expiry checker checks certificates, and our CORS error guide explains server configuration changes you'd make from the terminal. When your terminal scripts process JSON config files, our JSON formatter validates them before deployment. Our diff checker is a browser alternative to diff for comparing config files side by side. The Git error guide covers the git commands you'd run in the terminal when things go wrong. Our Python cheat sheet covers the Python scripts you commonly run from the Linux terminal.

FAQ

find / -name "filename.txt" 2>/dev/null searches from root, suppressing permission errors. For faster searches on indexed paths, use locate filename.txt (requires updatedb to be run first).