Identity & help
| Command |
Purpose |
whoami |
Current username |
id |
UID, GID, groups |
groups |
Group names |
hostname |
Machine name |
uname -a |
Kernel / system summary |
date / cal |
Date and calendar |
man cmd |
Manual page |
man -k keyword |
Search man descriptions |
clear |
Clear terminal |
Navigation & listing
| Command |
Purpose |
pwd |
Print working directory |
cd / cd ~ / cd - |
Change dir / home / previous |
ls |
List |
ls -l |
Long listing |
ls -la |
Long + hidden |
ls -ld dir |
List directory itself |
ls -F |
Classify (/, *, @, …) |
ls -R |
Recursive |
file path |
Guess file type |
Paths: /… absolute · foo/bar relative · ~ home · . here · .. parent
View & compare
| Command |
Purpose |
cat f |
Print whole file |
less f |
Page through (q quit) |
head -n 20 f |
First lines |
tail -n 20 f |
Last lines |
tail -f f |
Follow growing log |
wc -l f |
Count lines (also -w -c) |
diff a b |
Compare two files |
Create / copy / move / delete
| Command |
Purpose |
touch f |
Create empty / update mtime |
mkdir d / mkdir -p a/b |
Make directory (parents) |
cp a b / cp -r dir dest |
Copy file / tree |
cp -i |
Confirm overwrite |
mv a b |
Move / rename |
rm f / rm -i f |
Remove file (interactive) |
rm -r dir |
Remove tree (careful!) |
rmdir d |
Remove empty directory |
Links & search
| Command |
Purpose |
ln a hard |
Hard link |
ln -s target link |
Symbolic link |
find dir -name '*.log' |
Find by name |
grep -n pat f |
Search inside file |
grep -R pat dir |
Recursive grep |
| Globs |
* any · ? one · [abc] set |
vim essentials
| Key / cmd |
Purpose |
vim f |
Open / create |
i a o |
Insert / append / open line |
Esc |
Normal mode |
h j k l |
Move |
dd yy p |
Delete line / yank / put |
/pat n |
Search / next |
:w :q :wq :q! |
Write / quit / save-quit / discard |
:set number |
Show line numbers |
Bash: expansions, redirect, variables
| Syntax |
Purpose |
{a,b} |
Brace expand |
$VAR / ${VAR} |
Parameter |
$(cmd) |
Command substitution |
> >> |
Stdout overwrite / append |
2> 2>&1 |
Stderr; merge stderr→stdout |
< |
Stdin from file |
cmd \| cmd |
Pipe |
tee f |
View and save |
' " \ |
Quoting / escape |
export VAR=val |
Environment variable |
history / !! / Ctrl+R |
History / redo / reverse search |
source ~/.bashrc |
Reload startup file |
alias ll='ls -la' |
Alias |
Permissions
| Command |
Purpose |
ls -l |
Read mode bits |
chmod 644 f / chmod u+x f |
Octal / symbolic mode |
chown user f |
Change owner (needs privilege) |
chgrp group f |
Change group |
umask |
Default bits to remove on create |
Sticky on /tmp-style dirs |
chmod +t dir (others cannot delete each other’s files) |
Octal reminder: 7=rwx 6=rw- 5=r-x 4=r-- · order user-group-other.
Processes
| Command |
Purpose |
ps / ps -ef |
List processes |
pstree |
Tree view |
pgrep name |
Find PIDs by name |
kill PID |
SIGTERM (default) |
kill -9 PID |
SIGKILL (last resort) |
pkill name |
Signal by name |
cmd & |
Background |
Shell scripting (M14)
| Item |
Purpose |
#!/usr/bin/env bash |
Portable shebang |
chmod +x script.sh |
Make executable |
$0 $1 $# "$@" |
Name / args / count / all args |
"${1:-default}" |
Default value |
[[ -f f ]] [[ -d d ]] |
File / directory tests |
if …; then …; fi |
Branch |
for x in …; do …; done |
Loop |
exit n / $? |
Exit code / previous status |
set -euo pipefail |
Strict mode habit |
Archives & remote (M15)
| Command |
Purpose |
tar -czf a.tgz dir |
Create gzip archive |
tar -tzf a.tgz |
List |
tar -xzf a.tgz -C dest |
Extract into dest |
gzip -k f / gunzip -k f.gz |
Compress / decompress file |
zip -r a.zip dir |
Zip tree (optional) |
scp f u@h:~/ |
Copy over SSH |
sftp u@h |
Interactive SSH files |
rsync -av src/ dest/ |
Sync (delta-friendly) |
Packages (M16) — apt ‖ dnf
| Job |
apt (Debian/Ubuntu) |
dnf (Fedora/RHEL-family) |
| Refresh |
sudo apt update |
sudo dnf check-update |
| Upgrade |
sudo apt upgrade |
sudo dnf upgrade |
| Search |
apt search tree |
dnf search tree |
| Install |
sudo apt install tree |
sudo dnf install tree |
| Remove |
sudo apt remove tree |
sudo dnf remove tree |
| Info |
apt show tree |
dnf info tree |
Users & groups (M17)
| Command |
Purpose |
getent passwd user |
Look up account fields |
sudo useradd -m -s /bin/bash u |
Create user + home |
sudo adduser u |
Debian-friendly interactive create |
sudo passwd u |
Set password |
sudo groupadd g |
Create group |
su - u |
Login shell as user |
sudo -u u -i |
sudo into user |
sudo userdel -r u |
Delete user + home (VM only) |
passwd fields: name · x · UID · GID · comment · home · shell
Networking (M18)
| Command |
Purpose |
ip -br addr |
Interfaces + addresses |
ip route |
Routes / default gateway |
ping -c 3 host |
ICMP check (if installed) |
curl -sI https://url |
HTTP(S) headers / reachability |
wget -qO- url |
Fetch body (quiet) |
ss -tln |
Listening TCP ports |
ss -tlnp |
+ process (may need sudo) |
getent hosts name |
Resolve name |
Troubleshoot order: address → default route → ping/curl → DNS → ss listeners.
Safe practice reminder
mkdir -p /tmp/linux-lab-pushpjeet && cd /tmp/linux-lab-pushpjeet
Prefer disposable VMs for package and user labs. Snapshot before experiments.
Original cheat sheet © Pushpjeet Cholkar / pushpjeet.com. Not derived from Oracle training materials.