Linux Mint – Navigating the filesystem

How to Create MySQL Users Accounts and Grant Privileges

Before we continue with more advanced terminal usage, it’s important to understand how the filesystem is laid out in Linux as well as how to navigate it. First, we must clarify what exactly is meant by the term “filesystem” as it can refer to different things depending on the context. If you recall, when you installed Linux Mint, you formatted one or more partitions with a filesystem, most likely ext4. In this context, we’re referring to the type of formatting applied to a hard-disk partition. There are many different filesystems available for formatting hard disk partitions, and this is true for all operating systems.

However, there is another meaning to “filesystem” with regards to Linux. In the context of this chapter, filesystem refers to the default system of directories (also known as folders) in a Linux installation and how to navigate from one folder to another. The filesystem in an installed Linux system includes many different folders, each with its own purpose. In order to understand how to navigate between directories in a Linux filesystem, you should first have a basic understanding of what the folders are for.

You can view the default directory structure in the Linux filesystem in one of the following two ways:

  • One way is to open the Nemo file manager and click on File System on the left-hand side of the window. This will open a view of the default folders in Linux, as shown in the following screenshot:
  • Additionally, you can execute the following command from your terminal emulator:
    ls -l /

    The following screenshot shows the output of the preceding command from the root of the filesystem:

The first point to understand, especially if you’re coming from Windows, is that there is no drive lettering in Linux. This means that there is no C drive for your operating system or D drive for your optical drive. The closest thing that the Linux filesystem has for a C: drive is a single forward slash, which represents the beginning of the filesystem. In Linux, everything is a subdirectory of /. When we executed the preceding command ( ls -l /), we were telling the terminal emulator that we’d like a listing of / or the beginning of the drive. The -l flag tells the terminal emulator that we would like a long alphabetical listing rather than a horizontal one.

Paths are written as shown in the following command line example. In this example, the path references the Music directory under Joe’s home directory:


The first slash ( /home) references the beginning of the filesystem. If a path in Linux is typed starting with a single forward slash, this means that the path starts with the beginning of the drive. In the preceding example, if we start at the beginning of the filesystem, we’ll see a directory there named home. Inside the home folder, we’ll see another directory named joe. Inside the joe directory, we’ll find another directory named Music.

The cd command is used to change the directory from the current working directory, to the one that we want to work with. Let’s demonstrate this with an example. First, let’s say that the prompt Joe sees in his terminal is the following:

joe@Mint ~ $

From this, we can deduce that the current working directory is Joe’s home directory. We know this because the ~ character is shorthand for the user’s home directory. Let’s assume that Joe types the following:


Then, his output will be as follows:


In his case, ~ is the same as /home/joe.

Since Joe is currently in his home directory, he can see the contents of that directory by simply typing the following command:


The Music directory that Joe wants to access would be shown in the output as its path is /home/joe/Music.

To change the working directory of the terminal to /home/joe/Music, Joe can type the following:

cd /home/joe/Music

His prompt will change to the following:

joe@Mint ~/Music $

However, the cd command does not make you type the full path. With the cd command, you can type an absolute or relative path. In the preceding command line using cd command, we referenced an absolute path. The absolute path is a path from the beginning of the disk (the single forward slash), and each directory from the beginning is completely typed out. In this example, it’s unnecessary to type the full path because Joe is already in his home directory. As Music is a subdirectory of the directory he’s already in, all he has to do is type the following command in order to get access to his Music directory:

cd Music

That’s it. Without first typing a forward slash, the command interpreter understands that we are referencing a directory in the current working directory. If Joe was to use /Music as a path instead, this wouldn’t work because there is no Music directory at the top level of his hard drive.

If Joe wants to go back one level, he can enter the following command:


Typing the cd command along with two periods tells the command interpreter that we would like to move backwards to the level above the one where we currently are. In this case, the command would return Joe back to his home directory.

Finally, as if the difference between a filesystem in the context of hard drive formatting and filesystem in the context of directory structure wasn’t confusing enough, there is another key term you should know for use with Linux. This term also has multiple meanings that change depending on the context in which you use it. The word is root.

The user account named root is present on all Linux systems. The root account is the Alpha and Omega of the Linux system. The root user has the most permissions of any user on the system; root could even delete the entire filesystem and everything contained within it if necessary. Therefore, it’s generally discouraged to use the root account for fear of a typo destroying your entire system. However, in regards to this chapter, when we talk about root, we’re not talking about the root user account. We’ll get to that in Chapter 8, Managing Users and Permissions; however, for now, there are actually two other meanings to the word root in Linux in regards to the filesystem.

First, you’ll often hear of someone referring to the root of the filesystem. They are referring to the single forward slash that represents the beginning of the filesystem. Second, there is a directory in the root of the filesystem named root. Its path is as follows:


Linux administrators will refer to that directory as “slash root”, indicating that it is a directory called root, and it is stored in the root (beginning) of the filesystem. So, what is the /root directory? The /root directory is the home directory for the root account. In this chapter, we have referred to the /home directory several times. In a Linux system, each user gets their own directory underneath /home. David’s home directory would be /home/david and Cindy’s home directory is likely to be /home/cindy. (Using lowercase for all user names is a common practice for Linux administrators). Notice, however, that there is no /home/root. The root account is special, and it does not have a home directory in /home as normal users would have. /root is basically the equivalent of a home directory for root. The /root directory is not accessible to ordinary users. For example, try the following command:

ls /root

The ls command by itself displays the contents of the current working directory. However, if we pass a path to ls, we’re telling ls that we want to list the storage of a different directory. In the preceding command, we’re requesting to list the storage of the /root directory. Unfortunately, we can’t. The root account does not want its directories visible to mortal users. If you execute the command, it will give you an error message indicating that permission was denied.


Like many Ubuntu-based distributions, the root account in Mint is actually disabled. Even though it’s disabled, the /root directory still exists and the root account can be used but not directly logged in to. In Chapter 8, Managing Users and Permissions, we’ll clear this mystery a little more. For now, the takeaway is that you cannot actually log in as root, though in Chapter 8, Managing Users and Permissions, we’ll demonstrate a way to run commands with root permissions.

So far, we’ve covered the /home and /root subdirectories of /, but what about the rest? This section of the chapter will be closed with a brief description of what each directory is used for. Don’t worry; you don’t have to memorize them all. Just use this section as reference.

  • /bin: This stores essential commands accessible to all users. The executables for commands such as ls are stored here.
  • /boot: This stores the configuration information for the boot loader as well as the initial ramdisk for the boot sequence.
  • /dev: This holds the location for devices to represent pieces of hardware, such as hard drives and sound cards.
  • /etc: This stores the configuration files used in the system. Examples include the configuration for Samba, which handles cross-platform networking, as well as the fstab file, which stores mount points for hard disks.
  • /home: As discussed earlier in the chapter, each user account gets its own directory underneath this directory for storing personal files.
  • /lib: This stores the libraries needed for other binaries.
  • /media: This directory serves as a place for removable media to be mounted. If you insert media (such as a flash drive), you’ll find it underneath this directory.
  • /mnt: This directory is used for manual mount points; /media is generally used instead, and this directory still exists as a holdover from the past.
  • /opt: Additional programs can be installed here.
  • /proc: Within /proc, you’ll find virtual files that represent processes and kernel data.
  • /root: This is the home directory for the root account.
  • /sbin: This consists of super user program binaries.
  • /tmp: This is a place for temporary files.
  • /usr: This is a directory where utilities and applications can be stored for use by all users, but it is not modified directly by users other than the root user.
  • /var: This is a directory where continually changing files, such as printer spools and logs, are stored.

Comments are closed.