Cheat sheet: Linux & shell
Linux basics (cd, ls -lh, cp, mkdir, rm, cat, man, sudo, apt, ssh) to pipelines, every flag and pipe explained.
Each entry shows the command, a copy button, and what every part does: sub-command, flag, pipe, redirect and placeholder, in the order they appear. <placeholders> are the bits you replace.
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
Navigate & list13
cd <dir>Go into a folderWhat each part does
cdchange directory (a shell built-in)<dir>relative path (logs) or absolute path (/var/log)
cd ~Go to your home folderWhat each part does
cdchange directory~your home directory (/home/<user>); plain "cd" with no argument does the same
cd ..; cd -Go up one level / back to the previous folderWhat each part does
cd ..".." is the parent of the current folder;thencd -jump back to the folder you were in before (and print it)
pwdShow where you areWhat each part does
pwdprint working directory: the full path of the current folder
lsList filesWhat each part does
lslist the current folder (names only, hidden dot-files not shown)
ls -lLong listing: permissions, owner, size, dateWhat each part does
lslist directory contents-llong format: permissions, links, owner, group, size in bytes, modified date, name
ls -laInclude hidden files (.env, .git …)What each part does
-llong format-a--all: also show entries starting with "." (including . and ..)
Tip ls -lA shows hidden files but leaves out . and ..
ls -lhLong listing with readable sizesWhat each part does
-llong format-h--human-readable: sizes like 4.0K, 12M, 1.3G instead of bytes (works with -l)
ls -ltrNewest files last (great for log folders)What each part does
-llong format-tsort by modification time, newest first-r--reverse: flip the order, so the newest ends up at the bottom next to your prompt
ls -lhSBiggest files firstWhat each part does
-l -hlong format with readable sizes-Ssort by size, largest first
ls -d */List only sub-foldersWhat each part does
-d--directory: list the folders themselves, not what is inside them*/shell glob that matches only directories
ls -R <dir>List everything below, recursivelyWhat each part does
-R--recursive: list every sub-folder too
tree -L 2 <dir>Folder tree, two levels deepWhat each part does
treedraw the folder structure (install it: apt install tree)-L 2limit depth to 2 levels
Create, copy, move, delete13
mkdir -p <path/to/dir>Create a folder (and parents) in one goWhat each part does
mkdirmake directory-pcreate missing parent folders too; no error if it already exists
touch <file>Create an empty file / update its timestampWhat each part does
touchcreate the file if missing; if it exists, set its modified time to now
cp <src> <dest>Copy a fileWhat each part does
cpcopy<src>file to copy<dest>new file name, or a folder to copy into
cp -r <src-dir> <dest-dir>Copy a folder with everything in itWhat each part does
-r--recursive: copy directories and their contents
cp -a <src> <dest>Copy keeping permissions, owner and times (backups)What each part does
-a--archive: recursive + keep symlinks, permissions, ownership and timestamps
cp -i <src> <dest>Copy but ask before overwritingWhat each part does
-i--interactive: prompt before overwriting an existing file
mv <old-name> <new-name>Rename a file or folderWhat each part does
mvmove: within the same folder this is a rename
mv <file1> <file2> <dir>/Move files into a folderWhat each part does
<file1> <file2>one or more sources<dir>/destination folder (the trailing / makes it clear it is a folder)
Tip Add -i to be asked before overwriting, -n to never overwrite.
rm <file>Delete a fileCautionWhat each part does
rmremove (no recycle bin: it is gone)
rm -i <files>Delete, but confirm each fileCautionWhat each part does
-iprompt before every removal
rm -rf <dir>Delete a folder and everything in itDestructiveWhat each part does
-r--recursive: remove directories and their contents-f--force: never prompt, ignore files that don't exist<dir>double-check this path: there is no undo
Tip Run ls <dir> first. Never run it with a variable that might be empty (rm -rf "$DIR/").
rmdir <dir>Delete an empty folderWhat each part does
rmdirremove a directory only if it is empty (safe)
ln -s <target> <link-name>Create a symbolic link (shortcut)What each part does
lnmake links-s--symbolic: a symlink pointing to <target> (without -s it makes a hard link)<target>the real file or folder<link-name>the shortcut to create
View & compare files9
cat <file>Print a fileWhat each part does
catconcatenate: print one or more files to the screen
cat -n <file>Print with line numbersWhat each part does
-n--number: number every output line
less <file>Read a long file page by pageWhat each part does
lessscroll a file: Space/b = page down/up, /text = search, n = next match, G = end, q = quit
head -n 20 <file>First lines of a fileWhat each part does
headstart of a file-n 20how many lines (default 10)
tail -n 50 <file>Last lines of a fileWhat each part does
tailend of a file-n 50how many lines (default 10); add -f to keep following
wc -l <file>Count lines, words, bytesWhat each part does
wcword count-lcount lines only (-w words, -c bytes)
diff -u <old-file> <new-file>Compare two filesWhat each part does
diffshow differences (exit 0 = same, 1 = different)-uunified format: - removed lines, + added lines, 3 lines of context
file <file>What kind of file is this?What each part does
filedetect the type: text, ELF binary, gzip, JSON…
stat <file>Size, permissions and timestamps of a fileWhat each part does
statdetailed metadata: size, inode, permissions, access/modify/change times
Permissions & ownership (chmod, chown, umask, ACL)31
ls -l <file>Read a permission stringWhat it means
On a directory: r = list names, w = create/delete entries, x = enter it / reach things inside.
What each part does
-rwxr-xr-xexample output; 1st char is the type: - file, d directory, l symlinkrwxchars 2-4, owner (user): r read, w write, x executer-xchars 5-7, group: - means "not allowed"r-xchars 8-10, others (everyone else)s / ts in an x slot = setuid/setgid, t in the last slot = sticky (capital S/T = bit set but no x)+a trailing + means extra ACL entries exist (see getfacl)
stat -c '%a %A %U:%G %n' <file>See permissions as numbersWhat each part does
stat -cprint chosen fields%apermissions in octal, e.g. 755%Athe same as letters, e.g. -rwxr-xr-x%U:%Gowner user and group%nfile name
chmod 755 <file-or-dir>Octal modes explained: 755What each part does
chmodchange mode (permissions)7owner = 4 read + 2 write + 1 execute = rwx5group = 4 read + 1 execute = r-x5others = r-x
Tip Typical for folders, scripts and binaries.
chmod 644 <file>Regular files: owner writes, everyone readsWhat each part does
6owner rw- (4+2)4group r--4others r--
Tip Typical for config files, web content, documents.
chmod 600 <file>Private file: only the ownerWhat each part does
6owner rw-0group: nothing0others: nothing
Tip Use for secrets: .env files, private keys, kubeconfig, credentials.
chmod 700 <dir>Private folder / script: only the ownerWhat each part does
7owner rwx0 0group and others: no access at all
chmod 750 <dir>; chmod 640 <file>Shared with the group, hidden from othersWhat each part does
750dir: owner rwx, group r-x (can enter and read), others none640file: owner rw-, group r--, others none
chmod 400 <file>Read-only for the ownerWhat each part does
4owner r-- only00nobody else
Tip AWS .pem key files are expected to be 400 or 600.
chmod 777 <path>777: everyone can do everything (avoid)DestructiveWhat each part does
7 7 7rwx for owner, group and ALL other users
Tip Any user or compromised process can change or replace the file, or delete files in the folder. Fix ownership or group instead (chown / chgrp + 775 or 770).
chmod +x <script>.sh && ./<script>.shMake a script executable and run itWhat each part does
+xadd execute (no who-letter = for all, minus the umask bits)&&then./<script>.shrun it from the current folder (. is not on PATH)
chmod u+x,g-w,o-rwx <file>Symbolic: add or remove for owner/group/othersWhat each part does
u+xu = owner (user): add execute,separate clausesg-wg = group: remove writeo-rwxo = others: remove everything
Tip Who: u, g, o, a (all). Operator: + add, - remove, = set exactly. Perms: r w x X s t.
chmod u=rwx,go=rx <path>Symbolic: set exact permissionsWhat each part does
u=rwxowner gets exactly rwxgo=rxgroup and others get exactly r-x (same as 755)
chmod a+r <file>Give everyone read accessWhat each part does
a+ra = all (owner, group, others): add read
chmod -R u+rwX,go+rX,go-w <dir>Recursive, the safe way (capital X)What each part does
-R--recursive: the folder and everything insideu+rwXowner: read, write, and execute only for folders / files already executablego+rXgroup/others: read, and enter foldersgo-wgroup/others: no write
Tip X (capital) avoids making every plain file executable, which chmod -R 755 would do.
find <dir> -type d -exec chmod 755 {} + && find <dir> -type f -exec chmod 644 {} +Folders 755, files 644 (fix a messy tree)CautionWhat each part does
find <dir> -type devery directory under <dir>-exec chmod 755 {} +run chmod on them in batches ({} = the found names)&&then-type f … chmod 644every regular file gets 644
Tip Re-add +x afterwards to scripts that need it.
chmod --reference=<source-file> <file>Copy permissions from another fileWhat each part does
--reference=<source-file>use that file's mode instead of typing one
sudo chown <user> <path>Change the ownerWhat each part does
chown <user>new owner; the group stays the same
sudo chown -R <user>:<group> <path>Change owner and group, recursivelyWhat each part does
-Rrecursive<user>:<group>both at once (no spaces). <user>: alone = also set the user's login group
sudo chgrp -R <group> <path>Change only the groupWhat each part does
chgrpchange group (same as chown :<group>)-Rrecursive
sudo chown -R --from=<old-user> <new-user> <dir>Re-own only files that belong to someone elseWhat each part does
--from=<old-user>change only files currently owned by <old-user><new-user>new owner
sudo chgrp <group> <dir> && sudo chmod 2775 <dir>Shared team folder: new files keep the folder groupWhat each part does
chgrp <group> <dir>folder belongs to the team group2setgid bit: new files/folders inside inherit the folder's group775owner and group rwx, others r-x
Tip Symbolic form: chmod g+s <dir>.
sudo chmod 1777 <dir>Sticky folder: users can only delete their own filesWhat each part does
1sticky bit: only the file owner (or dir owner/root) can delete or rename entries777everyone can create files
Tip This is how /tmp is set up (drwxrwxrwt). Symbolic: chmod +t <dir>.
sudo find / -xdev -type f -perm /4000 2>/dev/nullFind setuid programs (security audit)What each part does
-xdevstay on one filesystem-type ffiles only-perm /4000any file with the setuid bit (runs as its owner, often root)2>/dev/nullhide "Permission denied" noise
find <dir> -type f -perm -o+wFind world-writable filesWhat each part does
-perm -o+w"-" = all listed bits must be set: others have write
umask; umask 027Default permissions for new files (umask)What each part does
umaskshow the current mask (usually 0022)umask 027set it for this shell: bits in the mask are REMOVED from new files
Tip New files start from 666, folders from 777. 022 → files 644, dirs 755. 027 → 640 / 750. 077 → 600 / 700. Put it in ~/.bashrc or the service unit (UMask=) to keep it.
setfacl -m u:<user>:rwx <path>Give one extra user access (ACL)What each part does
setfaclset file access control lists-m--modify: add or change an entryu:<user>:rwxentry: u = user, then the name, then permissions (g:<group>:rx for a group)
setfacl -R -m u:<user>:rwX <dir> && setfacl -d -m u:<user>:rwX <dir>ACL for everything inside, and for future filesWhat each part does
-Rapply to existing files recursively-d--default: entries that NEW files and folders inside will inheritrwXX = execute only on folders/executables
getfacl <path>Show ACLsWhat each part does
getfaclowner, group, and every ACL entry with its effective rights (mask applies)
setfacl -x u:<user> <path>; setfacl -b <path>Remove ACL entriesWhat each part does
-x u:<user>remove that user's entry (no permissions in the spec)-b--remove-all: drop every extra entry, keep owner/group/others
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys ~/.ssh/id_ed25519SSH files: fix permissions so sshd accepts themWhat each part does
700 ~/.sshonly you can enter or list the folder600 authorized_keysonly you can read/write the list of allowed keys600 id_ed25519private key readable only by you (public .pub can be 644)
Tip With StrictModes (default yes) sshd refuses keys if these are group/world-writable.
namei -l <path>Why is access denied? Check every folder on the pathWhat each part does
namei -llist owner, group and mode of each component: missing x on any parent blocks access
Help & shell basics11
man <command>Read the manual for a commandWhat each part does
manmanual page; / to search, q to quit<command>e.g. man ls, man tar
<command> --helpQuick help for a commandWhat each part does
--helpmost tools print their options and exit
which <command>; type <command>Where is a command installed?What each part does
whichpath of the program that would runtypealso tells you if it is an alias, built-in or function
history | grep <word>Search your command historyWhat each part does
historynumbered list of commands you ran| grep <word>only the ones containing <word>; re-run one with !<number>
Tip Faster: press Ctrl+R and start typing to search history interactively.
sudo !!Re-run the last command with sudoWhat each part does
sudorun as root!!history expansion: the whole previous command
alias ll='ls -lh'Create a shortcut commandWhat each part does
aliasdefine a short name for a commandll='ls -lh'typing ll now runs ls -lh (add it to ~/.bashrc to keep it)
echo "$HOME"Print a variableWhat each part does
echoprint text"$HOME"value of the HOME variable; quotes keep spaces intact
export <NAME>=<value>Set a variable for this shell and its programsWhat each part does
exportmake the variable visible to programs you start from this shell<NAME>=<value>no spaces around =
env | grep <NAME>Show environment variablesWhat each part does
envall environment variables| grep <NAME>only matching ones
sudo <command>; sudo -iRun as root / open a root shellCautionWhat each part does
sudo <command>run one command as root (asks for your password)sudo -iinteractive root login shell; type exit to leave
Tab · Ctrl+C · Ctrl+R · Ctrl+L · Ctrl+DUseful keysWhat each part does
Tabcomplete file and command names (press twice to list options)Ctrl+Cstop the running commandCtrl+Rsearch command historyCtrl+Lclear the screen (same as clear)Ctrl+Dend input / log out of the shell
Users & groups6
whoami; idWho am I?What each part does
whoamiyour user nameidyour user ID, primary group and all groups
groups <user>Which groups is a user in?What each part does
groupslist group memberships (yours if no user given)
su - <user>Switch to another userWhat each part does
susubstitute user-start a full login shell (their home folder and environment)
sudo useradd -m -s /bin/bash <user>Create a user with a home folder and bashWhat each part does
useraddcreate a user account-m--create-home: create /home/<user> with the skeleton files-s /bin/bash--shell: login shell
sudo usermod -aG <group> <user>Add a user to a group (keep other groups)What each part does
usermodmodify a user-a--append: add to the group (only valid with -G)-G <group>supplementary group(s). Without -a the user is REMOVED from groups not listed
Tip Typical: sudo usermod -aG docker $USER, then log out and in again.
sudo passwd <user>Set or change a passwordWhat each part does
passwdchange the password (your own if no user given, no sudo needed)
Install packages7
sudo apt update && sudo apt upgrade -yRefresh package lists and upgrade (Debian/Ubuntu)What each part does
apt updatedownload the latest package lists (installs nothing)&&only if that workedapt upgradeinstall newer versions of installed packages-yanswer yes to the prompt
sudo apt install -y <package>Install a packageWhat each part does
apt installinstall a package and its dependencies-yno confirmation prompt
sudo apt remove <package>Remove a packageCautionWhat each part does
apt removeuninstall (keeps config files; apt purge removes those too)
apt search <word>Find a packageWhat each part does
apt searchsearch package names and descriptions
apt list --installed | grep <package>Is it installed?What each part does
apt list --installedevery installed package| grep <package>filter to the one you want
sudo dnf install -y <package>Install on RHEL / Fedora / Amazon LinuxWhat each part does
dnf installinstall with the dnf package manager (yum on older systems)-yno prompt
apk add --no-cache <package>Install on Alpine (common in containers)What each part does
apk addAlpine's package manager--no-cachedon't keep the package index: smaller images
Package & software versions (any distro)29
hostnamectlOS, version and kernel in one viewWhat each part does
hostnamectlhostname, operating system and version, kernel, architecture, virtualization (systemd systems)
<program> --versionVersion of any programWhat each part does
<program> --versionmost tools print their version; some use -v or -V (nginx -v, java -version, python3 -V)
dpkg -S "$(command -v <program>)"Where is a command, and which package installed it? (Debian / Ubuntu)What each part does
command -v <program>full path of the program the shell would rundpkg -S <path>the package that owns that file
rpm -qf "$(command -v <program>)"Which package installed a command? (RHEL / Fedora / Amazon Linux)What each part does
command -v <program>full path of the programrpm -qf <path>package (name-version-release) that owns that file
dpkg-query -W -f='${Package} ${Version} ${Status}\n' <package>Installed version of one package (Debian / Ubuntu)What each part does
dpkg-query -Wshow installed package info-f='${Package} ${Version} ${Status}\n'output format: name, version, install status<package>package name; wildcards work, e.g. 'openssl*'
apt-cache policy <package>Installed vs available version (Debian / Ubuntu)What each part does
apt-cache policyInstalled: version now, Candidate: what apt install/upgrade would get, plus the version table per repo<package>package name
apt list -a <package>All versions the repos offer (Debian / Ubuntu)What each part does
apt list -aevery available version, marked [installed] / [upgradable]
sudo apt update && apt list --upgradablePackages with updates available (Debian / Ubuntu)What each part does
apt updaterefresh package lists first, or the answer is staleapt list --upgradableinstalled packages with a newer version: name, new version, [upgradable from: old]
dpkg-query -W -f='${Package}\t${Version}\n' | sortEvery installed package with its version (Debian / Ubuntu)What each part does
dpkg-query -W -f='...'name TAB version for every installed package| sortalphabetical; redirect to a file to diff two servers
rpm -q <package>Installed version of one package (RHEL / Fedora / Amazon Linux / SUSE)What each part does
rpm -q <package>name-version-release.arch, or 'package ... is not installed'
rpm -qi <package>Details of an installed package (RHEL family)What each part does
rpm -qiversion, release, install date, vendor, build date, summary
dnf list --showduplicates <package>Installed and available versions (RHEL / Fedora)What each part does
dnf listInstalled Packages section and Available Packages section--showduplicatesevery available version, not just the newest (to pick one to install or downgrade)
dnf check-updatePackages with updates available (RHEL / Fedora)What each part does
dnf check-updatelist pending updates; exit code 100 means updates exist, 0 means none (yum check-update on older systems)
dnf updateinfo list --securityPending security updates only (RHEL / Fedora)What each part does
dnf updateinfo listadvisories for available updates--securityonly security fixes, with severity and advisory ID
rpm -qa --last | head -30Every installed package, newest installs first (RHEL family)What each part does
rpm -qaall installed packages--lastsorted by install/update time, newest first, with the date| head -30the 30 most recent
dnf history; dnf history info <id>What changed recently? (RHEL / Fedora)What each part does
dnf historyevery install/upgrade/remove transaction with date and userdnf history info <id>exact packages and versions in that transaction; dnf history undo <id> reverts it
grep -E ' (install|upgrade) ' /var/log/dpkg.logWhat was installed or upgraded recently? (Debian / Ubuntu)What each part does
grep -E ' (install|upgrade) 'only install and upgrade lines (date, package, old and new version)/var/log/dpkg.logdpkg's log; older months are in dpkg.log.1 and .gz files (zgrep)
apk info -v <package>; apk policy <package>Installed version of one package (Alpine)What each part does
apk info -v <package>installed name-versionapk policy <package>installed and available versions per repository
apk update && apk version -l '<'Packages with updates available (Alpine)What each part does
apk updaterefresh the indexapk version -l '<'only packages whose installed version is older than the repo's
zypper info <package>Installed version of one package (SUSE)What each part does
zypper infoversion, repository, installed status of a package
snap list; flatpak list --columns=application,versionSnap and Flatpak packages with versionsWhat each part does
snap listsnaps: name, version, revision, channelflatpak list --columns=...flatpak apps and their versions
python3 -m pip list; python3 -m pip show <package>Python packages and versionsWhat each part does
python3 -m pip listevery package in this Python environment with its version (add --outdated for updates)pip show <package>version, location and dependencies of one package
node --version; npm ls -g --depth=0Global Node.js packages and versionsWhat each part does
node --versionNode.js versionnpm ls -g --depth=0globally installed npm packages, top level only
ldd --version | head -1; openssl version -a | head -2Core library versions (glibc, OpenSSL)What each part does
ldd --versionthe C library (glibc) version; matters for binary compatibility and CVEsopenssl version -aOpenSSL version and build date
sudo apt install <package>=<version>Install a specific version (Debian / Ubuntu)CautionWhat each part does
<package>=<version>exact version from apt list -a; add --allow-downgrades to go back
sudo dnf install <package>-<version>Install a specific version (RHEL / Fedora)CautionWhat each part does
<package>-<version>exact version from dnf list --showduplicates; dnf downgrade to go back
sudo apt-mark hold <package>; sudo dnf versionlock add <package>Stop a package from being upgradedWhat each part does
apt-mark holdDebian / Ubuntu: keep the current version (apt-mark unhold to release)dnf versionlock addRHEL / Fedora: same idea (needs the versionlock plugin)
dnf provides '*/<file>'; apt-file search <file>Which package provides a file you don't have?What each part does
dnf provides '*/<file>'RHEL family: packages containing that fileapt-file search <file>Debian / Ubuntu (install apt-file and run apt-file update first)
ansible all -i <inventory> -m shell -a "rpm -q <package> 2>/dev/null || dpkg-query -W <package>"Check a package version across many serversWhat each part does
ansible all -i <inventory>every host in the inventory-m shell -a "..."run the command on each onerpm -q <package> || dpkg-query -W <package>works on both RHEL- and Debian-family hosts
Tip Without Ansible: for h in <host1> <host2>; do echo "$h: $(ssh $h 'rpm -q <package> 2>/dev/null || dpkg-query -W <package>')"; done
System info9
uname -aKernel and architectureWhat each part does
unamesystem information-aall: kernel name, hostname, release, version, architecture
cat /etc/os-releaseWhich Linux distribution and version?What each part does
/etc/os-releaseNAME, VERSION_ID, ID of the distro (ubuntu, debian, rhel…)
hostname; hostname -IHost name and IP addressesWhat each part does
hostnamethe machine name-Iall IP addresses of the host
uptimeHow long has it been running? Load?What each part does
uptimetime since boot, logged-in users, load average over 1/5/15 minutes
date; timedatectlDate, time and timezoneWhat each part does
datecurrent date and timetimedatectltimezone and whether NTP sync is active
nproc; lscpuCPU cores and modelWhat each part does
nprocnumber of CPUs availablelscpuCPU model, cores, threads, architecture
lsblkDisks and partitionsWhat each part does
lsblkblock devices as a tree: disks, partitions, sizes, mount points
findmntWhat is mounted whereWhat each part does
findmntmounted filesystems as a tree (cleaner than mount)
sudo reboot; sudo shutdown -h nowReboot / shut downDestructiveWhat each part does
rebootrestart the machineshutdown -h now-h = halt/power off, now = immediately (or +10 for 10 minutes)
Network basics & SSH10
ping -c 4 <host>Is a host reachable?What each part does
pingsend ICMP echo requests-c 4stop after 4 packets (otherwise it runs until Ctrl+C)
ssh <user>@<host>Log in to a serverWhat each part does
sshsecure shell<user>@<host>remote user name and host name or IP
ssh -p <port> -i <key-file> <user>@<host>SSH with a port and a key fileWhat each part does
-p <port>remote port (default 22)-i <key-file>private key to use
ssh <user>@<host> "<command>"Run one command remotelyWhat each part does
"<command>"runs on the server, output comes back to you
ssh-keygen -t ed25519 -C "<email>"Create an SSH keyWhat each part does
ssh-keygengenerate a key pair-t ed25519key type (ed25519 is the modern default)-C "<email>"comment stored in the key, to recognise it
Tip Creates ~/.ssh/id_ed25519 (private, keep secret) and id_ed25519.pub (public).
ssh-copy-id <user>@<host>Install your public key on a serverWhat each part does
ssh-copy-idappend your public key to ~/.ssh/authorized_keys on the server
wget <url>Download a fileWhat each part does
wgetdownload to the current folder (curl -O <url> does the same)
nc -zv <host> <port>Is a TCP port open?What each part does
ncnetcat-zjust scan, send no data-vverbose: say "succeeded" or "refused"
traceroute <host>Path packets take to a hostWhat each part does
traceroutelist every hop (router) on the way; shows where it stops
ip aShow IP addressesWhat each part does
ip ashort for ip address: every interface with its IPs
Zip & compress4
zip -r <archive>.zip <dir>Zip a folderWhat each part does
zipcreate a .zip archive-rinclude folders recursively
unzip <archive>.zip -d <dir>Unzip into a folderWhat each part does
-d <dir>extract into <dir> instead of the current folder
gzip <file>; gunzip <file>.gzCompress / decompress one fileWhat each part does
gzip <file>replace <file> with <file>.gzgunziprestore the original
tar -tf <archive>.tar.gzList what is inside a tarballWhat each part does
-tlist contents-farchive file name
Shell operators (how combinations work)6
cmd1 | cmd2Send the output of one command into anotherWhat each part does
cmd1first command; its normal output (stdout) is captured|pipe: stdout of the left command becomes the input (stdin) of the right onecmd2second command, reads that input (e.g. grep, sort, head)
cmd > out.txt; cmd >> out.txtSave output to a file (overwrite / append)What each part does
>redirect stdout to a file, creating it or truncating it to empty first;run the next command after the first, whatever its result>>append stdout to the end of the file (creates it if missing)
cmd > out.log 2>&1Capture errors together with normal outputWhat each part does
> out.logstdout (file descriptor 1) goes to out.log2>&1make stderr (fd 2) point where stdout points. Order matters: it must come after > out.log
Tip Short bash form: cmd &> out.log
make build && make deploy || echo "failed"Run the next command only if the previous one succeeded / failedWhat each part does
make buildfirst command&&run the next command only if the previous exited with code 0 (success)make deployruns only after a successful build||run the next command only if the previous exited non-zero (failure)echo "failed"fallback message
kill $(pgrep -f <name>)Use the output of a command as an argumentWhat each part does
killsend a signal (TERM by default) to process IDs$( … )command substitution: run the inner command and paste its output herepgrep -f <name>print PIDs whose full command line matches <name>
cat <list-file> | xargs -r -n 1 <cmd>Pass input lines as arguments to another commandWhat each part does
cat <list-file>print the file (one item per line)|pipe into xargsxargsbuild and run command lines from its input-rdon't run the command at all if the input is empty (GNU xargs)-n 1one input item per command invocation<cmd>the command to run with each item appended
Processes6
ps aux | grep <name>Find a process by nameWhat each part does
pssnapshot of current processesauxBSD-style options (no dash): a = all users, u = user-oriented columns (USER, %CPU, %MEM…), x = include processes without a terminal|pipe the process list into grepgrep <name>keep only lines containing <name>
Tip The grep line itself matches too. Use grep "[n]ginx" (brackets on one letter) or pgrep -a <name>.
ps aux --sort=-%mem | headTop 10 processes by memoryWhat each part does
ps auxall processes, user-oriented columns--sort=-%memsort by memory share; the leading "-" means descending| headkeep the first 10 lines (header + top 9)
ps -eo pid,user,%cpu,%mem,comm --sort=-%cpu | head -n 15Custom columns sorted by CPUWhat each part does
-eselect every process-o pid,user,%cpu,%mem,commchoose the output columns: PID, owner, CPU %, memory %, executable name--sort=-%cpuhighest CPU firsthead -n 15first 15 lines
top -b -n 1 | head -n 20One-shot top output (for logs or scripts)What each part does
toplive process viewer-bbatch mode: plain text, no interactive screen (works in pipes)-n 1stop after one refreshhead -n 20summary lines plus the top processes
kill <pid>; sleep 5; kill -9 <pid>Stop a process gracefully, then forcefullyCautionWhat each part does
kill <pid>send SIGTERM (15): asks the process to exit and clean upsleep 5give it time to shut downkill -9 <pid>send SIGKILL: cannot be caught, ends it immediately (no cleanup)
free -hMemory usage in human unitsWhat each part does
freeshow RAM and swap usage-hhuman-readable units (Mi, Gi). Look at the "available" column, not "free"
Files & search8
grep -rn "<text>" <dir>Search text in all files under a folderWhat each part does
grepprint lines matching a pattern-rrecurse into sub-directories-nshow the line number of each match"<text>"the pattern (quote it if it has spaces or special characters)<dir>where to start searching
grep -rni --include="*.yaml" "<pattern>" <dir>Case-insensitive search in one file type onlyWhat each part does
-r -nrecursive, with line numbers-iignore upper/lower case--include="*.yaml"only search files whose name matches the glob"<pattern>"regular expression to find
Tip Useful extras: -l (only file names), -v (lines that do NOT match), -w (whole word), -C 3 (3 lines of context).
find <dir> -name "*.log" -mtime +7 -deleteFind and delete log files older than 7 daysDestructiveWhat each part does
find <dir>walk the directory tree starting at <dir>-name "*.log"file name matches the pattern (quoted so the shell does not expand it)-mtime +7last modified more than 7 days ago-deletedelete each match
Tip Run it with -print instead of -delete first to see what would go.
find <dir> -type f -size +100MFind big filesWhat each part does
-type fregular files only (d = directories)-size +100Mlarger than 100 MiB ("+" = more than, "-" = less than)
find <dir> -name "*.tmp" -print0 | xargs -0 rm -fRun a command on every found file (safe with spaces)DestructiveWhat each part does
-print0print each name ending with a NUL byte instead of a newline|pipe the names to xargsxargs -0read NUL-separated names, so spaces/newlines in names are saferm -fremove the files, no prompts
tail -F <file> | grep --line-buffered "<word>"Follow a log and show only matching linesWhat each part does
tailshow the end of a file-Ffollow new lines and keep following when the file is rotated or recreated|stream new lines into grepgrep --line-bufferedprint each match immediately instead of buffering"<word>"text to look for, e.g. ERROR
sed -n '<start>,<end>p' <file>Show lines N to M of a fileWhat each part does
sedstream editor-ndon't print every line automatically'<start>,<end>p'address range (line numbers) + p = print those lines
sed -i.bak 's/<old>/<new>/g' <file>Replace text in a file in place (keep a backup)CautionWhat each part does
-i.bakedit the file in place and save the original as <file>.baks/<old>/<new>/substitute: regex <old> → <new>greplace every match on a line, not just the first
Text processing pipelines4
sort <file> | uniq -c | sort -rn | headCount duplicate lines, most frequent firstWhat each part does
sort <file>sort lines so duplicates sit next to each otheruniq -ccollapse adjacent duplicates and prefix each with its countsort -rnsort by that number (-n numeric) in reverse order (-r)headtop 10
awk '{print $1}' access.log | sort | uniq -c | sort -rn | headTop client IPs in an access logWhat each part does
awk '{print $1}'print the first whitespace-separated field of every line (the client IP)sort | uniq -cgroup identical IPs and count themsort -rn | headhighest counts first, top 10
grep -c "<pattern>" <file>; wc -l <file>Count lines / matchesWhat each part does
grep -ccount matching lines instead of printing themwc -lcount all lines in the file
sort -t: -k3,3n /etc/passwdSort a delimited file by a numeric columnWhat each part does
-t:fields are separated by ":"-k3,3sort key is field 3 onlyncompare that key as a number
Disk3
df -hT; df -iDisk space per filesystem (and inodes)What each part does
dfreport filesystem usage-hhuman-readable sizes-Tshow the filesystem typedf -iinode usage instead of space. A disk can be "full" on inodes
du -sh * | sort -rh | headBiggest items in the current folderWhat each part does
duestimate file/directory space-sone total per argument-hhuman-readable sizes*every entry in the current directory (shell glob)sort -rhsort human sizes (-h knows 2K < 1G), largest first (-r)headtop 10
du -xh -d 1 <dir> | sort -rh | head -n 15Folder sizes one level deep, same filesystemWhat each part does
-xdon't cross into other mounted filesystems-hhuman-readable-d 1only show totals one level below <dir> (same as --max-depth=1)sort -rh | head -n 15largest 15
Network5
ss -tulpnWhich process listens on which portWhat each part does
sssocket statistics (modern netstat)-tTCP sockets-uUDP sockets-llistening sockets only-pshow the owning process (needs sudo for other users’ processes)-nnumeric ports and addresses, no name lookups
sudo lsof -i :<port>Who is using a portWhat each part does
lsoflist open files (sockets are files too)-ionly network sockets:<port>filter to that port
ip -br addr; ip routeInterfaces and routesWhat each part does
ip -br addrevery interface with its addresses, one line each (-br = brief)ip routerouting table, including the default gateway
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" <url>Check an HTTP endpoint: status code and timeWhat each part does
-ssilent: no progress bar-Sbut still show errors-o /dev/nullthrow away the response body-w "…"print a custom line after the request: %{http_code} = status, %{time_total} = seconds
curl -fsSL <url> -o <file>Download a file, following redirects, failing on HTTP errorsWhat each part does
-ffail (non-zero exit, no output) on HTTP 4xx/5xx-s -Squiet, but show errors-Lfollow redirects-o <file>write the body to <file>
Services & logs (systemd)6
systemctl status <unit> --no-pager -lStatus and recent logs of a serviceWhat each part does
systemctl status <unit>state, PID, last exit code and the last log lines--no-pagerprint directly instead of opening less-ldon't truncate long lines
sudo systemctl enable --now <unit>Start at boot and start nowWhat each part does
enablecreate the links so the unit starts at boot--nowalso start it right away
sudo systemctl daemon-reload && sudo systemctl restart <unit>Reload unit files after editing themWhat each part does
daemon-reloadre-read unit files (does not restart services)&&only if that worked…restart <unit>stop then start the service
journalctl -u <unit> -f -n 100Follow a service logWhat each part does
-u <unit>only messages from that unit-ffollow new entries-n 100start with the last 100 lines
journalctl -p err -b --no-pagerErrors since bootWhat each part does
-p errpriority "err" and more severe (crit, alert, emerg)-bcurrent boot only (-b -1 = previous boot)--no-pagerplain output
journalctl -u <unit> --since "1 hour ago" --until nowLogs in a time windowWhat each part does
--sincestart time: absolute ("2026-11-20 10:00") or relative ("1 hour ago", "yesterday")--untilend time
Archives & copying4
tar -czvf <name>.tar.gz <dir>Create a gzip tarballWhat each part does
-ccreate an archive-zcompress with gzip-vlist files as they are added-f <name>.tar.gzarchive file name (must come right after f)
tar -xzvf <name>.tar.gz -C <dest>Extract a tarball into a folderWhat each part does
-xextract-z -v -fgzip, verbose, archive file-C <dest>change to <dest> before extracting
rsync -avzn --delete <src>/ <user>@<host>:<dest>/Sync a folder to a server (preview first)CautionWhat each part does
-aarchive mode: recursive, keep permissions, times, owner, symlinks-vverbose-zcompress during transfer-ndry run: show what would change. Remove it to really sync--deletedelete files on the destination that are not in the source<src>/trailing slash = copy the folder’s contents, not the folder itself
scp -r -P <port> <src> <user>@<host>:<path>Copy a folder to a server over SSHWhat each part does
-rcopy directories recursively-P <port>SSH port (capital P; lowercase -p means preserve times)<user>@<host>:<path>remote destination
Firewall (ufw, firewalld, iptables, nftables)7
sudo ufw status verboseFirewall status and rules (Ubuntu ufw)What each part does
ufw statusactive or not, and each allow/deny ruleverbosealso default policies and logging level
sudo ufw allow <port>/tcpAllow a port (ufw)CautionWhat each part does
ufw allowadd an allow rule (ufw allow from <ip> to any port <port> to restrict the source)<port>/tcpport and protocol
sudo firewall-cmd --list-allFirewall rules (RHEL firewalld)What each part does
firewall-cmd --list-allthe default zone's services, ports, rich rules and interfaces
sudo firewall-cmd --permanent --add-port=<port>/tcp && sudo firewall-cmd --reloadOpen a port permanently (firewalld)CautionWhat each part does
--permanentsave to config (without it the rule is lost on reload)--add-port=<port>/tcpopen the port in the default zone (or --add-service=https)--reloadapply the saved config
sudo iptables -L -n -v --line-numbersList iptables rules with countersWhat each part does
-Llist rules of the filter table-nnumeric, no DNS lookups-vpacket/byte counters and interfaces--line-numbersrule numbers, for deleting by number
sudo iptables -t nat -L -n -vList NAT rules (port forwards, Docker, Kubernetes)What each part does
-t natthe NAT table: DNAT port forwards and MASQUERADE rules
sudo nft list rulesetShow the full nftables rulesetWhat each part does
nft list rulesetevery table, chain and rule (newer distros use nftables under firewalld and iptables-nft)
Scheduling: cron & systemd timers6
crontab -l; crontab -eList and edit your cron jobsWhat each part does
crontab -lshow your user's cron jobs (sudo crontab -l -u <user> for others)crontab -eedit them in $EDITOR
*/5 * * * * /usr/local/bin/<script> >> /var/log/<script>.log 2>&1Cron line formatWhat each part does
*/5 * * * *minute hour day-of-month month day-of-week: here every 5 minutes/usr/local/bin/<script>use full paths: cron has a minimal PATH>> <log> 2>&1append output and errors to a log, otherwise they are mailed or lost
ls /etc/cron.d /etc/cron.daily /etc/cron.hourly; cat /etc/crontabSystem-wide cron jobsWhat each part does
/etc/cron.djob files from packages and admins (with a user field)/etc/cron.daily, hourly...scripts run by run-parts at those intervals
journalctl -u cron -u crond --since todayDid cron run my job?What each part does
journalctl -u cron -u crondcron daemon logs (cron on Debian, crond on RHEL); or grep CRON /var/log/syslog--since todayonly today
systemctl list-timers --allList systemd timers and when they run nextWhat each part does
list-timersevery timer: next run, last run, the unit it starts--allinclude inactive timers
echo '<command>' | at 02:00Run a command once at a later timeWhat each part does
at 02:00run once at 2 AM (also: at now + 30 minutes); atq lists, atrm removes
Storage, mounts & LVM10
lsblk -fDisks, partitions and filesystemsWhat each part does
lsblkblock devices as a tree: disks, partitions, LVM volumes-fadd filesystem type, label, UUID and mount point
sudo mount <device> <mount-point>Mount a filesystemWhat each part does
mount <device>e.g. /dev/sdb1 or /dev/mapper/vg-data<mount-point>existing empty directory, e.g. /mnt/data
sudo findmnt --verify && sudo mount -aTest /etc/fstab before rebootingWhat each part does
findmnt --verifycheck fstab syntax, devices and filesystem typesmount -amount everything in fstab now; a typo here would otherwise stop the next boot
sudo umount <mount-point> || sudo lsof +f -- <mount-point>Unmount, and find what keeps it busyWhat each part does
umountunmountlsof +f -- <mount-point>processes with files open there (target is busy)
sudo mkfs.ext4 -L <label> <device>Create a filesystem on a new diskDestructiveWhat each part does
mkfs.ext4format as ext4 (mkfs.xfs for XFS): erases the device-L <label>filesystem label
sudo growpart <disk> <partition-number> && sudo resize2fs <partition>Grow a partition and filesystem after enlarging a cloud diskCautionWhat each part does
growpart /dev/xvda 1extend partition 1 to fill the disk (cloud-guest-utils)resize2fs <partition>grow an ext4 filesystem; for XFS: xfs_growfs <mount-point>
sudo pvs; sudo vgs; sudo lvsLVM overviewWhat each part does
pvsphysical volumes (disks in LVM)vgsvolume groups and their free spacelvslogical volumes and sizes
sudo lvextend -r -L +<size>G /dev/<vg>/<lv>Extend a logical volume and its filesystemCautionWhat each part does
lvextendgrow a logical volume-ralso resize the filesystem in one step-L +<size>Gadd this much (or -l +100%FREE for all free space)
swapon --show; sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfileShow swap, and add a swap fileWhat each part does
swapon --showactive swap devices and usagefallocate -l 2G /swapfilecreate a 2 GB filechmod 600only root may read itmkswap / swaponformat it as swap and enable it (add to fstab to keep it)
df -iOut of inodes? (disk full with free space left)What each part does
df -iinode usage per filesystem; 100% means no new files even if space is free (millions of tiny files)
Kernel, hardware & limits8
sudo dmesg -T | tail -50Kernel messages with readable timesWhat each part does
dmesgkernel ring buffer: hardware errors, OOM killer, disk and network driver messages-Thuman-readable timestamps| tail -50the latest 50 lines
sudo dmesg -T | grep -i -E 'killed process|out of memory'Did the OOM killer kill something?What each part does
grep -i -E '...'lines where the kernel killed a process to free memory, with its name and memory use
lscpu; lspci; sudo dmidecode -t systemHardware overviewWhat each part does
lscpuCPU model, cores, threads, virtualizationlspciPCI devices: NICs, GPUs, storage controllersdmidecode -t systemvendor, model and serial number
sysctl <key>; sudo sysctl -w <key>=<value>Read and change kernel parametersCautionWhat each part does
sysctl <key>e.g. vm.swappiness, net.ipv4.ip_forward, fs.file-maxsysctl -w <key>=<value>change it now; put it in /etc/sysctl.d/*.conf to keep it after reboot
ulimit -n; cat /proc/<pid>/limitsOpen-file and process limitsWhat each part does
ulimit -nmax open files for this shell (Too many open files means you hit it)/proc/<pid>/limitsthe actual limits of a running process (systemd services set LimitNOFILE)
lsmod | grep <module>; sudo modprobe <module>Kernel modulesWhat each part does
lsmodloaded modulesmodprobe <module>load a module with its dependencies (e.g. br_netfilter for Kubernetes)
timedatectlTime, timezone and NTP syncWhat each part does
timedatectllocal time, UTC, timezone and whether the clock is NTP-synchronized (clock skew breaks TLS and tokens)
uptimeUptime and load averageWhat each part does
uptimehow long since boot, users, and 1/5/15-minute load averages (compare with CPU count)
Performance & tracing10
vmstat 1 5CPU, memory, swap and I/O wait every secondWhat each part does
vmstatr (run queue), free memory, si/so (swapping), wa (I/O wait), us/sy/id CPU1 5every 1 second, 5 times (the first line is the average since boot)
iostat -xz 1Disk I/O per deviceWhat each part does
iostatdisk statistics (sysstat package)-xextended: %util, await (latency), r/s, w/s-zhide idle devices1refresh every second
mpstat -P ALL 1CPU usage per coreWhat each part does
mpstatCPU statistics (sysstat)-P ALLevery core, to spot one core at 100%1every second
pidstat -u -r -d 1CPU, memory and I/O per process over timeWhat each part does
pidstatper-process statistics (sysstat)-u -r -dCPU, memory (faults, RSS) and disk I/O1every second
sudo iotop -oPaWhich processes do the most disk I/O?What each part does
iotoptop for disk I/O-oonly processes actually doing I/O-Pper process, not per thread-aaccumulated totals
ps -eo pid,user,%mem,rss,cmd --sort=-rss | head -15Top memory usersWhat each part does
ps -eo ...pick columns: PID, user, % of RAM, resident memory in KB, command--sort=-rssbiggest memory first| head -15top 14 plus the header
sudo strace -f -tt -p <pid> -e trace=network,fileTrace what a process is doing (system calls)What each part does
strace -p <pid>attach to a running process-ffollow its threads and children-tttimestamps with microseconds-e trace=network,fileonly network and file calls (drop it to see everything)
Tip Slows the process down a lot; use briefly in production.
sudo perf topLive CPU profile of the whole systemWhat each part does
perf topfunctions using the most CPU right now, across kernel and user space
sar -n DEV 1Network traffic per interfaceWhat each part does
sar -n DEVpackets and KB per second per interface (sysstat)1every second; sar without a count reads history if sysstat collection is enabled
watch -n 2 -d '<command>'Re-run a command every few secondsWhat each part does
watchrun the command repeatedly, full-screen-n 2every 2 seconds-dhighlight what changed
TLS & certificates (openssl)8
openssl s_client -connect <host>:443 -servername <host> -showcerts </dev/nullShow a server's certificate and chainWhat each part does
s_client -connect <host>:443open a TLS connection-servername <host>send SNI, so you get the right certificate on shared IPs-showcertsprint every certificate the server sends</dev/nullclose the connection right after the handshake
openssl s_client -connect <host>:443 -servername <host> </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -datesWhen does a site's certificate expire?What each part does
openssl s_client ...fetch the certificate| openssl x509 -nooutparse it without printing the encoded certificate-subject -issuer -dateswho it is for, who signed it, notBefore and notAfter
openssl x509 -in <cert>.pem -noout -textRead a certificate fileWhat each part does
x509 -in <cert>.pema PEM certificate file-noout -textfull details: subject, SANs (DNS names), validity, key size
openssl x509 -noout -pubkey -in <cert>.pem | sha256sum; openssl pkey -pubout -in <key>.pem | sha256sumDoes this key belong to this certificate?What each part does
x509 -pubkeypublic key from the certificatepkey -puboutpublic key derived from the private keysha256sumthe two hashes must be identical
openssl req -new -newkey rsa:2048 -nodes -keyout <name>.key -out <name>.csr -subj "/CN=<domain>"Create a private key and a CSRWhat each part does
req -newnew certificate signing request-newkey rsa:2048 -nodesgenerate a 2048-bit key, not encrypted with a passphrase-keyout / -outwhere to write the key and the CSR-subj "/CN=<domain>"subject; add -addext "subjectAltName=DNS:<domain>" for SANs
openssl req -x509 -newkey rsa:2048 -nodes -days 365 -keyout <name>.key -out <name>.crt -subj "/CN=<domain>"Self-signed certificate for testingWhat each part does
req -x509output a self-signed certificate instead of a CSR-days 365valid for a year
openssl verify -CAfile <ca-bundle>.pem <cert>.pemCheck a certificate against a CA bundleWhat each part does
openssl verifyOK if the chain validates; otherwise the reason (expired, unable to get issuer)-CAfiletrusted CA and intermediates
openssl s_client -connect <host>:443 -tls1_2 </dev/null; openssl s_client -connect <host>:443 -tls1_3 </dev/nullWhich TLS versions does a server accept?What each part does
-tls1_2 / -tls1_3force one protocol version; a handshake failure means it's not supported
Packet capture & network debugging10
sudo tcpdump -i any -nn port <port>Capture traffic on a portWhat each part does
tcpdumppacket capture-i anyall interfaces-nndon't resolve names or portsport <port>filter: only traffic on that port (also host <ip>, tcp, udp)
sudo tcpdump -i <interface> -w <file>.pcap -c 10000 host <ip>Save a capture for WiresharkWhat each part does
-w <file>.pcapwrite raw packets to a file-c 10000stop after 10,000 packetshost <ip>only traffic to or from this IP
ip route get <ip>Which route and source IP would be used?What each part does
ip route getthe exact route, gateway, interface and source address the kernel would use
mtr -rwc 50 <host>Path and packet loss to a hostWhat each part does
mtrtraceroute and ping combined, per hop-r -wreport mode with wide (untruncated) host names-c 5050 probes per hop
nmap -Pn -p 1-1024 <host>Scan a host's open portsWhat each part does
nmapport scanner (only scan hosts you're allowed to)-Pnskip the ping check (many hosts block ping)-p 1-1024port range (or -p 22,80,443)
ss -sSocket summaryWhat each part does
ss -stotals of TCP states: established, time-wait, orphaned; spot connection leaks
ss -tn state established | awk 'NR>1 {split($4,a,":"); print a[1]}' | sort | uniq -c | sort -rn | headConnections per remote IPWhat each part does
ss -tn state establishedopen TCP connections, numericawk '...'take the peer address column and strip the portsort | uniq -c | sort -rn | headcount per IP, busiest first
ip neighARP / neighbour tableWhat each part does
ip neighIP to MAC mappings; FAILED or INCOMPLETE entries point to layer 2 problems
curl -sv --resolve <host>:443:<ip> https://<host>/Test a URL against a specific IP (skip DNS)What each part does
--resolve <host>:443:<ip>use this IP for that host and port, keeping the right SNI and Host header-svquiet progress, verbose headers and TLS
nc -l <port>Listen on a port to test reachabilityWhat each part does
nc -l <port>listen; from another machine nc -zv <host> <port> or curl shows whether traffic gets through
Terminal tools (tmux, jq, background jobs)8
tmux new -A -s <name>Start or reattach a tmux sessionWhat each part does
tmux new -s <name>new named session that survives SSH disconnects-Aattach instead if it already exists
Tip Detach with Ctrl+B then D; list with tmux ls.
<command> | jq '.items[] | {name: .metadata.name, phase: .status.phase}'Pretty-print and filter JSONWhat each part does
| jq '...'JSON processor.items[]iterate over an array{name: ..., phase: ...}build a smaller object with just those fields
jq -r '.[] | select(.state=="running") | .name' <file>.jsonRaw values from JSON for scriptsWhat each part does
-rraw strings, no quotesselect(.state=="running")keep only matching items.nameprint one field
yq '.spec.replicas' <file>.yaml; yq -i '.spec.replicas = 3' <file>.yamlRead or edit YAMLWhat each part does
yq '.path'read a value (jq syntax for YAML)yq -i '...'edit the file in place
nohup <command> > <log> 2>&1 &Keep a command running after logoutWhat each part does
nohupignore the hangup signal sent when you log out> <log> 2>&1send output and errors to a log&run in the background; jobs and fg to manage it
timeout 30s <command>Stop a command that runs too longWhat each part does
timeout 30skill the command after 30 seconds; exit code 124 if it timed out
cat <list> | xargs -P 8 -I{} <command> {}Run commands in parallelWhat each part does
xargs -P 8up to 8 at a time-I{}replace {} in the command with each input line
until <command>; do echo retrying; sleep 5; doneRetry a command until it succeedsWhat each part does
until <command>loop while the command failssleep 5wait between attempts
Nothing matches.
My DevOps Playbook by Angelo John Calleja