Essential Raspberry Pi Commands: A Complete Cheat Sheet

Working with a Raspberry Pi often means spending time in the terminal. Whether you're setting up a new Pi, troubleshooting network issues, or monitoring system performance, having the right commands at your fingertips can save you significant time.

This cheat sheet brings together the most essential Raspberry Pi OS commands I've found myself using repeatedly. I've organized them by category to make them easy to find when you need them most.

Configuration Commands

These commands help you configure your Raspberry Pi system settings.

System Configuration

sudo raspi-config

Opens the interactive configuration tool for system settings.

raspi-config nonint do_change_locale en_US.UTF-8

Changes the system locale without any menu interaction.

raspi-config nonint do_wifi_country DE

Sets the Wi-Fi country code (replace DE with your country code).

Package Management

Keep your system updated and install new software with these commands.

System Updates

sudo apt update

Refreshes the repository lists to check for available updates.

sudo apt full-upgrade

Installs newer versions of every installed package.

sudo apt install <package-name>

Installs a specific package from the official repositories.

sudo dpkg -i <file>.deb

Installs a local .deb file directly.

sudo apt autoremove

Removes orphaned dependencies that are no longer needed.

Networking & Wi-Fi

These commands help you manage network connections and troubleshoot connectivity issues.

Wi-Fi Management

iwgetid -r

Prints the active Wi-Fi network SSID.

sudo iwlist wlan0 scan | grep ESSID

Lists all nearby Wi-Fi networks.

nmcli dev status

Shows a short overview of all network interfaces.

nmcli dev wifi list

Performs a Wi-Fi scan using NetworkManager.

nmcli dev wifi connect "<SSID>" password "<password>"

Connects to a specific Wi-Fi network.

rfkill list

Shows Bluetooth/Wi-Fi block status.

rfkill unblock wifi

Unblocks Wi-Fi if it's been disabled.

Network Interface Management

ip a

Lists all network interfaces and their IP addresses.

sudo ifconfig wlan0 up

Brings the Wi-Fi interface up.

sudo ifconfig wlan0 down

Brings the Wi-Fi interface down.

System Monitoring

Monitor your Raspberry Pi's performance and health with these commands.

Temperature & Performance

/usr/bin/vcgencmd measure_temp

Shows the SoC (System on Chip) temperature.

vcgencmd get_throttled

Reads voltage or thermal throttling flags to check if the Pi is being throttled.

Resource Usage

htop

Interactive process viewer showing CPU and RAM usage (install with sudo apt install htop if needed).

free -h

Shows a summary of RAM usage in human-readable format.

df -h

Displays disk usage per partition in human-readable format.

Hardware & GPIO

These commands help you work with hardware components and GPIO pins.

GPIO Management

gpio readall

Shows a wiringPi table of all pin modes and levels.

USB & Storage Devices

lsusb

Lists all connected USB devices.

lsblk -o model,name,size,fstype,mountpoint

Shows connected block devices with their mount points and filesystem types.

Boot & Shutdown

Safely manage system restarts and shutdowns.

System Control

sudo reboot

Restarts the system immediately.

sudo systemctl reboot

Alternative command to restart the system.

sudo shutdown -h now

Halts and safely shuts down the system.

sudo shutdown -r +5

Schedules a restart five minutes from now (change the number for different delays).

Service Management

sudo systemctl restart <service-name>

Restarts a specific service (e.g., sudo systemctl restart ssh).

sudo systemctl status <service-name>

Shows the status of a specific service.

sudo systemctl enable <service-name>

Enables a service to start on boot.

sudo systemctl disable <service-name>

Disables a service from starting on boot.

File Management

Essential commands for navigating and managing files on your Raspberry Pi.

Navigation & Listing

pwd

Shows your current working directory.

ls -la

Lists all files (including hidden ones) with detailed information.

cd <directory>

Changes to the specified directory.

File Operations

cp <source> <destination>

Copies a file or directory.

mv <source> <destination>

Moves or renames a file or directory.

rm <file>

Deletes a file.

rm -rf <directory>

Recursively deletes a directory and all its contents (use with caution).

File Viewing & Editing

cat <file>

Displays the entire contents of a file.

head -n 20 <file>

Shows the first 20 lines of a file.

tail -n 20 <file>

Shows the last 20 lines of a file.

tail -f <file>

Shows the last lines of a file and follows new additions in real-time.

nano <file>

Opens a file in the nano text editor.

grep "search-term" <file>

Searches for a specific term within a file.

Network Diagnostics

Troubleshoot network connectivity issues.

Connectivity Testing

ping <ip-address>

Tests connectivity to a specific IP address.

ping google.com

Tests internet connectivity.

nslookup <domain>

Looks up DNS information for a domain.

traceroute <domain>

Shows the network path to a domain.

Quick Tips

  • Use Tab completion: Type the first few letters of a command or filename and press Tab to auto-complete.
  • Check command history: Use the up arrow key to cycle through previous commands.
  • Get help: Add --help to any command to see its options (e.g., ls --help).
  • Read manual pages: Use man <command> to get detailed documentation.

When to Use These Commands

  • Configuration: Use raspi-config when setting up a new Pi or changing system settings.
  • Updates: Run apt update and apt full-upgrade regularly to keep your system secure.
  • Networking: Use the Wi-Fi commands when setting up wireless connections or troubleshooting connectivity.
  • Monitoring: Check temperature and resource usage when running intensive applications.
  • Hardware: Use GPIO commands when working with sensors, LEDs, or other hardware projects.

This cheat sheet covers the commands I find most useful in my daily Raspberry Pi work. Keep it bookmarked for quick reference, and you'll find yourself becoming more efficient with terminal operations.

Have any favorite Raspberry Pi commands that aren't listed here? Share them with me on X!

A Wifi Place Logo

Find Work-Friendly Cafes Near You

Check my free directory of laptop-friendly cafes with Wifi.

Browse Cafes