Skip to content
Read everything about Raspberry Pi 5 and other single board Pi PCs, Pi microcontrollers and other news and updates about Pi accessories.
Raspberry Pi Article · 6 min read

The Essential Linux Commands a New Raspberry Pi Owner Actually Needs

About a dozen Linux commands cover files, software, settings and text editing on Raspberry Pi OS. Here they are grouped by task, with copy-ready examples and plain warnings about sudo, rm -rf, chmod -R and dd.

A small single-board computer on a wooden desk wired to a monitor that shows a terminal window with white text

Sooner or later after the first boot, every Raspberry Pi owner ends up at a terminal prompt, and the essential Linux commands for that moment come to about a dozen: ls, cd, cp, mv and mkdir for files, apt update, apt full-upgrade and apt install for software, raspi-config for settings, nano for editing text, and vcgencmd and hostname -I for checking on the board. Three commands deserve real caution: rm -rf, chmod -R and dd, and sudo raises the stakes on all of them. I think a beginner should learn the whole set by task, in the order the jobs come up, because an alphabetical list is a poor way to meet them.

Why should a beginner learn commands by task instead of A to Z?

Alphabetical order looks tidy, and sure, it suits someone who already knows a command's name and only wants its options. But a new owner with a terminal open rarely starts from a name. They start from a job: copy this folder, install that program, change a setting. A list sorted by letter answers none of those directly, because it asks for the one thing a beginner does not have yet.

Sorting by task puts the file commands together because they get used together, puts the software commands in the order they should run, and gives the risky ones a section of their own where the warning sits right beside the command. That layout teaches where sudo belongs at the same moment it teaches what each command does. Everything below is written for Raspberry Pi OS, the system that Raspberry Pi's own documentation covers.

Five commands handle nearly all the file work

ls lists what is in the current folder, and ls -l adds the permissions, owner, size and date for each entry. cd moves you around: cd Documents steps into a folder, cd .. goes up one level, and cd on its own takes you back to your home folder. Between them, those two settle where you are and what is there, which is the first thing any terminal session needs.

The other three change things. mkdir projects creates a folder called projects. cp copies, so cp notes.txt notes-backup.txt makes a second copy of a file, and cp -r projects projects-backup copies a whole folder, because cp skips directories unless it gets the -r option. mv handles both moving and renaming: mv notes.txt Documents/ moves the file, and mv draft.txt final.txt renames it where it sits. Inside your own home folder none of the five needs sudo, so a Permission denied message there is a signal to stop and check the path rather than to retype the line with sudo in front.

Is apt all you need for software?

The Raspberry Pi OS documentation sets out the routine, and the order of the lines matters:

sudo apt update
sudo apt full-upgrade
sudo apt install htop

The first line refreshes the list of available software packages. It tells the system what is on offer and leaves installed software alone. The second brings the installed packages up to date, and the same documentation recommends full-upgrade over the standard upgrade. The third installs a specific package, written as sudo apt install followed by the package name, in this case the htop process viewer. Running the update first means the other two work from a current list.

Other routes exist, from compiling source code to running install scripts copied off a web page. For a beginner, I think apt is enough for a long while, and the other routes can wait until a project calls for one.

Settings are the other half of keeping a Pi in order, and here Raspberry Pi OS has its own tool. Raspberry Pi's configuration guide describes raspi-config as a terminal-based tool included in Raspberry Pi OS for managing common system settings, and you open it by typing sudo raspi-config in the Terminal. It is a menu you move through with the arrow keys and Enter, and for a beginner it is a better first stop than opening a settings file by hand.

Nano is enough of an editor, and that is the point

Text editing can stall a beginner who lands in an editor with no visible way out. nano puts its way out on the screen. Typing nano followed by a file name, as in nano notes.txt, opens that file, or starts a new one if it does not exist yet. The editor prints its main shortcuts along the bottom of the window, where the ^ symbol stands for the Ctrl key. The save routine, as the RaspberryTips command guide gives it, is three keystrokes:

Ctrl+O
Enter
Ctrl+X

Ctrl+O writes the file, Enter confirms the file name, and Ctrl+X closes the editor.

Vim and Emacs have their devoted users, and both repay the time it takes to learn them. A new Pi owner editing a config file needs neither. The rule worth adding here is about sudo: a file in your home folder opens with plain nano, while a system configuration file needs sudo nano, which runs the editor with administrator privileges. That is the line to slow down on.

Which three commands deserve real caution?

Start with the word that so often comes before them. sudo, in the words of the RaspberryTips guide, gives you administrator privileges for the commands that follow, which is why apt and raspi-config take it. Whatever else sits on that line runs with the same privileges. It appears all through this piece, and each time it does, the line deserves a second reading before Enter.

The first of the three is rm -rf. rm deletes, -r makes it recursive so it goes into folders and everything inside them, and -f forces it through without prompting. Used on system folders, the same guide warns, it will delete everything without any warning message, and those folders belong to the administrator, which is where sudo comes in. Before running rm -r on anything, run ls on the same path to see exactly what is about to go.

The second is chmod -R. The chmod manual page describes the command as changing file mode bits, the read, write and execute permissions, and its -R option changes files and directories recursively. One command can therefore rewrite the permissions on every file under a folder. On your own project folder that is handy. With sudo in front, the same recursive change runs with administrator privileges, so the path after it is worth checking twice.

The third is dd, often used to copy whole disk images. The GNU coreutils manual describes it as copying input to output with a changeable block size, optionally converting the data on the way, and adds that unless conv=notrunc is given, the output file is truncated before writing. dd writes to whatever of= names and empties it first by default, which makes of= the part of the line to check letter by letter.

Two short commands tell you how the board is doing

The last pair is the gentlest. vcgencmd measure_temp displays the current CPU temperature, according to the same RaspberryTips list, which makes it a quick check after fitting a case or cooler. hostname -I prints the IP addresses the Pi holds on the network, the address you need to reach the board from another computer, over SSH for example, when it runs without a monitor. Neither needs sudo and neither changes anything.

You give up memorising a long command list and gain a dozen commands and one habit: read every line that starts with sudo before pressing Enter.

Written by Rhea Manalo

From Cebu City, Rhea Manalo tracks which old games run well on Raspberry Pi boards.

14 articles →