The Most Common Raspberry Pi Commands (And What They Do)

Taking control of your Pi is easy!
Ash Ash (362)
0

Learning how to navigate your Raspberry Pi can be tricky—but it doesn't have to be! We've comprised a list of the most common Raspberry Pi commands.

Not sure where to start? These are some of the most useful commands you can find. Create new directories, update your OS, or even schedule a time for your Pi to shutdown.

Log into your Pi via SSH

First things first, you'll need to log into your Pi. These commands are used when accessing your Pi with a command-line interface. Visit our guide on how to log into your Raspberry Pi using SSH.

Understand the sudo command

sudo

The Raspberry Pi runs on a Linux-based operating system called Raspberry Pi OS. When using Linux commands, it's important to familiarize yourself with the term sudo. The sudo prefix allows you to run specific commands as administrator. Certain commands can cause a lot of hassle if you're not careful. It's important to be diligent with the use of sudo to prevent any accidents or mishaps.

It's possible to enable a permanent superuser mode. This allows you to enter commands without the sudo prefix. However, we strongly advise against this setting to be safe. We've already added the sudo prefix to commands that require administrative access, so you don't have to worry!

Raspberry PiRaspberry Pi ×1

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

sudo reboot

This command does exactly what it sounds like; it will reboot the Pi. You'll need admin privileges to initiate it. Once you run this command, your Raspberry Pi will reboot itself.

sudo poweroff

If you need to power off your raspberry pi, this is the command for you. Be sure to add the sudo prefix!

sudo shutdown -h 03:14

Maybe you need to shutdown your Pi, but not yet! This command lets you schedule a time for your Raspberry Pi to turn off. In the example code, the Raspberry Pi will turn off at 3:14am. Change the hour and minute to reflect your desired shutdown time. You’ll need super user privileges to make this happen.

sudo halt

The halt command tells the Raspberry Pi to cease all CPU functionality before shutting itself down. It's different from other power down commands in that it halts the CPU prior to shutting down. Use the sudo prefix to initiate this command!

clear

This command doesn't undo any of the previous commands, but it does clear them from the screen. If your SSH session is too cluttered, clean the slate with the clear command.

cd /folder1/folder2

The cd command stands for "change directory" and it does exactly what you think it does. If you need to switch to a different folder, just enter this command and replace "/folder1/folder2" with the complete path to your desired directory location.

ls

Are you looking for something in particular? Use this command to list the files in your current directory.

Some commonly used flags are -lha. This will list all files in the directory (including hidden files starting with a dot), and it will display the file size in a human readable way.

ls -lha
sudo find / -name file.txt

Do you need a specific file? Use this command to locate it! Replace "file.txt" with the desired file name. Be sure to include the file extension.

This command works best when running as administrator. Use sudo to make sure the search includes protected folders.

If you're looking for a certain type of file, it can speed up your search to include -type.

File

sudo find / -name file.txt -type f

Directory

sudo find / -name somedir -type d

And if you're looking for a pattern you can always use wildcard search:

sudo find / -name file.*
sudo mv ~/file /folder1/folder2/

The mv command is perfect for moving files from one directory to another. You'll need to use the sudo prefix to ensure the command goes through.

In the example provided, replace "~/file" with your desired file name and "/folder1/folder2/" with your desired destination path.

Note: In this example, the ~ represents the current users home directory.

man command

The man command is an abbreviation of the word manual. This command allows you to access the manual page for a given file, comman1d, or function. Replace the “command/function/file” from our example with your desired data. For example, run “man man” to view the man manual page.

sudo raspi-config

This is the command you need to access the Raspberry Pi Configuration Menu. This menu allows you to modify many different areas of the Pi and you will need admin capabilities to use it. Be sure to use the sudo prefix to access this menu.

sudo ifconfig -a

This command lists out crucial network information. Perfect for setting up network features or troubleshooting. You'll need admin rights to run this command, be sure to add sudo.

ping 192.168.1.1

Need to ping an IP address? Maybe you're troubleshooting or just want to make sure you still have an internet connection. Whatever the case, all you need is to replace the IP address from the example with the destination IP of your choosing.

sudo apt-get update

Use this command to update the package list for your Raspberry Pi. This involves the use of restricted folders, you’ll need to use sudo to run this command.

sudo apt-get upgrade

Use this command to update your Raspberry Pi by installing the latest version of all software packages. Be sure to run this command using the sudo prefix.