DEVELOPER SANDBOX Academy of Mastery
WelcomeBuild · Explore · Create SD
REFERENCE GUIDE

Linux Command Reference

Linux shell / CLI
Linux cmds

Orient yourself, move through the filesystem, inspect files, and perform safe everyday file operations.

Panel 1 / 6

01 — Shell, Navigation & Files

Shell, Navigation & Files

Where Am I? / Help

pwd
Print the current working directory.
whoami
Show the current user name.
id
Show user ID, group ID, and group memberships.
echo $SHELL
Show the configured login shell.
echo $0
Show the current shell/process name in many shells.
command -v name
Show which executable or command definition will run.
type name
Show whether a name is an alias, builtin, function, or executable.
type -a name
Show all matching command locations/definitions.
man command
Open the manual page for a command.
command --help
Show built-in CLI help when supported.
apropos keyword
Search manual-page descriptions by keyword.
info command
Open GNU Info documentation where installed.
history
Show recent shell commands.
clear
Clear the terminal display.
Shell, Navigation & Files

Navigation

cd path
Change to a directory.
cd ..
Move up one directory.
cd ~
Move to the current user's home directory.
cd -
Return to the previous working directory.
pushd path
Save the current directory and move to another.
popd
Return to the most recently pushed directory.
dirs -v
Show the directory stack with indexes.
Shell, Navigation & Files

List & Inspect

ls
List directory contents.
ls -l
Long listing with permissions, owner, size, and time.
ls -la
Long listing including hidden files.
ls -lh
Use human-readable file sizes.
ls -lt
Sort newest modified items first.
ls -lS
Sort largest items first.
stat file
Show detailed metadata for a file or directory.
file name
Identify a file's content/type.
realpath path
Resolve an absolute canonical path.
basename path
Return the final path component.
dirname path
Return the parent directory portion.
Shell, Navigation & Files

Create, Copy & Move

mkdir folder
Create a directory.
mkdir -p a/b/c
Create nested directories as needed.
touch file.txt
Create an empty file or update its timestamp.
cp source dest
Copy a file.
cp -i source dest
Prompt before overwriting.
cp -a source dest
Archive-style copy preserving attributes and directories.
cp -r dir dest
Copy a directory tree recursively.
mv old new
Move or rename a file or directory.
mv -i old new
Prompt before overwriting a destination.
Shell, Navigation & Files

Delete Carefully

rm file
Delete a file.
rm -i file
Prompt before deleting.
rmdir empty-dir
Remove an empty directory.
rm -r folder
Delete a directory tree recursively.
rm -rf folder
Force-delete a directory tree. Verify the path first.
find path -delete
Delete matched files directly; inspect the matches before adding -delete.
trash-put file
Move to a trash location when trash-cli is installed.

Read files, search recursively, filter text, transform streams, and compose commands with pipes and redirection.

Panel 2 / 6

02 — Read, Search & Text Processing

Read, Search & Text Processing

Read Files

cat file
Print an entire small file.
less file
Open a scrollable pager.
more file
Page through text using a simpler pager.
head file
Show the first 10 lines.
head -n 20 file
Show the first 20 lines.
tail file
Show the last 10 lines.
tail -n 20 file
Show the last 20 lines.
tail -f app.log
Follow new lines appended to a growing log.
nl -ba file
Print lines with line numbers, including blank lines.
Read, Search & Text Processing

grep

grep 'text' file
Find matching lines.
grep -n 'text' file
Include line numbers.
grep -i 'text' file
Search case-insensitively.
grep -v 'text' file
Show lines that do not match.
grep -E 'regex' file
Use extended regular expressions.
grep -R 'text' dir
Search recursively.
grep -Rni 'text' .
Recursive, case-insensitive search with line numbers.
grep -l 'text' *.log
Print only matching file names.
grep -c 'text' file
Count matching lines.
Read, Search & Text Processing

find

find . -name '*.js'
Find items by case-sensitive name pattern.
find . -iname '*.jpg'
Find items by case-insensitive name pattern.
find . -type f
Find files.
find . -type d
Find directories.
find . -type l
Find symbolic links.
find . -mtime -1
Find items modified within roughly the last day.
find . -size +100M
Find files larger than 100 MiB units used by find.
find . -empty
Find empty files and directories.
find . -perm /111
Find 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.
Read, Search & Text Processing

sort, uniq, cut & paste

