Linux Command Reference: Basic Usage & System Admin Commands
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
CommandWhat it does pwdPrint current directory (where am I) lsList files in current directory ls -laList all files including hidden, long format (permissions, size, owner) cd /path/to/dirChange directory cd ..Go up one directory cd ~ or cdGo to home directory cd -Go back to the previous directory mkdir dirnameCreate a directory mkdir -p a/b/cCreate nested directories in one shot rmdir dirnameRemove an empty directory rm fileDelete a file rm -r dirnameDelete a directory and its contents recursively rm -rf dirnameSame, forced, no confirmation — be careful, this doesn't ask twice cp file1 file2Copy a file cp -r dir1 dir2Copy a directory recursively mv file1 file2Move or rename a file touch filenameCreate an empty file, or update its timestamp if it exists find /path -name "*.log"Search for files by name under a path locate filenameFast filename search using a prebuilt index (run updatedb first) which commandShow the full path of a command man commandOpen the manual page for a command — the built-in help, always available2. Viewing & Editing Files
CommandWhat it does cat filePrint entire file contents to the screen less filePage through a file (space = next page, q = quit, / = search) head fileShow the first 10 lines head -n 50 fileShow the first 50 lines tail fileShow the last 10 lines tail -f fileFollow a file live as new lines are appended — essential for watching logs nano fileSimple terminal text editor — Ctrl+O to save, Ctrl+X to exit vim filePowerful but less beginner-friendly editor — press i to type, Esc then :wq to save and quit, :q! to quit without saving diff file1 file2Show differences between two files3. File Permissions & Ownership
Every file has an owner, a group, and permission bits for owner/group/everyone (read, write, execute).
CommandWhat it does ls -lShow permissions in the form -rwxr-xr-- (owner/group/other) chmod 755 fileSet permissions numerically (owner=rwx, group=rx, other=rx) chmod +x script.shMake a file executable chown user:group fileChange file owner and group chown -R user:group dirChange ownership recursively sudo commandRun a single command as root (administrator) sudo -i or sudo suGet 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
CommandWhat it does ps auxList all running processes topLive view of running processes, CPU/memory usage (q to quit) htopNicer, color, interactive version of top (install with your package manager first) kill PIDAsk a process to stop gracefully by process ID kill -9 PIDForce-kill a process that won't stop killall processnameKill all processes matching a name command &Run a command in the background jobsList background jobs in the current shell fgBring the most recent background job to the foreground nohup command &Run a command that keeps running even after you log out systemctl status servicenameCheck the status of a system service systemctl start/stop/restart servicenameStart, stop, or restart a service systemctl enable servicenameMake a service start automatically on boot journalctl -u servicenameView logs for a specific systemd service journalctl -fFollow 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:
CommandWhat it does sudo apt updateRefresh the list of available packages (run this before installing anything) sudo apt upgradeUpgrade all installed packages to their latest versions sudo apt install packagenameInstall a package sudo apt remove packagenameRemove a package, keep its config files sudo apt purge packagenameRemove a package and its config files sudo apt autoremoveClean up packages no longer needed by anything else apt search keywordSearch for a package by name/description dpkg -lList 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
CommandWhat it does ip aShow network interfaces and their IP addresses (modern replacement for ifconfig) ping hostTest connectivity to a host (Ctrl+C to stop) curl urlFetch a URL and print the response — useful for testing APIs curl -O urlDownload a file, keeping its original filename wget urlDownload a file (better than curl for large/resumable downloads) ssh user@hostConnect to a remote machine over SSH ssh -p 2222 user@hostConnect 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 -tulpnShow listening ports and what's using them (modern replacement for netstat) hostname -IQuick way to get just this machine's IP address nmap -sn 192.168.1.0/24Scan the local network for other devices (install nmap first)7. Disk & Storage
CommandWhat it does df -hShow disk space usage for all mounted filesystems, human-readable du -sh dirnameShow total size of a directory du -sh */ | sort -hShow sizes of subdirectories, sorted smallest to largest lsblkList block devices (drives and partitions) in a tree view mount /dev/sdX1 /mnt/pointMount a drive/partition to a directory umount /mnt/pointUnmount a drive — always do this before physically removing it fdisk -lList disks and partition tables (needs sudo)8. User & Group Administration
CommandWhat it does whoamiShow the current logged-in user sudo useradd -m usernameCreate a new user with a home directory sudo passwd usernameSet or change a user's password sudo userdel -r usernameDelete a user and their home directory sudo usermod -aG groupname usernameAdd a user to a group (e.g. sudo or docker) groups usernameShow what groups a user belongs to idShow current user's UID, GID, and group memberships9. System Monitoring & Logs
CommandWhat it does uptimeHow long the system has been running, plus load average free -hShow RAM and swap usage, human-readable uname -aShow kernel version and system info lsb_release -aShow distro name and version dmesgShow kernel ring buffer messages — useful for hardware/driver issues dmesg | tailSee the most recent kernel messages (e.g. right after plugging in a USB device) journalctl -xeShow recent system logs with extra context, useful after a crash vcgencmd measure_tempRaspberry Pi specific — check CPU temperature10. 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.
CommandWhat it does grep "text" fileSearch for lines containing "text" in a file grep -r "text" dir/Search recursively through a directory grep -i "text" fileCase-insensitive search command | grep "text"Filter the output of another command sed 's/old/new/g' fileFind and replace text in a file's output awk '{print $1}' filePrint the first column/field of each line cut -d',' -f2 fileExtract a specific column from delimited text (here, comma-separated, 2nd column) sort fileSort lines alphabetically sort -n fileSort numerically uniqRemove adjacent duplicate lines (usually paired with sort first) wc -l fileCount lines in a file command > fileRedirect output to a file, overwriting it command >> fileRedirect output to a file, appending command1 | command2Pipe the output of one command into another11. Archives & Compression
CommandWhat it does tar -czvf archive.tar.gz dir/Create a compressed tarball from a directory tar -xzvf archive.tar.gzExtract a compressed tarball zip -r archive.zip dir/Create a zip archive unzip archive.zipExtract a zip archive gzip fileCompress a single file to file.gz gunzip file.gzDecompress a .gz file12. Scheduled Tasks (Cron)
CommandWhat it does crontab -eEdit the current user's scheduled cron jobs crontab -lList current cron jobs sudo crontab -e -u usernameEdit 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.
Related Guides
- Raspberry Pi — Common CLI Commands Reference
- Raspberry Pi: Complete Headless Setup Guide (No Monitor Needed)
- How to Install Klipper on Any 3D Printer: Complete Setup Guide
- Raspberry Pi: Headless OS Setup
- How to Set Up a Raspberry Pi Headless with SSH and WiFi
- Getting Started with ROS2 on Raspberry Pi for Robotics
- Managing a Fleet of Raspberry Pis with Ansible: Automated Provisioning, Updates, and Config Management
- Raspberry Pi GPIO in C: libgpiod and WiringPi for Non-Python Projects