Where Am I? / Help
pwdPrint the current working directory.
whoamiShow the current user name.
idShow user ID, group ID, and group memberships.
echo $SHELLShow the configured login shell.
echo $0Show the current shell/process name in many shells.
command -v nameShow which executable or command definition will run.
type nameShow whether a name is an alias, builtin, function, or executable.
type -a nameShow all matching command locations/definitions.
man commandOpen the manual page for a command.
command --helpShow built-in CLI help when supported.
apropos keywordSearch manual-page descriptions by keyword.
info commandOpen GNU Info documentation where installed.
historyShow recent shell commands.
clearClear the terminal display.
List & Inspect
lsList directory contents.
ls -lLong listing with permissions, owner, size, and time.
ls -laLong listing including hidden files.
ls -lhUse human-readable file sizes.
ls -ltSort newest modified items first.
ls -lSSort largest items first.
stat fileShow detailed metadata for a file or directory.
file nameIdentify a file's content/type.
realpath pathResolve an absolute canonical path.
basename pathReturn the final path component.
dirname pathReturn the parent directory portion.
Create, Copy & Move
mkdir folderCreate a directory.
mkdir -p a/b/cCreate nested directories as needed.
touch file.txtCreate an empty file or update its timestamp.
cp source destCopy a file.
cp -i source destPrompt before overwriting.
cp -a source destArchive-style copy preserving attributes and directories.
cp -r dir destCopy a directory tree recursively.
mv old newMove or rename a file or directory.
mv -i old newPrompt before overwriting a destination.
Delete Carefully
rm fileDelete a file.
rm -i filePrompt before deleting.
rmdir empty-dirRemove an empty directory.
rm -r folderDelete a directory tree recursively.
rm -rf folderForce-delete a directory tree. Verify the path first.
find path -deleteDelete matched files directly; inspect the matches before adding -delete.
trash-put fileMove to a trash location when trash-cli is installed.
Links
ln target linknameCreate a hard link.
ln -s target linknameCreate a symbolic link.
readlink linkShow a symbolic link's target.
readlink -f linkResolve the final absolute target where supported.
find . -type lFind symbolic links.
Read files, search recursively, filter text, transform streams, and compose commands with pipes and redirection.
02 — Read, Search & Text Processing
Read Files
cat filePrint an entire small file.
less fileOpen a scrollable pager.
more filePage through text using a simpler pager.
head fileShow the first 10 lines.
head -n 20 fileShow the first 20 lines.
tail fileShow the last 10 lines.
tail -n 20 fileShow the last 20 lines.
tail -f app.logFollow new lines appended to a growing log.
nl -ba filePrint lines with line numbers, including blank lines.
grep
grep 'text' fileFind matching lines.
grep -n 'text' fileInclude line numbers.
grep -i 'text' fileSearch case-insensitively.
grep -v 'text' fileShow lines that do not match.
grep -E 'regex' fileUse extended regular expressions.
grep -R 'text' dirSearch recursively.
grep -Rni 'text' .Recursive, case-insensitive search with line numbers.
grep -l 'text' *.logPrint only matching file names.
grep -c 'text' fileCount matching lines.
find
find . -name '*.js'Find items by case-sensitive name pattern.
find . -iname '*.jpg'Find items by case-insensitive name pattern.
find . -type fFind files.
find . -type dFind directories.
find . -type lFind symbolic links.
find . -mtime -1Find items modified within roughly the last day.
find . -size +100MFind files larger than 100 MiB units used by find.
find . -emptyFind empty files and directories.
find . -perm /111Find files with any execute bit set on GNU find.
find . -exec command {} \;Run a command once per match.
find . -exec command {} +Run a command with batches of matches.
sort, uniq, cut & paste
sort fileSort lines.
sort -n fileSort numerically.
sort -r fileReverse the sort order.
sort -u fileSort and remove duplicates.
uniq fileCollapse adjacent duplicate lines.
uniq -c fileCount adjacent duplicate lines.
cut -d, -f1 file.csvSelect fields using a delimiter.
paste file1 file2Merge files line-by-line.
column -t fileAlign whitespace-separated columns into a table where installed.
wc, tr, tee & xargs
wc -l fileCount lines.
wc -w fileCount words.
wc -c fileCount bytes.
tr 'a-z' 'A-Z'Translate characters from one set to another.
tr -d '\r'Delete carriage-return characters.
tee fileCopy standard input to both screen and file.
tee -a fileAppend standard input to a file while also displaying it.
xargs commandBuild command arguments from standard input.
xargs -0 commandRead NUL-separated input, useful with find -print0.
sed Quick Patterns
sed 's/old/new/' fileReplace the first match on each line.
sed 's/old/new/g' fileReplace every match on each line.
sed -n '10,20p' filePrint only lines 10 through 20.
sed '/pattern/d' fileRemove matching lines from output.
sed -E 's/(a|b)/x/g' fileUse extended regular expressions.
sed -i.bak 's/old/new/g' fileEdit in place while creating a backup; -i syntax varies across GNU/BSD sed.
awk Quick Patterns
awk '{print $1}' filePrint the first whitespace-separated field.
awk -F, '{print $1}' file.csvUse a comma field separator.
awk '$3 > 100 {print $1,$3}' fileFilter rows by a field condition.
awk '{sum += $1} END {print sum}' fileAccumulate and print a total.
awk 'NR==1 || /text/' filePrint the first row plus matching rows.
Pipes & Redirection
a | bPipe standard output of a into standard input of b.
a > fileOverwrite a file with standard output.
a >> fileAppend standard output to a file.
a 2> errors.logRedirect standard error.
a 2>> errors.logAppend standard error.
a > all.log 2>&1Send standard output and error to one file.
a < input.txtUse a file as standard input.
a && bRun b only if a succeeds.
a || bRun b only if a fails.
a ; bRun sequentially regardless of success.
$(command)Substitute command output into another command.
Ownership & ACLs
chown user fileChange file owner.
chown user:group fileChange owner and group.
chgrp group fileChange group ownership.
chown -R user:group dirChange ownership recursively.
getfacl fileDisplay POSIX ACLs where the ACL tools are installed.
setfacl -m u:user:rwx fileAdd or modify an ACL entry.
setfacl -x u:user fileRemove a specific ACL entry.
sudo & Privilege
sudo commandRun one command with elevated privileges.
sudo -iOpen a root login shell.
sudo -u user commandRun a command as another user.
sudo -lList allowed sudo commands for the current user.
visudoSafely edit sudoers with syntax checking.
su - userSwitch to another user with a login shell.
Users
whoShow logged-in users.
wShow logged-in users and what they are doing.
lastShow recent login history.
id userShow a user's UID, GID, and groups.
getent passwd userQuery the user-account database.
useradd nameCreate a user on distributions using shadow-utils.
adduser nameFriendly user-creation wrapper on Debian-family systems.
usermod -aG group userAdd a user to a supplementary group.
userdel userDelete a user account; options control home-data removal.
passwd userSet or change a user's password.
Groups
groupsShow the current user's groups.
groups userShow another user's group memberships.
getent group groupQuery group information.
groupadd groupCreate a group.
groupdel groupDelete a group.
gpasswd -a user groupAdd a user to a group.
gpasswd -d user groupRemove a user from a group.
newgrp groupStart a shell using a different primary group for the session.
Environment Variables
printenvList environment variables.
printenv NAMEPrint one environment variable.
envDisplay the environment or run a command with modified environment values.
echo $PATHShow the executable search path.
export NAME=valueSet and export a variable for the current shell session.
NAME=value commandSet an environment variable for one command only.
unset NAMERemove a shell variable/environment variable.
env -i commandRun a command with an almost-empty environment.
Shell Startup & Aliases
~/.bashrcCommon interactive Bash configuration file.
~/.bash_profileCommon Bash login-shell configuration file.
~/.profilePortable login environment file used by many setups.
source ~/.bashrcReload Bash configuration in the current shell.
. ~/.profileSource a shell configuration file using POSIX dot syntax.
aliasList aliases.
alias ll='ls -lah'Create a session alias.
unalias llRemove an alias.
function name() { ...; }Define a reusable shell function in Bash-style syntax.
Inspect running processes, control jobs and signals, manage systemd services, read logs, and schedule recurring work.
04 — Processes, Services, Logs & Scheduling
Process Inspection
psShow processes attached to the current terminal.
ps auxShow a broad process list in BSD-style format.
ps -efShow a broad process list in POSIX/System V-style format.
pgrep nameFind process IDs by name.
pgrep -af patternShow matching PIDs with full command lines.
pidof programShow PIDs for a program where available.
topInteractive live process and resource viewer.
htopEnhanced interactive process viewer when installed.
pstreeDisplay processes as a parent/child tree.
Signals & Stop
kill PIDSend SIGTERM, requesting a clean stop.
kill -TERM PIDExplicitly send SIGTERM.
kill -HUP PIDSend SIGHUP; many daemons use it to reload configuration.
kill -9 PIDSend SIGKILL. Force termination; last resort.
killall nameSignal processes by executable name.
pkill patternSignal processes matching a name/pattern.
trap '...' SIGNALHandle signals in a shell script.
Foreground & Background Jobs
command &Start a command in the background.
jobsList jobs started by the current shell.
fg %1Bring job 1 to the foreground.
bg %1Continue a stopped job in the background.
Ctrl+ZSuspend the foreground process.
Ctrl+CInterrupt the foreground process.
nohup command &Keep a command running after terminal disconnect, writing output to nohup.out by default.
disown %1Remove a job from the shell's job table so it is not sent SIGHUP by that shell.
systemd Services
systemctl status serviceShow service state and recent log lines.
sudo systemctl start serviceStart a service now.
sudo systemctl stop serviceStop a service now.
sudo systemctl restart serviceRestart a service.
sudo systemctl reload serviceReload service configuration when supported.
sudo systemctl enable serviceEnable service startup at boot.
sudo systemctl disable serviceDisable service startup at boot.
systemctl is-active serviceCheck whether a service is currently active.
systemctl is-enabled serviceCheck whether a service is enabled at boot.
systemctl list-units --type=serviceList loaded service units.
systemctl daemon-reloadReload unit definitions after editing unit files.
journalctl
journalctlRead the systemd journal.
journalctl -u serviceShow logs for one service/unit.
journalctl -u service -fFollow logs for one service.
journalctl -bShow logs from the current boot.
journalctl -b -1Show logs from the previous boot.
journalctl --since todayShow entries since today.
journalctl --since '1 hour ago'Show recent entries using a relative time.
journalctl -p errShow error-priority messages.
journalctl --disk-usageShow journal disk usage.
Traditional Logs
ls /var/logList traditional system log files.
tail -f /var/log/syslogFollow Debian/Ubuntu-style system log where present.
tail -f /var/log/messagesFollow RHEL-family/general system log where present.
dmesgRead kernel ring-buffer messages.
dmesg -TShow kernel messages with human-readable timestamps where supported.
cron & Timers
crontab -eEdit the current user's cron schedule.
crontab -lList the current user's cron entries.
crontab -rRemove the current user's crontab; use carefully.
systemctl list-timersList systemd timers.
OnCalendar=systemd timer directive for calendar-style schedules.
Persistent=truesystemd timer option allowing missed runs to execute after downtime.
at 17:00Schedule a one-time command where the at service is installed.
atq / atrm IDList or remove queued at jobs.
Inspect interfaces and routes, diagnose DNS and ports, test HTTP, connect with SSH, and transfer or synchronize files.
05 — Networking, SSH & Remote Work
Interfaces & Addresses
ip addrShow network interfaces and IP addresses.
ip -br addrShow a compact interface/address summary.
ip linkShow network interfaces and link state.
ip routeShow the routing table.
hostnameShow the system hostname.
hostname -IShow assigned IP addresses where supported.
nmcli device statusShow NetworkManager device status where NetworkManager is used.
nmcli connection showList NetworkManager connections.
Connectivity
ping hostTest ICMP reachability.
ping -c 4 hostSend four ICMP echo requests.
traceroute hostTrace the route to a host when installed.
tracepath hostTrace path without requiring the same privileges as traditional traceroute on many Linux systems.
mtr hostInteractive combined ping/traceroute diagnostics when installed.
nc -vz host 443Test whether a TCP port is reachable.
timeout 5 bash -c 'Bash-specific TCP reachability test without netcat.
DNS
dig example.comQuery DNS records.
dig +short example.comReturn compact DNS answers.
dig MX example.comQuery mail-exchanger records.
nslookup example.comTraditional DNS lookup tool.
host example.comSimple DNS lookup utility.
resolvectl statusInspect systemd-resolved DNS configuration where used.
cat /etc/resolv.confInspect resolver configuration or resolver stub details.
Ports & Sockets
ss -tulpnList listening TCP/UDP sockets with process information where permitted.
ss -ltnList listening TCP sockets.
ss -tunapShow TCP/UDP sockets broadly with process information where permitted.
lsof -i :3000Find processes using port 3000 when lsof is installed.
fuser 3000/tcpShow processes using a TCP port.
sudo fuser -k 3000/tcpKill processes using a TCP port; use carefully.
curl & wget
curl URLSend an HTTP GET request and print the response body.
curl -I URLRequest headers only.
curl -L URLFollow redirects.
curl -o file URLSave a response to a named file.
curl -O URLSave using the remote filename.
curl -X POST -H 'Content-Type: application/json' -d '{...}' URLSend a JSON POST request.
curl -v URLShow verbose request/connection diagnostics.
wget URLDownload a URL to a file.
wget -c URLContinue a partially downloaded file where supported.
SSH
ssh user@hostOpen an SSH session.
ssh -p 2222 user@hostConnect using a non-default SSH port.
ssh -i key user@hostConnect using a specific identity/private key.
ssh-keygen -t ed25519 -C 'email'Create an Ed25519 SSH key pair.
ssh-add ~/.ssh/id_ed25519Add a private key to the SSH agent.
ssh -T git@github.comTest SSH authentication to GitHub.
ssh-copy-id user@hostInstall your public key on a remote host where the helper is available.
~/.ssh/configPer-user SSH host aliases and connection options.
scp & rsync
scp file user@host:/pathCopy one file over SSH.
scp -r dir user@host:/pathCopy a directory recursively over SSH.
rsync -av src/ dest/Archive-style local synchronization.
rsync -av src/ host:/dest/Synchronize a directory to a remote host.
rsync -av --delete src/ dest/Make destination mirror source by deleting extra destination files; review carefully.
rsync -avP src/ dest/Show progress and preserve partially transferred files.
rsync -n ...Dry-run an rsync command before making changes.
Firewall Quick Reference
sudo ufw statusShow UFW status on systems using UFW.
sudo ufw allow 22/tcpAllow SSH through UFW.
sudo firewall-cmd --list-allShow firewalld configuration on systems using firewalld.
sudo firewall-cmd --add-service=http --permanentPermanently allow HTTP in firewalld.
sudo firewall-cmd --reloadReload permanent firewalld configuration.
nft list rulesetInspect nftables rules where nftables is used.
Manage software, disks, filesystems, archives, system identity, resources, and common Linux troubleshooting.
06 — Packages, Storage, Archives & Recovery
APT ↔ DNF ↔ Pacman
sudo apt updateRefresh package metadata.
sudo dnf check-updatesudo apt install pkgInstall a package.
sudo dnf install pkgsudo apt remove pkgRemove a package.
sudo dnf remove pkgsudo apt upgradeUpgrade installed packages.
sudo dnf upgradeapt search pkgSearch packages.
dnf search pkgapt show pkgShow package information.
dnf info pkgdpkg -lList installed packages using the low-level Debian package tool.
rpm -qaPacman Notes
sudo pacman -SyuArch Linux: refresh package databases and perform a full system upgrade.
sudo pacman -S pkgArch Linux: install a package.
sudo pacman -Rns pkgArch Linux: remove a package plus unused dependencies/config where applicable.
pacman -Ss pkgArch Linux: search repositories.
pacman -Qi pkgArch Linux: show installed package information.
Disk Usage
df -hShow mounted filesystem space in human-readable units.
df -iShow inode usage.
du -sh folderShow total apparent disk usage for a folder.
du -sh *Show sizes of items in the current directory.
du -ah . | sort -h | tailFind larger files/directories under the current path.
lsblkShow block devices and mount relationships.
blkidShow filesystem UUIDs and types where permitted.
Mounts & Filesystems
mountList mounted filesystems.
findmntShow mounts in a structured tree.
sudo mount /dev/sdb1 /mnt/dataMount a filesystem.
sudo umount /mnt/dataUnmount a filesystem.
cat /etc/fstabInspect configured persistent mounts.
sudo fdisk -lList disk partition information.
sudo parted -lList disks and partition tables using parted.
fsck deviceCheck/repair an unmounted filesystem; exact tool/options depend on filesystem.
Archives & Compression
tar -cf archive.tar folderCreate a tar archive.
tar -tf archive.tarList tar archive contents.
tar -xf archive.tarExtract a tar archive.
tar -czf archive.tar.gz folderCreate a gzip-compressed tar archive.
tar -xzf archive.tar.gzExtract a gzip-compressed tar archive.
tar -cJf archive.tar.xz folderCreate an xz-compressed tar archive.
gzip fileCompress one file with gzip.
gunzip file.gzDecompress a gzip file.
zip -r archive.zip folderCreate a ZIP archive when zip is installed.
unzip archive.zipExtract a ZIP archive.
System & Resource Info
uname -aShow kernel and system information.
uname -rShow the kernel release.
cat /etc/os-releaseShow distribution identification.
hostnamectlShow hostname and system metadata on systemd systems.
uptimeShow uptime and load averages.
free -hShow memory and swap usage.
lscpuShow CPU architecture details.
lsmemShow memory block information where available.
lsusbList USB devices.
lspciList PCI devices.
Kernel & Boot
dmesg | lessInspect kernel messages.
journalctl -kShow kernel journal entries on systemd systems.
systemctl --failedList failed systemd units.
systemctl get-defaultShow the default systemd target.
systemctl rebootReboot through systemd.
systemctl poweroffPower off through systemd.
rebootReboot using the traditional command; privileges may be required.
shutdown -h nowShut down immediately.
shutdown -r +10Schedule a reboot in 10 minutes.
Fast Troubleshooting Loop
pwd && ls -laConfirm location and visible project files.
whoami && idConfirm the current identity and groups.
command -v tool && tool --versionConfirm a required CLI exists and which version is active.
printenv | sortInspect environment values.
df -h && free -hCheck disk and memory pressure.
ps aux | headCheck process state quickly.
ss -tulpnCheck listeners and port conflicts.
systemctl --failedFind failed services.
journalctl -p err -bReview current-boot errors.
curl -I http://localhost:PORTConfirm a local HTTP service responds.
High-Risk Commands
rm -rf PATHPermanently removes a directory tree. Verify pwd and the exact path first.
sudo commandRuns with elevated privileges; system-wide damage is possible.
chmod -R / chown -RRecursive permission/ownership changes can break applications and services.
dd if=... of=...Raw block copying can overwrite disks. Verify the output device before running.
mkfs.* deviceCreates a new filesystem and destroys existing filesystem data on the target.
fsck -yAutomatic repair can modify filesystem structures; use appropriate recovery procedures.
apt/dnf/pacman full upgradesLarge upgrades can change runtimes, services, kernels, and dependencies.
shutdown / rebootEnds current sessions and running work.