sort file
Sort lines.
sort -n file
Sort numerically.
sort -r file
Reverse the sort order.
sort -u file
Sort and remove duplicates.
uniq file
Collapse adjacent duplicate lines.
uniq -c file
Count adjacent duplicate lines.
cut -d, -f1 file.csv
Select fields using a delimiter.
paste file1 file2
Merge files line-by-line.
column -t file
Align whitespace-separated columns into a table where installed.
Read, Search & Text Processing

wc, tr, tee & xargs

wc -l file
Count lines.
wc -w file
Count words.
wc -c file
Count bytes.
tr 'a-z' 'A-Z'
Translate characters from one set to another.
tr -d '\r'
Delete carriage-return characters.
tee file
Copy standard input to both screen and file.
tee -a file
Append standard input to a file while also displaying it.
xargs command
Build command arguments from standard input.
xargs -0 command
Read NUL-separated input, useful with find -print0.
Read, Search & Text Processing

sed Quick Patterns

sed 's/old/new/' file
Replace the first match on each line.
sed 's/old/new/g' file
Replace every match on each line.
sed -n '10,20p' file
Print only lines 10 through 20.
sed '/pattern/d' file
Remove matching lines from output.
sed -E 's/(a|b)/x/g' file
Use extended regular expressions.
sed -i.bak 's/old/new/g' file
Edit in place while creating a backup; -i syntax varies across GNU/BSD sed.
Read, Search & Text Processing

awk Quick Patterns

awk '{print $1}' file
Print the first whitespace-separated field.
awk -F, '{print $1}' file.csv
Use a comma field separator.
awk '$3 > 100 {print $1,$3}' file
Filter rows by a field condition.
awk '{sum += $1} END {print sum}' file
Accumulate and print a total.
awk 'NR==1 || /text/' file
Print the first row plus matching rows.
Read, Search & Text Processing

Pipes & Redirection

a | b
Pipe standard output of a into standard input of b.
a > file
Overwrite a file with standard output.
a >> file
Append standard output to a file.
a 2> errors.log
Redirect standard error.
a 2>> errors.log
Append standard error.
a > all.log 2>&1
Send standard output and error to one file.
a < input.txt
Use a file as standard input.
a && b
Run b only if a succeeds.
a || b
Run b only if a fails.
a ; b
Run sequentially regardless of success.
$(command)
Substitute command output into another command.

Control permissions, ownership, users, groups, environment variables, shell startup files, aliases, and sudo.

Panel 3 / 6

03 — Permissions, Users & Shell Environment

Permissions, Users & Shell Environment

Permission Bits

ls -l
Inspect permission bits and ownership.
chmod +x script.sh
Add execute permission.
chmod u+x file
Add execute permission for the owner.
chmod go-rwx file
Remove all permissions from group and others.
chmod 644 file
Owner read/write; group and others read.
chmod 755 file
Owner read/write/execute; group and others read/execute.
chmod 700 file
Owner-only read/write/execute.
chmod -R mode dir
Apply permission changes recursively; use carefully.
umask
Show the current file-creation mask.
umask 022
Set a common mask producing 755 directories and 644 files from standard defaults.
Permissions, Users & Shell Environment

Ownership & ACLs

chown user file
Change file owner.
chown user:group file
Change owner and group.
chgrp group file
Change group ownership.
chown -R user:group dir
Change ownership recursively.
getfacl file
Display POSIX ACLs where the ACL tools are installed.
setfacl -m u:user:rwx file
Add or modify an ACL entry.
setfacl -x u:user file
Remove a specific ACL entry.
Permissions, Users & Shell Environment

sudo & Privilege

sudo command
Run one command with elevated privileges.
sudo -i
Open a root login shell.
sudo -u user command
Run a command as another user.
sudo -l
List allowed sudo commands for the current user.
visudo
Safely edit sudoers with syntax checking.
su - user
Switch to another user with a login shell.
Permissions, Users & Shell Environment

Users

who
Show logged-in users.
w
Show logged-in users and what they are doing.
last
Show recent login history.
id user
Show a user's UID, GID, and groups.
getent passwd user
Query the user-account database.
useradd name
Create a user on distributions using shadow-utils.
adduser name
Friendly user-creation wrapper on Debian-family systems.
usermod -aG group user
Add a user to a supplementary group.
userdel user
Delete a user account; options control home-data removal.
passwd user
Set or change a user's password.
Permissions, Users & Shell Environment

Groups

groups
Show the current user's groups.
groups user
Show another user's group memberships.
getent group group
Query group information.
groupadd group
Create a group.
groupdel group
Delete a group.
gpasswd -a user group
Add a user to a group.
gpasswd -d user group
Remove a user from a group.
newgrp group
Start a shell using a different primary group for the session.
Permissions, Users & Shell Environment

