15 Useful Commands Every Raspberry Pi User Should Know

If you’re using a Raspberry Pi computer for your weekend project (perhaps a media centre or a home server) then there is a good chance these useful command line instructions will save you some time.

The Raspberry Pi: Yes, It’s Linux

You’ve imaged your SD card and booted your Raspberry Pi. You’re probably using the Raspbian operating system and updated and configured it so that it meets your requirements. What you may not have realised is that despite the Windows-style icon-driven desktop, Raspbian is a Linux distribution. Several operating systems are available for Raspberry Pi, the vast majority of which are Linux.

Rather than an attempt to get people using Linux by stealth, the Raspberry Pi relies on these operating systems because of their open source origins and versatility.

(And because it’s rather good.)

Now, you can probably use a Linux operating system with a graphical user interface without using the command line, but this is where most of the real power lies.

muo raspberrypi commands terminal   15 Useful Commands Every Raspberry Pi User Should Know

Want power over your Raspbian-powered Raspberry Pi? Begin by launching LX Terminal.

Raspberry Pi Command Line Basics

We wouldn’t expect you to start using the command line without knowing how it works. Essentially, it is a method for instructing the computer to perform tasks. It’s really not all that different from pointing and clicking, only you’re expected to use text.

muo raspberrypi commands version   15 Useful Commands Every Raspberry Pi User Should Know

When you first access the command line, you’ll see the pi@raspberrypi $ prompt – whenever this is displayed you’ll be able to enter commands.

With a mouse-driven GUI, you can easily switch directories and read their contents. In the command line, you can check which directory you’re viewing by entering pwd (print working directory). Use ls to list the contents of the directory, and change directory by entering cd. For instance, cd edward will switch to a directory called “Edward”, while cd.. will always return focus to the parent directory. New directories are possible with mkdir newdir, where “newdir” is the directory label. You can also create a succession of new directories with mkdir –p /home/edward/newdir1/newdir2, where both newdir1 and newdir2 are created, but this will only work with the –p switch.

These are basics of all command line interfaces, and can be easily picked up. What you really need are useful commands.

Display Hardware Information

muo raspberrypi commands cpuinfo   15 Useful Commands Every Raspberry Pi User Should Know

On a Windows PC or Mac you can easily find hardware information by looking in System or About This Mac. To find out about your Raspberry Pi’s hardware, enter the following:

cat /proc/cpuinfo

This will output information about the device’s processor. For instance, where you see BCM2708, this indicates that the chip was manufactured by Broadcom.

Various other hardware information can be found by running commands under the proc directory.

  • cat /proc/meminfo displays details about the Raspberry Pi’s memory
  • cat /proc/partitions reveals the size and number of partitions on your SD card or HDD
  • cat /proc/version shows you which version of the Pi you are using.

All of these details can be used to assess what your Raspberry Pi might be capable of. Further information can be acquired using the vcgencmd series of commands, which can reveal things like CPU temperature (vcgencmd measure_temp). This can prove vital if you’re concerned about airflow.

muo raspberrypi commands temp   15 Useful Commands Every Raspberry Pi User Should Know

Other technical commands include free -o -h to see how much free system memory is available, while vcgencmd get_mem arm && vcgencmd get_mem gpu will reveal the memory split between the CPU and GPU, something that can be adjusted in the Raspbian config screen (see below).

As with the file structure, the ls command can be used to list items attached to your Raspberry Pi, specifically USB hardware. Use lsusb to display a list of attached devices – you’ll find this crucial for setting up a wireless network, mounting a hard disk drive or attaching any other USB hardware that requires some configuration.

muo raspberrypi commands lusb   15 Useful Commands Every Raspberry Pi User Should Know

As long as the item is listed here, you should be able to set it up.

Three Important Terminal Commands

Perhaps the most important command line instruction is sudo. This single word instructs Linux-based systems such as Raspbian that the following command is to be carried out with “super user” privileges, an advanced level of access similar to (but not the same as) administrator on Windows computers.

For example, sudo apt-get install synaptic will download and install the synaptic package manager (one of several methods of installing software on the Raspberry Pi).

muo raspberrypi commands config   15 Useful Commands Every Raspberry Pi User Should Know

One of the most common commands for Raspbian users is sudo raspi-config. This opens the configuration screen for the operating system, which has been updated considerably since it was first released.

When you’re done in the Raspberry Pi command line, and you’re using the Raspbian (distro), enter startx to return to the graphical, mouse-driven interface. If, on the other hand, you wish to shutdown, use sudo shutdown –h now to immediately begin the system halt and shutdown process.

muo raspberrypi commands shutdown   15 Useful Commands Every Raspberry Pi User Should Know

You can restart with sudo shutdown –r now. A timed shutdown can be set by including a value, such as 5 minutes, or a time, such as 21:55:

sudo shutdown –h 21:55

Command Line Information Is Power

For many people, command line access on any platform is intimidating.

The useful commands listed here are an attempt to give the Raspberry Pi newcomer the bare minimum to get started with the terminal, a small stepping stone to success with whichever Pi project they decide to start.

If you’re new to the Raspberry Pi, don’t forget to check out our unofficial Raspberry Pi guide.

Meanwhile, if you have any commands that you regularly input into your Raspberry Pi terminal, don’t forget to share them in the comments below.

Featured Image Credit: Osde-Info

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

6 Comments -

0 votes

Jurmy C

Useful, thank you.

0 votes

tom g

I so want to get one of these!

0 votes

DrToxic

I still don’t run the Debian Image on my Pi.
Risc OS is much faster and easier to code for

0 votes

Jim K

Be careful with Linux based Operating systems cd edward will never change your directory to one called Edward. Linux is case sensitive, cd edward will only switch you to a directory called edward all lower case.

0 votes

andycrofts

@tom g:
Just get one! Cheap as chips, and EXTREMELY addictive.
Check mine out.
oululife.dnsdynamic.com
and have a look at the PILAB tab, and the drivel I’ve documented.
Yeps, the webserver’s running on a Pi.
Cheers, and have shedloads of fun!
Andy, Oulu, Finland

0 votes

Giovanni

Nice article, and you’re right. Mastering the command line opens up all sorts of options.

There’s one typo : “For instance, cd edward will switch to a directory called “Edward”
They both should be edward (or Edward) . Unlike Windows where they’re treated identically, in Linux, the filenames are case-sensitive.

Once you’ve mastered these commands, check out ssh. It allows you to connect and give commands from any PC by giving you a terminal window that connects over the network, so you don’t need a display or keyboard plugged into the Pi. Tis very handy.