Raspberry Pi & Linux Guide

I - What is a Raspberry Pi and Linux?

Raspberry Pi

What is it?

The Raspberry Pi is a series of small, affordable, single-board computers developed in the United Kingdom by the Raspberry Pi Foundation in collaboration with Broadcom. It’s designed to promote teaching basic computer science and to provide an accessible platform for hobbyists, educators, and students to explore computing, learn programming, and work on various digital projects.

Raspberry Pi Projects

Raspberry Pi projects range from simple learning tools to complex systems. Some popular project ideas include:

Raspberry Pi Documentation

To read more about the Raspberry Pi, you can visit the official Raspberry Pi website or explore its Wikipedia page for detailed information on its history, models, and specifications. Additionally, there are numerous online communities and forums where Raspberry Pi enthusiasts share their projects and offer support.

Linux

What is Linux?

Why does the Pi use Linux?

II - How to use Linux

Installation

Install the Raspberry Pi Imager on a computer. This is used to install a .iso file to an SD card or MicroSD card (depending on your Raspberry Pi model). Launch the application and you’ll see the following buttons:

Raspberry Pi Imager Interface

Select your Raspberry Pi device and the storage device connected to your computer.

For the Operating System, if you have a Raspberry Pi 3 or newer, the top option should be OK. Anything older, and you should choose Raspberry Pi OS (Legacy, 32-bit) Lite. Note that this will not install a Desktop Environment (DE), which means everything you’ll do is through the terminal. That might sound scary, but don’t worry. This guide will go over everything you need to know to hit the ground running.

Once you hit next, you should see the popup below:

Raspberry Pi Imager Popup

Click EDIT SETTINGS and Set username and password. This is the only setting you should set, but others are available, such as enabling SSH (Secure Shell protocol). For the time being, let’s skip those since they’re not strictly necessary.

Raspberry Pi Settings Edit

Now, wait until the installation is complete!

Raspberry Pi Installation Progress

SSH vs. Local

Using a Raspberry Pi with Linux can be experienced in two distinct ways: through SSH (Secure Shell) or locally by connecting a display directly to the Pi. Here’s a comparison of both methods:

Using SSH:

Using Locally:

If you are going to utilize SSH, please be sure to check that option in the settings page when you are installing, though this can be enabled in the future.

III - The Power of the Linux Terminal

Why use a terminal?

A command is just an application. Some commands open a window (a Graphical User Interface or GUI) while others remain in the terminal (referred to as Command-Line Interface or CLI). Many developers create applications that live in the terminal because, frankly, it’s a lot less work. What this means is that small, specialized tools are widely available on Linux since someone likely has already made it.

While there are many, many more commands, this guide will stick to the essentials to get you up and running quickly. The essentials have been divided into the following categories:

These commands can be accessed in the terminal and can have many different options (called parameters outside of a program, arguments inside a program). Google is your friend here, but an even better friend is tldr. It provides simple and concise explanations of commands with examples for the most common uses of those commands.

Learning these commands will take time. It will at times be frustrating. Like anything worthwhile, it takes time, practice, and patience.

Essential Terminal Commands

Most commands have different parameters, some optional and some required. This guide will only cover the most common uses of the most common commands. Use tldr command to get more uses for a command. Use man command to get detailed information and all parameters for a command.

For most commands, either a full path or relative path may be used for input/output files and directories. Make sure to consider your user access to paths as well. For a command with input and/or output parameters, the input must be a file/directory that your user has access to read. The output must be a file/directory that your user has access to write to.

Most commands also support wildcard characters. Once you’re familiar with commands, start experimenting with wildcards. Start by reading more here.

File Operations

cd

cd is by far the most commonly used command line utility. This changes what directory you are currently in.

Command Description
cd Go to your home directory, /home/username.
cd ~ Go to your home directory, /home/username.
cd /home/username/directory Go to a specific directory by providing a full path.
cd directory Go to a directory that is in your current directory.
ls

ls is the second most used command. This command will list files and directories in your current location by default, but there are multiple options.

Command Description
ls Lists files and directories in your current directory.
ls -l Include more information like ownership and permissions.
ls -la Include hidden files and directories.
ls -la directory List all files and information for a specific directory.
mkdir

mkdir is used to create a new directory or folder, or many directories at once.

Command Description
mkdir a-directory Create a new directory.
mkdir a-directory b-directory ... Make multiple directories.
touch

touch has multiple uses. The primary use is to create new file(s). The secondary use is to update the last-accessed timestamp of a file. Note that this command does not create directories, but will update the timestamp of a directory.

Command Description
touch file.txt Create (or update the access timestamp) a file.
touch file.txt a-directory ... Create/update a file and update a directory.
cp

cp copies a file(s)/directory(ies) to a destination directory. This copies the permissions as well as the file contents themselves. cp writes over any existing output file as well.

Command Description
cp input-file output-file Copy the input file and create/write the output file.
cp a-input b-input directory Copy multiple files into one output directory.
cp -r input-directory output-directory Create a copy of the input directory with the output’s name.
mv

mv moves a file(s)/directory(ies) to a target destination. This can be used to rename a file or directory, or move file(s)/directory(ies) into another location.

Command Description
mv input-file directory Move the input file into the directory.
mv a-input b-input directory Move multiple files into one directory.
mv input-name output-name Rename a directory/file.
rm

rm is the delete command, and can remove one or more files at once, and can be used to delete directories as well.

Command Description
rm input-file Remove a file.
rm a-input b-input Remove multiple files at once.
rm -r a-directory Remove a directory.