🔤 Raspberry Pi – Common Linux Commands Cheat Sheet (2025 Guide)
🧲 Introduction – Why Master Linux Commands on Raspberry Pi?
The Raspberry Pi is powered by Linux, and mastering a core set of commands is essential for working efficiently—especially in terminal-only (headless) environments. Whether you’re managing files, configuring networks, accessing GPIO, or installing packages, the Linux shell is your daily toolkit.
🎯 In this guide, you’ll learn:
- Essential Linux commands for Raspberry Pi
- File management, user handling, permissions, and system tasks
- Networking, process management, and GPIO-related basics
- A printable-style reference for quick use
📁 File & Directory Commands
🧪 Command | 📝 Description |
---|---|
ls | List files in current directory |
ls -l | Long format listing (permissions, size, date) |
cd <dir> | Change to a directory |
pwd | Print current working directory |
mkdir <dir> | Create a new directory |
rm <file> | Delete a file |
rm -r <dir> | Delete a directory and its contents |
cp <src> <dest> | Copy files or folders |
mv <src> <dest> | Move or rename files |
touch <file> | Create an empty file |
🔍 Example:
mkdir scripts
cd scripts
touch startup.sh
🛠️ File Viewing & Editing
🧪 Command | 📘 Purpose |
---|---|
cat <file> | Display contents of file |
nano <file> | Edit file with Nano text editor |
less <file> | View large file with paging |
head -n 10 <file> | Show first 10 lines of file |
tail -f <file> | Live view of a file (e.g., logs) |
🔐 Permissions & User Management
🔧 Command | 💡 Purpose |
---|---|
whoami | Show current username |
id | Show UID, GID, and group info |
sudo <command> | Run command as superuser |
chmod +x <file> | Make a script or file executable |
chown pi:pi <file> | Change file ownership |
passwd | Change user password |
adduser <username> | Add a new user |
deluser <username> | Delete a user |
📦 Software Management (APT)
🧪 Command | 📝 Function |
---|---|
sudo apt update | Update the package list |
sudo apt upgrade | Upgrade all installed packages |
sudo apt install <package> | Install a new package |
sudo apt remove <package> | Remove a package |
sudo apt autoremove | Remove unused dependencies |
sudo apt search <name> | Search for packages |
🌐 Networking & IP Commands
🌐 Command | 💡 Function |
---|---|
hostname -I | Show local IP address |
ping <host> | Ping a host or IP |
ifconfig / ip a | Show network interface details |
iwconfig | Show wireless interface info |
netstat -tuln | Show active TCP/UDP ports |
ss -tuln | Alternative to netstat (newer) |
sudo raspi-config | Configure hostname, Wi-Fi, and SSH |
✅ Use nmap
or arp-scan
to detect devices on your network.
🧠 System Info & Process Management
🧪 Command | 📝 Purpose |
---|---|
uname -a | System and kernel version info |
top / htop | Show live system processes |
free -h | Display RAM usage |
df -h | Show disk space usage |
du -sh <dir> | Show folder size |
ps aux | Show running processes |
kill <PID> | Kill a process by PID |
uptime | How long the Pi has been running |
reboot / shutdown | Restart or power off the system |
🧪 GPIO & Python Execution
🧪 Command | 📘 Description |
---|---|
gpio readall | View GPIO pin mapping |
gpio -g write 17 1 | Set GPIO17 HIGH |
gpio -g write 17 0 | Set GPIO17 LOW |
python3 <script>.py | Run a Python script |
chmod +x <script>.py | Make script executable |
./<script>.py | Execute directly if executable |
✅ Install GPIO utility if not available:
sudo apt install wiringpi
🧹 Cleaning Up
🧹 Command | 💡 Use Case |
---|---|
history | View previous commands |
clear | Clear the terminal screen |
sudo apt clean | Remove downloaded package files |
sudo apt autoremove | Remove unnecessary dependencies |
📌 Summary – Recap & Next Steps
Knowing basic Linux commands is crucial for Raspberry Pi mastery. This cheat sheet covers the most-used commands so you can manage files, software, users, and network settings right from the terminal.
🔍 Key takeaways:
- Learn file navigation, editing, and permissions with
cd
,nano
,chmod
- Use APT commands to install, update, or remove software
- Monitor system health with
top
,free
,df
, andps
- Manage GPIO pins and execute Python scripts directly from shell
⚙️ Real-world relevance: These commands are used in Raspberry Pi projects like home automation, headless setups, web servers, and IoT sensors.
❓ FAQs – Raspberry Pi Common Linux Commands
❓ Is there a GUI alternative to these terminal commands?
✅ Yes, Raspberry Pi Desktop includes File Manager and Add/Remove Software—but command line is more powerful and scriptable.
❓ Can I create my own command shortcuts?
✅ Yes. Add aliases to ~/.bashrc
:
alias updateall="sudo apt update && sudo apt upgrade"
Then run source ~/.bashrc
.
❓ How do I find a command I used earlier?
✅ Use:
history
Or press the ↑
arrow to scroll through previous commands.
❓ Is sudo
always required?
✅ Only when modifying system files or installing software. Non-privileged commands like cd
, ls
, or cat
don’t need it.
❓ Can I use these commands via SSH?
✅ Yes! These are the same commands you’d use whether you’re logged in directly or over SSH.
Share Now :