Environment Variables

printenv
List environment variables.
printenv NAME
Print one environment variable.
env
Display the environment or run a command with modified environment values.
echo $PATH
Show the executable search path.
export NAME=value
Set and export a variable for the current shell session.
NAME=value command
Set an environment variable for one command only.
unset NAME
Remove a shell variable/environment variable.
env -i command
Run a command with an almost-empty environment.
Permissions, Users & Shell Environment

Shell Startup & Aliases

~/.bashrc
Common interactive Bash configuration file.
~/.bash_profile
Common Bash login-shell configuration file.
~/.profile
Portable login environment file used by many setups.
source ~/.bashrc
Reload Bash configuration in the current shell.
. ~/.profile
Source a shell configuration file using POSIX dot syntax.
alias
List aliases.
alias ll='ls -lah'
Create a session alias.
unalias ll
Remove 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.

Panel 4 / 6

04 — Processes, Services, Logs & Scheduling

Processes, Services, Logs & Scheduling

Process Inspection

ps
Show processes attached to the current terminal.
ps aux
Show a broad process list in BSD-style format.
ps -ef
Show a broad process list in POSIX/System V-style format.
pgrep name
Find process IDs by name.
pgrep -af pattern
Show matching PIDs with full command lines.
pidof program
Show PIDs for a program where available.
top
Interactive live process and resource viewer.
htop
Enhanced interactive process viewer when installed.
pstree
Display processes as a parent/child tree.
Processes, Services, Logs & Scheduling

Signals & Stop

kill PID
Send SIGTERM, requesting a clean stop.
kill -TERM PID
Explicitly send SIGTERM.
kill -HUP PID
Send SIGHUP; many daemons use it to reload configuration.
kill -9 PID
Send SIGKILL. Force termination; last resort.
killall name
Signal processes by executable name.
pkill pattern
Signal processes matching a name/pattern.
trap '...' SIGNAL
Handle signals in a shell script.
Processes, Services, Logs & Scheduling

Foreground & Background Jobs

command &
Start a command in the background.
jobs
List jobs started by the current shell.
fg %1
Bring job 1 to the foreground.
bg %1
Continue a stopped job in the background.
Ctrl+Z
Suspend the foreground process.
Ctrl+C
Interrupt the foreground process.
nohup command &
Keep a command running after terminal disconnect, writing output to nohup.out by default.
disown %1
Remove a job from the shell's job table so it is not sent SIGHUP by that shell.
Processes, Services, Logs & Scheduling

systemd Services

systemctl status service
Show service state and recent log lines.
sudo systemctl start service
Start a service now.
sudo systemctl stop service
Stop a service now.
sudo systemctl restart service
Restart a service.
sudo systemctl reload service
Reload service configuration when supported.
sudo systemctl enable service
Enable service startup at boot.
sudo systemctl disable service
Disable service startup at boot.
systemctl is-active service
Check whether a service is currently active.
systemctl is-enabled service
Check whether a service is enabled at boot.
systemctl list-units --type=service
List loaded service units.
systemctl daemon-reload
Reload unit definitions after editing unit files.
Processes, Services, Logs & Scheduling

journalctl

journalctl
Read the systemd journal.
journalctl -u service
Show logs for one service/unit.
journalctl -u service -f
Follow logs for one service.
journalctl -b
Show logs from the current boot.
journalctl -b -1
Show logs from the previous boot.
journalctl --since today
Show entries since today.
journalctl --since '1 hour ago'
Show recent entries using a relative time.
journalctl -p err
Show error-priority messages.
journalctl --disk-usage
Show journal disk usage.
Processes, Services, Logs & Scheduling

Traditional Logs

ls /var/log
List traditional system log files.
tail -f /var/log/syslog
Follow Debian/Ubuntu-style system log where present.
tail -f /var/log/messages
Follow RHEL-family/general system log where present.
dmesg
Read kernel ring-buffer messages.
dmesg -T
Show kernel messages with human-readable timestamps where supported.
Processes, Services, Logs & Scheduling

cron & Timers

crontab -e
Edit the current user's cron schedule.
crontab -l
List the current user's cron entries.
crontab -r
Remove the current user's crontab; use carefully.
systemctl list-timers
List systemd timers.
OnCalendar=
systemd timer directive for calendar-style schedules.
Persistent=true
systemd timer option allowing missed runs to execute after downtime.
at 17:00
Schedule a one-time command where the at service is installed.
atq / atrm ID
List or remove queued at jobs.

