Raspberry Pi β Working with Linux: Beginnerβs Command Line Guide (2025)
Introduction β Why Learn Linux on Raspberry Pi?
Raspberry Pi runs Linux-based operating systems like Raspberry Pi OS, Ubuntu, and others. Understanding how to work with Linux is essential for programming, system control, automation, and hardware interfacing on your Pi.
In this guide, youβll learn:
- How to navigate Linux on Raspberry Pi
- Common command-line tools and terminal basics
- File, user, and system management commands
- How to install software and update your Pi
- Practical Linux use cases on Raspberry Pi projects
What Is Linux on Raspberry Pi?
Linux is a powerful, open-source operating system that powers Raspberry Pi. The most common distro is Raspberry Pi OS, a Debian-based system with a PIXEL desktop. Whether you use the GUI or SSH remotely, all serious Pi work involves Linux under the hood.
Linux lets you:
- Run Python, C, Node.js, and Bash scripts
- Access GPIO, I2C, SPI devices
- Install packages with APT
- Schedule tasks and automate systems
- Secure and network your Pi
How to Access the Linux Terminal
You can access the terminal in three main ways:
| Method | How to Use |
|---|---|
| Desktop | Click the Terminal icon on the PIXEL taskbar |
| Headless SSH | Use ssh pi@<IP_ADDRESS> from another computer |
| Lite OS | Boots directly into CLI (command-line interface) |
Tip: Use CTRL+ALT+T to open terminal quickly on Raspberry Pi Desktop.
Basic Linux File Commands
| Command | Purpose |
|---|---|
pwd | Show current directory |
ls | List files and folders |
cd <folder> | Change directory |
mkdir <name> | Create a new folder |
touch <file> | Create an empty file |
rm <file> | Delete a file |
cp <src> <dest> | Copy files or folders |
mv <src> <dest> | Move or rename files |
Example:
cd /home/pi
mkdir projects
touch hello.py
User & Permission Commands
| Command | Purpose |
|---|---|
whoami | Shows the current user |
sudo | Run a command with root privileges |
passwd | Change your password |
chmod +x <file> | Make a script or file executable |
chown pi:pi <file> | Change file owner to user ‘pi’ |
Best practice: Avoid logging in as root. Use sudo when elevated access is needed.
Installing & Updating Software
Use APT (Advanced Package Tool) to install and manage software:
sudo apt update # Updates package list
sudo apt upgrade # Installs latest available updates
sudo apt install <name> # Installs a new package
Example:
sudo apt install git
sudo apt install python3-pip
You can also install .deb files or use snap on Ubuntu-based systems.
Editing Files with Nano
To edit configuration files or scripts:
nano <filename>
Example:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Use:
CTRL+Oto saveCTRL+Xto exitCTRL+Wto search
Rebooting & Shutting Down
| Command | Action |
|---|---|
sudo reboot | Restart Raspberry Pi |
sudo shutdown now | Shutdown immediately |
sudo shutdown -h now | Shutdown and halt |
sudo shutdown -r now | Reboot immediately |
οΈ Schedule shutdown:
sudo shutdown +30
(This will shutdown in 30 minutes.)
GPIO Access from Linux
You can toggle GPIO pins directly using command-line tools like:
gpio -g mode 17 out
gpio -g write 17 1
Or using Python with RPi.GPIO:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.HIGH)
Make sure to install:
sudo apt install python3-rpi.gpio
Summary β Recap & Next Steps
Mastering the Linux terminal opens up the real power of Raspberry Piβfrom running code and managing files to configuring hardware and automation. Once you’re comfortable, Raspberry Pi becomes a full Linux development and electronics platform.
Key takeaways:
- Raspberry Pi runs on Linux (Raspberry Pi OS, Ubuntu, etc.)
- Command line skills are essential for real Raspberry Pi usage
- Use terminal to manage files, users, software, and scripts
- Tools like
nano,apt, andsudoare frequently used - You can access GPIO, automate tasks, and manage devices with ease
Real-world relevance: Linux skills on Raspberry Pi directly translate to cloud servers, embedded systems, and professional DevOps workflows.
FAQs β Working with Linux on Raspberry Pi
Is Raspberry Pi OS based on Linux?
Yes. Raspberry Pi OS is a Debian-based Linux distribution optimized for ARM architecture.
Do I need to know Linux to use Raspberry Pi?
Basic knowledge is highly recommendedβespecially for headless, GPIO, or coding projects.
Can I use Raspberry Pi without a monitor?
Yes, using SSH from another device. Place a file named ssh in the /boot partition of the SD card.
Whatβs the difference between apt update and apt upgrade?
update refreshes the package list; upgrade installs the latest versions of your installed software.
How do I run a Python script from terminal?
Use:
python3 script.py
Make sure the file is executable or invoke it directly using Python.
Share Now :
