Catalog / Raspberry Pi Cheat Sheet
Raspberry Pi Cheat Sheet
A quick reference guide to Raspberry Pi, covering setup, common commands, GPIO pins, and troubleshooting tips. This cheat sheet is designed to help both beginners and experienced users get the most out of their Raspberry Pi.
Getting Started
Initial Setup
1. Download Raspberry Pi Imager: |
2. Install the Imager: |
3. Prepare SD Card: |
4. Choose OS and SD Card: |
5. Write to SD Card: |
6. Boot Raspberry Pi: |
7. Initial Configuration: |
8. Update the System:
|
Basic Commands
`sudo reboot` |
Reboots the Raspberry Pi. |
`sudo shutdown now` |
Shuts down the Raspberry Pi immediately. |
`sudo apt update` |
Updates the package lists. |
`sudo apt upgrade` |
Upgrades installed packages. |
`sudo apt install ` |
Installs a new package. |
`sudo apt remove ` |
Removes a package. |
`df -h` |
Shows disk space usage. |
`free -m` |
Shows memory usage. |
File Management
`ls` |
List files and directories in the current directory. |
`cd ` |
Change the current directory. |
`mkdir ` |
Create a new directory. |
`rm ` |
Remove a file. |
`rmdir ` |
Remove an empty directory. |
`cp ` |
Copy a file. |
`mv ` |
Move or rename a file. |
`nano ` |
Open a file in the Nano text editor. |
GPIO Programming
GPIO Pinout
Refer to the official Raspberry Pi documentation for the specific GPIO pinout of your model. |
Key considerations:
|
RPI.GPIO Library (Python)
`import RPi.GPIO as GPIO` |
Import the RPi.GPIO library. |
`GPIO.setmode(GPIO.BCM)` |
Set the GPIO numbering mode to BCM (Broadcom SOC channel) or |
`GPIO.setup(pin, GPIO.IN)` |
Set a GPIO pin as an input. |
`GPIO.setup(pin, GPIO.OUT)` |
Set a GPIO pin as an output. |
`GPIO.output(pin, GPIO.HIGH)` |
Set a GPIO pin HIGH (3.3V). |
`GPIO.output(pin, GPIO.LOW)` |
Set a GPIO pin LOW (0V). |
`GPIO.input(pin)` |
Read the state of a GPIO pin (returns |
`GPIO.cleanup()` |
Clean up GPIO resources when the script ends. |
Example: Blinking LED
|
Networking
Network Configuration
`ifconfig` |
Display network interface configurations. |
`iwconfig` |
Display wireless network configurations. |
`ping ` |
Test network connectivity by sending ICMP echo requests. |
`hostname -I` |
Display the IP address of the Raspberry Pi. |
`sudo nano /etc/network/interfaces` |
Edit network interface configurations (use with caution). |
`sudo nano /etc/wpa_supplicant/wpa_supplicant.conf` |
Edit Wi-Fi configuration (SSID and password). |
SSH Access
Enable SSH: |
Connect via SSH:
The default username is |
VNC Access
Install VNC Server:
|
Start VNC Server:
|
Connect via VNC Client: |
Troubleshooting
Common Issues
1. No Boot:
|
2. Network Connectivity Issues:
|
3. Permission Errors:
|
4. Package Installation Errors:
|
5. GPIO Issues:
|
Log Files
`/var/log/syslog` |
System log file containing general system messages. |
`/var/log/auth.log` |
Authentication log file recording login attempts and authorization events. |
`/var/log/daemon.log` |
Daemon log file containing messages from various system services. |
`/var/log/kern.log` |
Kernel log file recording kernel-related messages. |
Useful Commands for Troubleshooting
`dmesg` |
Display kernel messages, useful for identifying hardware-related issues. |
`vcgencmd get_throttled` |
Check for CPU throttling due to overheating or insufficient power. |
`top` |
Display real-time system resource usage (CPU, memory). |
`journalctl` |
Query the systemd journal for logs. |