Inspect interfaces and routes, diagnose DNS and ports, test HTTP, connect with SSH, and transfer or synchronize files.

Panel 5 / 6

05 — Networking, SSH & Remote Work

Networking, SSH & Remote Work

Interfaces & Addresses

ip addr
Show network interfaces and IP addresses.
ip -br addr
Show a compact interface/address summary.
ip link
Show network interfaces and link state.
ip route
Show the routing table.
hostname
Show the system hostname.
hostname -I
Show assigned IP addresses where supported.
nmcli device status
Show NetworkManager device status where NetworkManager is used.
nmcli connection show
List NetworkManager connections.
Networking, SSH & Remote Work

Connectivity

ping host
Test ICMP reachability.
ping -c 4 host
Send four ICMP echo requests.
traceroute host
Trace the route to a host when installed.
tracepath host
Trace path without requiring the same privileges as traditional traceroute on many Linux systems.
mtr host
Interactive combined ping/traceroute diagnostics when installed.
nc -vz host 443
Test whether a TCP port is reachable.
timeout 5 bash -c '
Bash-specific TCP reachability test without netcat.
Networking, SSH & Remote Work

DNS

dig example.com
Query DNS records.
dig +short example.com
Return compact DNS answers.
dig MX example.com
Query mail-exchanger records.
nslookup example.com
Traditional DNS lookup tool.
host example.com
Simple DNS lookup utility.
resolvectl status
Inspect systemd-resolved DNS configuration where used.
cat /etc/resolv.conf
Inspect resolver configuration or resolver stub details.
Networking, SSH & Remote Work

Ports & Sockets

ss -tulpn
List listening TCP/UDP sockets with process information where permitted.
ss -ltn
List listening TCP sockets.
ss -tunap
Show TCP/UDP sockets broadly with process information where permitted.
lsof -i :3000
Find processes using port 3000 when lsof is installed.
fuser 3000/tcp
Show processes using a TCP port.
sudo fuser -k 3000/tcp
Kill processes using a TCP port; use carefully.
Networking, SSH & Remote Work

curl & wget

curl URL
Send an HTTP GET request and print the response body.
curl -I URL
Request headers only.
curl -L URL
Follow redirects.
curl -o file URL
Save a response to a named file.
curl -O URL
Save using the remote filename.
curl -X POST -H 'Content-Type: application/json' -d '{...}' URL
Send a JSON POST request.
curl -v URL
Show verbose request/connection diagnostics.
wget URL
Download a URL to a file.
wget -c URL
Continue a partially downloaded file where supported.
Networking, SSH & Remote Work

SSH

ssh user@host
Open an SSH session.
ssh -p 2222 user@host
Connect using a non-default SSH port.
ssh -i key user@host
Connect using a specific identity/private key.
ssh-keygen -t ed25519 -C 'email'
Create an Ed25519 SSH key pair.
ssh-add ~/.ssh/id_ed25519
Add a private key to the SSH agent.
ssh -T git@github.com
Test SSH authentication to GitHub.
ssh-copy-id user@host
Install your public key on a remote host where the helper is available.
~/.ssh/config
Per-user SSH host aliases and connection options.
Networking, SSH & Remote Work

scp & rsync

scp file user@host:/path
Copy one file over SSH.
scp -r dir user@host:/path
Copy 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.
Networking, SSH & Remote Work

Firewall Quick Reference

sudo ufw status
Show UFW status on systems using UFW.
sudo ufw allow 22/tcp
Allow SSH through UFW.
sudo firewall-cmd --list-all
Show firewalld configuration on systems using firewalld.
sudo firewall-cmd --add-service=http --permanent
Permanently allow HTTP in firewalld.
sudo firewall-cmd --reload
Reload permanent firewalld configuration.
nft list ruleset
Inspect nftables rules where nftables is used.

Manage software, disks, filesystems, archives, system identity, resources, and common Linux troubleshooting.

Panel 6 / 6

06 — Packages, Storage, Archives & Recovery

Packages, Storage, Archives & Recovery

APT ↔ DNF ↔ Pacman

sudo apt update
Refresh package metadata.
sudo dnf check-update
sudo apt install pkg
Install a package.
sudo dnf install pkg
sudo apt remove pkg
Remove a package.
sudo dnf remove pkg
sudo apt upgrade
Upgrade installed packages.
sudo dnf upgrade
apt search pkg
Search packages.
dnf search pkg
apt show pkg
Show package information.
dnf info pkg
dpkg -l
List installed packages using the low-level Debian package tool.
rpm -qa
Packages, Storage, Archives & Recovery

