4  GNU/Linux file system


Laurent Modolo

Creative Commons License

Objective: Understand how files are organized in Unix

On a UNIX system, everything is a file ; if something is not a file, it is a process.

Machtelt Garrels

The followings are files:

This means that your keyboard is represented as a file within the OS.

This file system is organized as a tree. As you have seen, every folder has a parent folder except the / folder whose parent is itself.

Every file can be accessed by an absolute path starting at the root. Your user home folder can be accessed with the path /home/etudiant/. Go to your user home folder.

We can also access files with a relative path, using the special folder ... From your home folder, go to the ubuntu user home folder without passing by the root (we will see use of the . folder later).

4.1 File Types

As you may have guessed, every file type is not the same. We have already seen that common file and folder are different. Here is the list of file types:

  • - common files
  • d folders
  • l links
  • b disk
  • c special files
  • s socket
  • p named pipes

To see the file type you can type the command

ls -la

The first column will tell you the type of the file (here we have only the type - and d). We will come back on the other information later. Another less used command to get fine technical information on a file is the command stat [file_name]. Can you get the same information as ls -la with stat ?

4.2 Common Structure

From the root of the system (/), most of the Unix-like distribution will share the same folder tree structure. On macOS, the names will be different because when you sell the most advanced system in the world you need to rename things, with more advanced names.

4.2.1 /home

You already know this one. You will find all your file and your configuration files here. Which configuration file can you identify in your home ?

4.2.2 /boot

You can find the Linux kernel and the boot manager there. What is the name of your boot manager (process by elimination) ?

You can see a new type of file here, the type l. What it the version of the vmlinuz kernel ?

4.2.3 /root

The home directory of the super user, also called root (we will go back on him later). Can you check its configuration file ?

4.2.4 /bin, /sbin, /usr/bin and /opt

The folder containing the programs used by the system and its users. Programs are simple file readable by a computer, these files are often in binary format which means that it’s extremely difficult for a human to read them.

What is the difference between /bin and /usr/bin ?

/sbin stand for system binary. What are the names of the programs to power off and restart your system ?

/opt is where you will find the installation of non-conventional programs (if you don’t follow the guide of good practice of the LBMC, you can put your bioinformatics tools with crapy installation procedure there).

4.2.5 /lib and /usr/lib

Those folder contains system libraries. Libraries are a collection of pieces of codes usable by programs.

What is the difference between /lib and /usr/lib.

Search information on the /lib/gnupg library on the net.

4.2.6 /etc

The place where system configuration file and default configuration file are. What is the name of the default configuration file for bash ?

4.2.7 /dev

Contains every peripheric

What is the type of the file stdout (you will have to follow the links)?

With the command ls -l can you identify files of type b ?

Using less can you visualize the content of the file urandom ? What about the file random ?

What is the content of /dev/null?

4.2.8 /var

Storage space for variables and temporary files, like system logs, locks, or file waiting to be printed…

In the file auth.log you can see the creation of the ubuntu and etudiantaccount. To visualize a file you can use the command

less [file_path]

You can navigate the file with the navigation arrows. Which group the user ubuntu belongs to that the user etudiantdon’t ?

To close the less you can press Q. Try the opposite of less, what are the differences ?

What is the type of the file autofs.fifo-var-autofs-ifb in the run folder ? From fifo in the name, can you guess the function of the p file ?

There are few examples of the last type of file in the run folder, in which color the command ls -l color them ?

4.2.9 /tmp

Temporary space. Erased at each shutdown of the system !

4.2.10 /proc

Information on the system resources. This file system is virtual. What do we mean by that ?

One of the columns of the command ls -l show the size of the files. Try is on the /etc folder. You can add the -h option to have human readable file size.

What are the sizes of the files in the /proc folder ?

From the cpuinfo file get the brand of the cpu simulated by your VM.

From the meminfo file retrieve the total size of RAM

4.4 Disk and partition

On a computer, the data are physically stored on a media (HDD, SSD, USB key, punch card…)


(Punched cards in storage at a U.S. Federal records center in 1959. All the data visible here would fit on a 4 GB flash drive.)

You cannot dump data directly into the disk, you need to organize things to be able to find them back.


Each media is divided into partitions:


The media is divided into one or many partition, each of which have a file system type. Examples of file system types are

  • fat32, exFAT
  • ext3, ext4
  • HFS+
  • NTFS

The file system handle the physical position of each file on the media. The position of the file in the index of file is called Inode.

The action of attaching a given media to the Unix file system tree, is called mounting a partition or media. To have a complete list of information on what is mounted where, you can use the mountcommand without argument.


Find which disk is mounted at the root of the file tree.

We have seen the commands:

  • stat to display information on a file
  • less to visualize the content of a file
  • ln to create links
  • mount to list mount points

That’s all for the Unix file system, we will come back to it from time to time but for now you can head to the next section.

License: Creative Commons CC-BY-SA-4.0.
Made with Quarto.