A practical Linux command reference covering everyday usage and system administration: file navigation, permissions, processes, package management, networking, and text processing. Whether you're SSH'd into a Raspberry Pi, managing a home server, or just trying to figure out why a command isn't doing what you expect, having a solid grip on these commands pays off fast.
Examples below assume a Debian/Ubuntu-based system (including Raspberry Pi OS) unless noted; package manager commands differ slightly on other distros, called out where relevant.
1. Navigating the Filesystem
| Command | What it does |
pwd | Print current directory (where am I) |
ls | List files in current directory |
ls -la | List all files including hidden, long format (permissions, size, owner) |
cd /path/to/dir | Change directory |
cd .. | Go up one directory |
cd ~ or cd | Go to home directory |
cd - | Go back to the previous directory |
mkdir dirname | Create a directory |
mkdir -p a/b/c | Create nested directories in one shot |
rmdir dirname | Remove an empty directory |
rm file | Delete a file |
rm -r dirname | Delete a directory and its contents recursively |
rm -rf dirname | Same, forced, no confirmation — be careful, this doesn't ask twice |
cp file1 file2 | Copy a file |
cp -r dir1 dir2 | Copy a directory recursively |
mv file1 file2 | Move or rename a file |
touch filename | Create an empty file, or update its timestamp if it exists |
find /path -name "*.log" | Search for files by name under a path |
locate filename | Fast filename search using a prebuilt index (run updatedb first) |
which command | Show the full path of a command |
man command | Open the manual page for a command — the built-in help, always available |
2. Viewing & Editing Files
| Command | What it does |
cat file | Print entire file contents to the screen |
less file | Page through a file (space = next page, q = quit, / = search) |
head file | Show the first 10 lines |
head -n 50 file | Show the first 50 lines |
tail file | Show the last 10 lines |
tail -f file | Follow a file live as new lines are appended — essential for watching logs |
nano file | Simple terminal text editor — Ctrl+O to save, Ctrl+X to exit |
vim file | Powerful but less beginner-friendly editor — press i to type, Esc then :wq to save and quit, :q! to quit without saving |
diff file1 file2 | Show differences between two files |
3. File Permissions & Ownership
Every file has an owner, a group, and permission bits for owner/group/everyone (read, write, execute).
| Command | What it does |
ls -l | Show permissions in the form -rwxr-xr-- (owner/group/other) |
chmod 755 file | Set permissions numerically (owner=rwx, group=rx, other=rx) |
chmod +x script.sh | Make a file executable |
chown user:group file | Change file owner and group |
chown -R user:group dir | Change ownership recursively |
sudo command | Run a single command as root (administrator) |
sudo -i or sudo su | Get a root shell (use sparingly, it's easy to break things) |
Quick permission number reference: 7 = read+write+execute, 6 = read+write, 5 = read+execute, 4 = read only. The three digits in chmod 755 are owner, group, other in that order.
4. Process Management
| Command | What it does |
ps aux | List all running processes |
top | Live view of running processes, CPU/memory usage (q to quit) |
htop | Nicer, color, interactive version of top (install with your package manager first) |
kill PID | Ask a process to stop gracefully by process ID |
kill -9 PID | Force-kill a process that won't stop |
killall processname | Kill all processes matching a name |
command & | Run a command in the background |
jobs | List background jobs in the current shell |
fg | Bring the most recent background job to the foreground |
nohup command & | Run a command that keeps running even after you log out |
systemctl status servicename | Check the status of a system service |
systemctl start/stop/restart servicename | Start, stop, or restart a service |
systemctl enable servicename | Make a service start automatically on boot |
journalctl -u servicename | View logs for a specific systemd service |
journalctl -f | Follow the live system journal (like tail -f for the whole system) |
5. Package Management
How you install software depends on the distro. Most Raspberry Pi and Ubuntu/Debian systems use apt:
| Command | What it does |
sudo apt update | Refresh the list of available packages (run this before installing anything) |
sudo apt upgrade | Upgrade all installed packages to their latest versions |
sudo apt install packagename | Install a package |
sudo apt remove packagename | Remove a package, keep its config files |
sudo apt purge packagename | Remove a package and its config files |
sudo apt autoremove | Clean up packages no longer needed by anything else |
apt search keyword | Search for a package by name/description |
dpkg -l | List all installed packages (low-level, apt is built on dpkg) |
On Fedora/RHEL/CentOS it's dnf install packagename / dnf update. On Arch it's pacman -S packagename / pacman -Syu.
6. Networking
| Command | What it does |
ip a | Show network interfaces and their IP addresses (modern replacement for ifconfig) |
ping host | Test connectivity to a host (Ctrl+C to stop) |
curl url | Fetch a URL and print the response — useful for testing APIs |
curl -O url | Download a file, keeping its original filename |
wget url | Download a file (better than curl for large/resumable downloads) |
ssh user@host | Connect to a remote machine over SSH |
ssh -p 2222 user@host | Connect via SSH on a non-default port |
scp file user@host:/path/ | Copy a file to a remote machine over SSH |
rsync -avz src/ user@host:/dest/ | Sync files/directories efficiently, only transferring what changed |
ss -tulpn | Show listening ports and what's using them (modern replacement for netstat) |
hostname -I | Quick way to get just this machine's IP address |
nmap -sn 192.168.1.0/24 | Scan the local network for other devices (install nmap first) |
7. Disk & Storage
| Command | What it does |
df -h | Show disk space usage for all mounted filesystems, human-readable |
du -sh dirname | Show total size of a directory |
du -sh */ | sort -h | Show sizes of subdirectories, sorted smallest to largest |
lsblk | List block devices (drives and partitions) in a tree view |
mount /dev/sdX1 /mnt/point | Mount a drive/partition to a directory |
umount /mnt/point | Unmount a drive — always do this before physically removing it |
fdisk -l | List disks and partition tables (needs sudo) |
8. User & Group Administration
| Command | What it does |
whoami | Show the current logged-in user |
sudo useradd -m username | Create a new user with a home directory |
sudo passwd username | Set or change a user's password |
sudo userdel -r username | Delete a user and their home directory |
sudo usermod -aG groupname username | Add a user to a group (e.g. sudo or docker) |
groups username | Show what groups a user belongs to |
id | Show current user's UID, GID, and group memberships |
9. System Monitoring & Logs
| Command | What it does |
uptime | How long the system has been running, plus load average |
free -h | Show RAM and swap usage, human-readable |
uname -a | Show kernel version and system info |
lsb_release -a | Show distro name and version |
dmesg | Show kernel ring buffer messages — useful for hardware/driver issues |
dmesg | tail | See the most recent kernel messages (e.g. right after plugging in a USB device) |
journalctl -xe | Show recent system logs with extra context, useful after a crash |
vcgencmd measure_temp | Raspberry Pi specific — check CPU temperature |
10. Text Processing & Pipes
These are the tools that make the command line genuinely powerful — chaining them together with the pipe (|) lets you filter and transform output on the fly.
| Command | What it does |
grep "text" file | Search for lines containing "text" in a file |
grep -r "text" dir/ | Search recursively through a directory |
grep -i "text" file | Case-insensitive search |
command | grep "text" | Filter the output of another command |
sed 's/old/new/g' file | Find and replace text in a file's output |
awk '{print $1}' file | Print the first column/field of each line |
cut -d',' -f2 file | Extract a specific column from delimited text (here, comma-separated, 2nd column) |
sort file | Sort lines alphabetically |
sort -n file | Sort numerically |
uniq | Remove adjacent duplicate lines (usually paired with sort first) |
wc -l file | Count lines in a file |
command > file | Redirect output to a file, overwriting it |
command >> file | Redirect output to a file, appending |
command1 | command2 | Pipe the output of one command into another |
11. Archives & Compression
| Command | What it does |
tar -czvf archive.tar.gz dir/ | Create a compressed tarball from a directory |
tar -xzvf archive.tar.gz | Extract a compressed tarball |
zip -r archive.zip dir/ | Create a zip archive |
unzip archive.zip | Extract a zip archive |
gzip file | Compress a single file to file.gz |
gunzip file.gz | Decompress a .gz file |
12. Scheduled Tasks (Cron)
| Command | What it does |
crontab -e | Edit the current user's scheduled cron jobs |
crontab -l | List current cron jobs |
sudo crontab -e -u username | Edit another user's crontab (needs sudo) |
Cron format is five fields — minute, hour, day of month, month, day of week — followed by the command. Example: 0 3 * * * /home/user/backup.sh runs a script every day at 3:00 AM.
13. Handy Combos
history | grep ssh — find a command you ran before involving "ssh"
ps aux | grep python — find running Python processes
du -sh /* 2>/dev/null | sort -h — find what's eating disk space at the root level
tail -f /var/log/syslog | grep error — watch the system log for errors live
Ctrl+C — stop/cancel a running command
Ctrl+Z then bg — pause a running command and send it to the background
Ctrl+R then start typing — search backwards through your command history
!! — re-run the last command (e.g. sudo !! to re-run the last command with sudo after a permission error)
Tab — autocomplete filenames and commands, use it constantly
14. A Word on Safety
A few habits that save you from the classic Linux horror stories:
- Never run
rm -rf / or any variant with a wildcard you haven't double-checked — there's no trash can, deleted is deleted.
- Before running a command with
sudo, make sure you understand what it does — root can break the whole system, not just your files.
- When piping something into
bash from the internet (curl url | bash), read the script first if you can — you're handing over full execution on your machine.
- Keep backups of anything important before doing partition/disk-level operations (
fdisk, mkfs, etc.).
This covers the everyday 80% — navigating, editing, managing processes and services, installing software, basic networking, and enough text-processing to actually get useful work done at the terminal. From here, man command and command --help will get you the rest of the way for anything specific.