Skip to main content

Common Linux Command-Line Tools (Portable Across Distros) 🧰

Below is a practical, cross‑distro “core toolbox” of commands you’ll use constantly. I’ll group them by job, give a plain meaning, and include examples you can try.

Notes:

  • Examples assume a typical Bash-like shell.
  • Many commands have lots of options—this is the “most useful baseline.”

1) Getting oriented (where am I? what’s here?)

pwd — print working directory

Shows your current directory.

pwd
# /home/alex/projects

ls — list directory contents

ls
ls -l        # long listing (permissions, owner, size, time)
ls -a        # include hidden files (dotfiles)
ls -lah      # long + all + human-readable sizes

cd — change directory

cd /etc
cd ..        # up one directory
cd ~         # home directory
cd -         # previous directory

tree — show directory tree (often needs installing)

tree
tree -L 2    # limit depth

2) Creating, moving, copying, deleting (file operations)

touch — create an empty file / update timestamp

touch notes.txt

mkdir — make directories

mkdir logs
mkdir -p a/b/c   # create parents as needed

cp — copy files/directories

cp a.txt b.txt
cp -r src/ backup-src/     # copy directory recursively
cp -a src/ backup-src/     # archive mode: preserve permissions/times (very common)

mv — move/rename files/directories

mv oldname.txt newname.txt
mv file.txt /tmp/

rm — remove files/directories (destructive)

rm file.txt
rm -r folder/       # recursive delete directory
rm -rf folder/      # force + recursive (use extreme caution)
ln -s /var/www/site/current/public public   # symlink

3) Reading files quickly

cat — print file contents

Good for small files; for big ones prefer less.

cat /etc/hostname

less — page through text interactively

Keys: q quit, /text search, n next match.

less /var/log/syslog

head / tail — show start/end of file

head -n 20 access.log
tail -n 50 error.log
tail -f error.log     # follow appended log lines (real-time)

nl — show file with line numbers

nl -ba nginx.conf

4) Help & discovery

man — manual pages

man ls
man -k network    # search man page descriptions (keyword)

--help — quick built-in help (common convention)

grep --help

which / type — where a command comes from

which python
type ls            # also tells if it’s an alias/function/builtin

5) Searching text (the everyday “find inside files” tools)

grep — search text for patterns

grep "listen" nginx.conf
grep -R "DB_HOST" .           # recursive search
grep -n "error" app.log        # include line numbers
grep -i "warning" app.log      # case-insensitive

sed — stream editor (common for simple substitutions)

sed 's/http:/https:/g' urls.txt
sed -n '1,20p' file.txt        # print specific lines

awk — field/column processing

awk '{print $1, $9}' access.log   # e.g., IP and status code columns (depends on log format)

6) Counting, sorting, unique-ing (text pipelines)

wc — count lines/words/bytes

wc -l access.log     # number of lines

sort — sort lines

sort names.txt
sort -n numbers.txt  # numeric sort

uniq — collapse adjacent duplicates (usually used after sort)

sort users.txt | uniq
sort users.txt | uniq -c | sort -nr   # frequency count, descending

cut — extract columns/fields

cut -d: -f1 /etc/passwd     # usernames (field 1, delimiter ':')

tr — translate/delete characters

tr '[:lower:]' '[:upper:]' < file.txt

7) Composing commands (pipes, redirection, and “do this to each line”)

| (pipe) — send output of one command into another

ps aux | grep nginx

Redirection: >, >>, 2>, &>

echo "hello" > out.txt      # overwrite
echo "more"  >> out.txt     # append
cmd 2> err.txt              # stderr to file
cmd &> all.txt              # stdout+stderr to file (bash)

tee — write output to file and keep showing it

echo "config" | tee -a notes.txt

xargs — turn input lines into arguments (batch operations)

find . -name "*.log" | xargs rm -f
# safer form when filenames may contain spaces:
find . -name "*.log" -print0 | xargs -0 rm -f

8) Finding files

find — search by name/type/time/size (very common)

find . -name "*.conf"
find /var/log -type f -mtime -7     # files modified in last 7 days
find . -type f -size +100M          # larger than 100MB

locate — fast filename search via database (needs updated index)

locate nginx.conf

9) Permissions & ownership (you’ll use these constantly on servers)

chmod — change permissions

chmod 644 file.txt    # rw-r--r--
chmod 755 script.sh   # rwxr-xr-x
chmod -R 755 public/  # recursively (use carefully)

chown / chgrp — change owner / group

chown www-data:www-data -R /var/www/site
chgrp developers project/

umask — default permission mask for new files

umask

10) Processes & system state (baseline diagnostics)

ps — show processes

ps aux
ps aux | grep php-fpm

top / htop — live process viewer (htop may need install)

top
htop

kill / pkill — send signals to processes

kill 1234
pkill nginx
kill -TERM 1234   # graceful request
kill -KILL 1234   # force (last resort)

systemctl — manage services (systemd systems)

systemctl status nginx
systemctl restart nginx
systemctl enable nginx   # start on boot

journalctl — systemd logs

journalctl -u nginx
journalctl -u nginx -f       # follow
journalctl -b                # logs since boot

11) Networking essentials (developer/server workflow)

ip — network interfaces and routes

ip a          # addresses
ip r          # routes

ss — see listening ports and connections

ss -tulpn     # TCP/UDP listening + process names

ping — basic reachability test

ping -c 4 example.com

curl — make HTTP requests (huge for web debugging)

curl https://example.com
curl -I https://example.com          # headers only
curl -v https://example.com          # verbose (TLS + connection details)

dig / nslookup — DNS queries (often dig)

dig example.com A
dig example.com +short

12) Archives & compression (moving code, backups)

tar — create/extract tar archives (the Linux standard)

tar -czf site.tar.gz site/     # create gzip-compressed archive
tar -xzf site.tar.gz           # extract

gzip / xz — compression tools (often used via tar)

gzip large.log
xz -T0 bigfile     # stronger compression; -T0 uses all cores

zip / unzip — common for cross-platform bundles

zip -r project.zip project/
unzip project.zip

13) Remote access & file transfer (core server skills)

ssh — remote shell

ssh user@server.example.com
ssh -i ~/.ssh/id_ed25519 user@server

scp — copy over SSH (simple, not always the best)

scp file.txt user@server:/tmp/
scp -r site/ user@server:/var/www/

sftp — interactive file transfer over SSH

sftp user@server
# then: put/get, ls, cd, etc.

14) Privilege escalation (admin work)

sudo — run as root (or another user)

sudo apt update
sudo systemctl restart nginx

15) “Environment” and shell basics you’ll constantly touch

echo — print text / variables

echo "Hello"
echo "$HOME"

env / printenv — show environment variables

env
printenv PATH

export — set environment variable for this shell session

export NODE_ENV=production

history — show command history

history | tail

If you want, I can turn this into a printable “cheat sheet”

Tell me your target context: web server admin (WordPress), Node/React dev, or general Linux—and whether you’re on Debian-like or RHEL-like most often.