Skip to content
Snippets Groups Projects
4_unix_file_system.md 8.02 KiB
title: GNU/Linux file system

GNU/Linux file system

cc_by_sa

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:

  • a text file
  • an executable file
  • a folder
  • a keyboard
  • a disk
  • a USB key
  • ...

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 file 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).

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 are 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. An other 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 ?

Common Structure

From the root of the system (/), most of the Unix-like distribution will share the same folder arborescence. 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.

/home