← How-Tos
electronics Jul 7, 2026 ◑ 1 views ◯ 8 min read

Linux Command Reference: Basic Usage & System Admin Commands

linuxcommand lineterminalsysadminraspberry pisshbashcheat sheet

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 available

2. 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 files

3. 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 memberships

9. 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 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.

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 another

11. 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 file

12. 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

14. A Word on Safety

A few habits that save you from the classic Linux horror stories:

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.