Linux··4 min

The Filesystem

Before you open a terminal and start typing commands, it helps to understand what you are actually navigating. Linux has a specific folder structure that looks strange at first but follows a clear logic once you know what each folder is for.

Before you open a terminal and start typing commands, it helps to understand what you are actually navigating. Linux has a specific folder structure that looks strange at first but follows a clear logic once you know what each folder is for.

The root folder

On Windows you have C:\. On Linux you have /. That single forward slash is the root of everything. Every file, every folder, every device on your system lives somewhere under it.

When you open a file manager or a terminal, you are always somewhere inside this tree.

What lives in /

These are the folders you will find in the root directory of almost every Linux system.

  • /home — This is where your personal files live. Every user on the system gets their own folder here. If your username is jan, your home folder is /home/jan. This is where your documents, downloads, pictures and configuration files go.

  • /etc — Configuration files for the system and installed software live here. If a program needs to store settings that affect all users, they end up in /etc.

  • /bin and /usr/bin — These contain the executable programs that make your system work. Commands like ls, cp and mv are files sitting in one of these folders.

  • /var — Variable data. Log files, caches, and other files that change frequently live here. If something goes wrong on your system, /var/log is usually the first place to look.

  • /tmp — Temporary files. Anything in here gets wiped on reboot. Programs use this folder as a scratchpad.

  • /root — This is the home folder of the root user. Not to be confused with /. The root user is the administrator of the system — more on that in the next post.

  • /dev — Device files. On Linux, hardware devices like your hard drive or USB stick are represented as files in this folder. You will rarely need to touch this directly.

  • /proc and /sys — These are virtual filesystems. They do not contain real files on disk. Instead they expose information about running processes and the kernel. You can read them like files, but they are generated on the fly by the system.

You do not need to memorize all of these right now. The ones you will actually use day to day are /home, /etc and /var.


Now that you know what the folders are, here is how you actually move around in a terminal.

Where am I?

pwd

pwd stands for Print Working Directory. It tells you where you currently are. When you open a terminal, you will almost always start in your home folder.

/home/jan

What is here?

ls

ls lists the contents of your current folder. Add -l for a detailed view with permissions and file sizes, or -a to also show hidden files.

ls -la

On Linux, any file or folder that starts with a . is hidden by default. Configuration files are often hidden this way.

Moving around

cd foldername

cd stands for Change Directory. You give it the name of a folder and it moves you into it.

cd /etc

You can navigate using either an absolute path (starting from /) or a relative path (starting from where you currently are).

There are also two shortcuts worth knowing immediately:

cd ~

~ always refers to your home folder. No matter where you are, cd ~ brings you home.

cd ..

.. refers to the folder above your current one. If you are in /home/jan/documents, running cd .. takes you to /home/jan.

A quick example

pwd
# /home/jan
 
cd /etc
pwd
# /etc
 
ls
# you will see a long list of configuration files
 
cd ~
pwd
# /home/jan

That is the foundation. You know what the folders are and you know how to move between them. Everything else you learn from here builds on top of this.

Next up: users and permissions — who owns what, and who is allowed to do what.

1 views