Pacman Notes

sudo pacman -Syu
Arch Linux: refresh package databases and perform a full system upgrade.
sudo pacman -S pkg
Arch Linux: install a package.
sudo pacman -Rns pkg
Arch Linux: remove a package plus unused dependencies/config where applicable.
pacman -Ss pkg
Arch Linux: search repositories.
pacman -Qi pkg
Arch Linux: show installed package information.
Packages, Storage, Archives & Recovery

Disk Usage

df -h
Show mounted filesystem space in human-readable units.
df -i
Show inode usage.
du -sh folder
Show total apparent disk usage for a folder.
du -sh *
Show sizes of items in the current directory.
du -ah . | sort -h | tail
Find larger files/directories under the current path.
lsblk
Show block devices and mount relationships.
blkid
Show filesystem UUIDs and types where permitted.
Packages, Storage, Archives & Recovery

Mounts & Filesystems

mount
List mounted filesystems.
findmnt
Show mounts in a structured tree.
sudo mount /dev/sdb1 /mnt/data
Mount a filesystem.
sudo umount /mnt/data
Unmount a filesystem.
cat /etc/fstab
Inspect configured persistent mounts.
sudo fdisk -l
List disk partition information.
sudo parted -l
List disks and partition tables using parted.
fsck device
Check/repair an unmounted filesystem; exact tool/options depend on filesystem.
Packages, Storage, Archives & Recovery

Archives & Compression

tar -cf archive.tar folder
Create a tar archive.
tar -tf archive.tar
List tar archive contents.
tar -xf archive.tar
Extract a tar archive.
tar -czf archive.tar.gz folder
Create a gzip-compressed tar archive.
tar -xzf archive.tar.gz
Extract a gzip-compressed tar archive.
tar -cJf archive.tar.xz folder
Create an xz-compressed tar archive.
gzip file
Compress one file with gzip.
gunzip file.gz
Decompress a gzip file.
zip -r archive.zip folder
Create a ZIP archive when zip is installed.
unzip archive.zip
Extract a ZIP archive.
Packages, Storage, Archives & Recovery

System & Resource Info

uname -a
Show kernel and system information.
uname -r
Show the kernel release.
cat /etc/os-release
Show distribution identification.
hostnamectl
Show hostname and system metadata on systemd systems.
uptime
Show uptime and load averages.
free -h
Show memory and swap usage.
lscpu
Show CPU architecture details.
lsmem
Show memory block information where available.
lsusb
List USB devices.
lspci
List PCI devices.
Packages, Storage, Archives & Recovery

Kernel & Boot

dmesg | less
Inspect kernel messages.
journalctl -k
Show kernel journal entries on systemd systems.
systemctl --failed
List failed systemd units.
systemctl get-default
Show the default systemd target.
systemctl reboot
Reboot through systemd.
systemctl poweroff
Power off through systemd.
reboot
Reboot using the traditional command; privileges may be required.
shutdown -h now
Shut down immediately.
shutdown -r +10
Schedule a reboot in 10 minutes.
Packages, Storage, Archives & Recovery

Fast Troubleshooting Loop

pwd && ls -la
Confirm location and visible project files.
whoami && id
Confirm the current identity and groups.
command -v tool && tool --version
Confirm a required CLI exists and which version is active.
printenv | sort
Inspect environment values.
df -h && free -h
Check disk and memory pressure.
ps aux | head
Check process state quickly.
ss -tulpn
Check listeners and port conflicts.
systemctl --failed
Find failed services.
journalctl -p err -b
Review current-boot errors.
curl -I http://localhost:PORT
Confirm a local HTTP service responds.
Packages, Storage, Archives & Recovery

High-Risk Commands

rm -rf PATH
Permanently removes a directory tree. Verify pwd and the exact path first.
sudo command
Runs with elevated privileges; system-wide damage is possible.
chmod -R / chown -R
Recursive permission/ownership changes can break applications and services.
dd if=... of=...
Raw block copying can overwrite disks. Verify the output device before running.
mkfs.* device
Creates a new filesystem and destroys existing filesystem data on the target.
fsck -y
Automatic repair can modify filesystem structures; use appropriate recovery procedures.
apt/dnf/pacman full upgrades
Large upgrades can change runtimes, services, kernels, and dependencies.
shutdown / reboot
Ends current sessions and running work.