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

🐚 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 DesktopClick the Terminal icon in the taskbar
SSH (Headless Setup)Run ssh pi@<ip-address> from another device
CLI-Only OSRaspberry Pi boots directly into the shell

πŸ“ Basic Shell Commands

Here are the most essential Linux commands you’ll use daily:

πŸ§ͺ CommandπŸ’‘ Description
pwdShow current directory (Print Working Directory)
lsList 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
clearClear 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.shMake script executable
ls -lView 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:

SymbolFunctionExample
&&Run next command only if successfulmkdir logs && cd logs
>Redirect output to filels > filelist.txt
>>Append output to fileecho "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 :

Leave a Reply

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

Share

🐚 Raspberry Pi – Linux Shell / Terminal Basics

Or Copy Link

CONTENTS
Scroll to Top