Raspberry Pi

Everything You Need to Know About Linux Root

Everything You Need to Know About Linux Root

Get the basics down and everything else starts to click. This tutorial pulls apart the root directory of the Raspberry Pi, one of those things you just have to know if you’re getting serious about Linux.

Introduction

Raspberry Pi OS, which used to be called Raspbian, is a Debian-based Linux system. It sticks to the Filesystem Hierarchy Standard (FHS), the layout the Linux Foundation keeps up.

The FHS is what sets the structure and the job of every directory in a Linux distro. Learn where things live and a lot of doors open up, career-wise.

The Linux Root Directory

The root directory is the base of the whole FHS. It holds every file and directory on a Linux system, and it goes by a single ‘/’ symbol. Users, installed software, all of it starts at root. Learn to move around in here and Linux gets a lot easier to live with.

Two ways to get to the root directory: the GUI or the CLI.

Accessing the Linux Root Directory

Using GUI (Graphical User Interface)

1. First, open File Explorer by clicking the folder icon on the top right corner of your Menu Bar.

Figure 1: File Explorer

2. Then pick Filesystem Root above the File Tree on the right.

Figure 2: The Root Directory using GUI

Using CLI (Command Line Interface)

1. First, open the CLI by pressing CTRL + ALT + T.

2. Then run the command below:

cd /

3. Check with pwd. And to see what’s inside the root directory, run ls.

Figure 3: The Root Directory using CLI

The Root Contents

/bin – Binaries

The binaries folder holds the executable files for the Linux shell commands. Look inside and you’ll find ls.exe, cd.exe, pwd.exe, rm.exe, and so on. It’s called binaries because most of the programs in here are in binary format.

/boot – Boot files

The boot files folder holds the kernel, the boot image, and the boot loader. The kernel is the OS piece that gets your hardware working. The boot image is the first file mounted to install the kernel. And the boot loader loads the kernel to start the computer.

/dev – Device files

The device files folder holds files that stand in for hardware. So /dev/usb is your USB, /dev/dsp is your speaker, and /dev/hda1 and /dev/hda2 stand in for the first and second partition of your computer.

There are some special files in here too. A few of them:

  • /dev/null: can delete any file
  • /dev/zero: contains an infinite set of zeroes
  • /dev/random: contains an infinite set of random values

/etc – Configuration files

The configuration files folder holds your system settings. This is what changes when you mess with raspi-config. You’ll find things like hostnames, passwords, and networking files in here.

/home – User data

The user data folder holds a personal directory for every user on the system, along with their preferences and their own settings. Everything on your account lands in your own directory under /home.

/lib – Libraries

The libraries folder holds the code dependencies the executable binaries rely on. No need to go deep here yet. Just know that /lib holds the libraries the binaries in /bin and /sbin need.

/media – Media

The media folder holds the files for mounting removable devices like a flash drive or an SD card. Plug in a flash drive and a directory shows up automatically under /media. Inside it you’ll find the files and folders from your flash drive.

/mnt – Mount

The mount folder works like /media, but instead of removable devices, /mnt is for mounting a whole filesystem.

/opt – Optional software

The optional software folder holds all the files for third-party apps. Third-party apps are the software that doesn’t come from the distribution’s repository.

When you install a third-party app, its install and storage files go to /opt while the executable binary goes to /bin. That binaries folder is what lets users actually run the software.

/proc – Process Files

The process files folder holds live data on the processes running right now, plus kernel parameters for the system. Point system tools at this directory and you get useful info back. Say you want real-time details on the ARM Cortex-A72 in the Raspberry Pi 4, just look at /proc/cpuinfo. Want memory usage? Open /proc/meminfo.

/root – Root User

The root user folder is just the home directory of the root user. Remember su and sudo? This is what you’re getting into when you use them.

/sbin – System binaries

The system binaries folder holds executable binaries that only the root user, the superuser, can run. The name kind of gives it away. It’s superuser plus /bin.

/srv – Service data

The service data folder holds the data for the services the system runs. Planning to use the Raspberry Pi as a single-purpose device? This is a good spot for the main program data.

/tmp – Temporary files

The temporary files folder holds exactly what the name says, temporary files. Almost every app uses them, either to speed things up or to hold onto your preferences for a bit. Everything in this folder gets wiped when you reboot.

/usr – User binaries and program data

The user binaries and program data folder holds all the data for system programs. For example:

  • ‘/usr/bin’ contains basic user commands
  • ‘/usr/sbin’ contains additional commands for the administrator
  • ‘/usr/lib’ contains the system libraries
  • ‘/usr/share’ contains documentation or common to all libraries, for example ‘/usr/share/man’ contains the text of the manpage

/var – Variable data

The variable data folder holds runtime info on your programs. Think caches, system logs, and user tracking files. Unlike /tmp, the files here stick around across reboots, which comes in handy if you want to check something like login history. Just head to /var/log/wtmp.

And that’s the rundown on the basic Linux directory structure. See you next time and keep circuit rockin’!

Want to keep going with Linux? Here are a couple more articles worth a read:

Frequently Asked Questions

What does this Everything You Need to Know About Linux Root tutorial cover?

Learning rudimentary knowledge gives mind-blowing epiphanies.

Which Raspberry Pi model fits the Everything You Need to Know About Linux Root project?

Pi 4 (4GB) or Pi 5 for desktop apps and AI workloads. Pi Zero 2 W is enough for headless / sensor builds. Pi 3 B+ works but is slower for camera or ML.

How do I auto-start the Everything You Need to Know About Linux Root script on boot?

Use systemd. Create /etc/systemd/system/myproject.service with ExecStart=/usr/bin/python3 /home/pi/script.py and Restart=always. sudo systemctl enable myproject.

// written by Ruzell Ramirez

Ruzell Ramirez writes the Arduino, ESP32, and Raspberry Pi tutorials at Circuitrocks Learn. Background in embedded electronics and microcontroller projects, with a soft spot for schematic-level explanations and beginner-friendly project builds. Based in the Philippines. When a tutorial here goes deep on power-supply quirks or USB-to-serial gotchas, that's usually him talking.