🐧 2. Raspberry Pi – Linux Environment
Estimated reading: 4 minutes 30 views

🔤 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
lsList files in current directory
ls -lLong format listing (permissions, size, date)
cd <dir>Change to a directory
pwdPrint 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
whoamiShow current username
idShow 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
passwdChange user password
adduser <username>Add a new user
deluser <username>Delete a user

📦 Software Management (APT)

🧪 Command📝 Function
sudo apt updateUpdate the package list
sudo apt upgradeUpgrade all installed packages
sudo apt install <package>Install a new package
sudo apt remove <package>Remove a package
sudo apt autoremoveRemove unused dependencies
sudo apt search <name>Search for packages

🌐 Networking & IP Commands

🌐 Command💡 Function
hostname -IShow local IP address
ping <host>Ping a host or IP
ifconfig / ip aShow network interface details
iwconfigShow wireless interface info
netstat -tulnShow active TCP/UDP ports
ss -tulnAlternative to netstat (newer)
sudo raspi-configConfigure hostname, Wi-Fi, and SSH

✅ Use nmap or arp-scan to detect devices on your network.


🧠 System Info & Process Management

🧪 Command📝 Purpose
uname -aSystem and kernel version info
top / htopShow live system processes
free -hDisplay RAM usage
df -hShow disk space usage
du -sh <dir>Show folder size
ps auxShow running processes
kill <PID>Kill a process by PID
uptimeHow long the Pi has been running
reboot / shutdownRestart or power off the system

🧪 GPIO & Python Execution

🧪 Command📘 Description
gpio readallView GPIO pin mapping
gpio -g write 17 1Set GPIO17 HIGH
gpio -g write 17 0Set GPIO17 LOW
python3 <script>.pyRun a Python script
chmod +x <script>.pyMake script executable
./<script>.pyExecute directly if executable

✅ Install GPIO utility if not available:

sudo apt install wiringpi

🧹 Cleaning Up

🧹 Command💡 Use Case
historyView previous commands
clearClear the terminal screen
sudo apt cleanRemove downloaded package files
sudo apt autoremoveRemove 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, and ps
  • 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 :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

🔤 Raspberry Pi – Common Linux Commands

Or Copy Link

CONTENTS
Scroll to Top