π Raspberry Pi β Linux Shell / Terminal Basics for Beginners (2025 Guide)
π§² Introduction β Why Learn the Shell on Raspberry Pi?
The Linux Shell (also called Terminal or Command Line Interface) is the most powerful tool for controlling your Raspberry Pi. Whether you’re managing files, programming GPIO pins, installing packages, or automating tasksβeverything starts in the shell.
π― In this guide, youβll learn:
- What the shell is and how it works on Raspberry Pi
- Essential terminal commands to get started
- How to navigate, create, and edit files from the CLI
- Practical shell usage for Raspberry Pi projects
π§ What Is the Linux Shell?
The shell is a command interpreter that lets you talk to your operating system by typing text commands.
Raspberry Pi uses Bash (Bourne Again SHell) by default, which supports:
- Scripting
- Command history
- Autocompletion
- Pipelining and redirection
π Whether you’re using Raspberry Pi OS Desktop or Lite, youβll rely on the shell for development, configuration, and automation.
π₯ How to Open the Terminal
π» Access Method | π Steps |
---|---|
Raspberry Pi Desktop | Click the Terminal icon in the taskbar |
SSH (Headless Setup) | Run ssh pi@<ip-address> from another device |
CLI-Only OS | Raspberry Pi boots directly into the shell |
π Basic Shell Commands
Here are the most essential Linux commands youβll use daily:
π§ͺ Command | π‘ Description |
---|---|
pwd | Show current directory (Print Working Directory) |
ls | List files and folders |
cd <dir> | Change directory |
mkdir <dir> | Create a new folder |
touch <file> | Create an empty file |
cp <src> <dest> | Copy a file or folder |
mv <src> <dest> | Move or rename files |
rm <file> | Delete a file |
clear | Clear the terminal screen |
π Example: Create and move to a new folder:
mkdir projects
cd projects
touch hello.py
π οΈ Viewing & Editing Files
Use the built-in cat
, nano
, and less
commands:
π§ͺ Command | π Function |
---|---|
cat <file> | Display contents of a file |
nano <file> | Edit a file in the terminal |
less <file> | View large files page by page |
π§ Example β Open and edit a script:
nano blink.py
Use Ctrl+O
to save, Ctrl+X
to exit.
π Permissions & Execution
Control who can access or run files:
π§ Command | π Purpose |
---|---|
chmod +x script.sh | Make script executable |
ls -l | View file permissions |
sudo <command> | Run with superuser privileges |
π Example β Run a Python script:
python3 blink.py
Or make it executable and run:
chmod +x blink.py
./blink.py
π System Update & Reboot
Common system maintenance tasks:
sudo apt update # Update package list
sudo apt upgrade # Upgrade installed packages
sudo reboot # Restart the Pi
sudo shutdown now # Power off safely
π Command Chaining, Pipes & Redirection
Shell allows powerful chaining:
Symbol | Function | Example |
---|---|---|
&& | Run next command only if successful | mkdir logs && cd logs |
> | Redirect output to file | ls > filelist.txt |
>> | Append output to file | echo "done" >> status.log |
` | ` | Pipe output to another command |
π§ͺ Example β Bash Script to Blink LED
Create a file blink.sh
:
#!/bin/bash
echo "Blinking GPIO18"
gpio -g mode 18 out
for i in {1..5}
do
gpio -g write 18 1
sleep 1
gpio -g write 18 0
sleep 1
done
Run it:
chmod +x blink.sh
./blink.sh
β This shell script toggles GPIO pin 18 five times.
π Summary β Recap & Next Steps
The Linux shell is your best tool for mastering Raspberry Pi. It gives you complete control over the systemβideal for scripting, automation, and GPIO control.
π Key takeaways:
- The shell is a command-line interface built into every Raspberry Pi OS
- Bash is the default shell, used for commands and scripting
- Learn file navigation, editing, and permission commands
- Use shell to control GPIO and automate Raspberry Pi tasks
βοΈ Real-world relevance: Most Raspberry Pi automation, networking, and IoT projects start in the shellβwhether via SSH, script, or cron job.
β FAQs β Raspberry Pi Shell / Terminal Basics
β What shell does Raspberry Pi use by default?
β Raspberry Pi uses Bash, a common Linux shell that supports scripting, command history, and job control.
β How do I make a script executable in the shell?
β Use:
chmod +x script.sh
Then run with ./script.sh
.
β Can I access the shell remotely?
β
Yes. Enable SSH via raspi-config
, then connect using:
ssh pi@<IP_ADDRESS>
β Whatβs the difference between Terminal and Shell?
β Terminal is the interface window, while the shell is the program inside that interprets commands (like Bash or Zsh).
β How do I exit Nano editor?
β
Press Ctrl+X
, then Y
to confirm save, and Enter
to exit.
Share Now :