21 March 2023 Reading time: 5 minutes

Leo Matyshkin,

software developer

File structure of a server


The file structure is a tree. Windows has a few trees, according to the number of disk drives: C, D, etc. Linux always has a single tree. The slash character / corresponds to its root. Everything the system holds, all its logical and physical devices are part of that tree, each with its own unique address.

File system tree

The file structure is a tree. Windows has a few trees, according to the number of disk drives: C, D, etc. Linux always has a single tree. The slash character / corresponds to its root. Everything the system holds, all its logical and physical devices are part of that tree, each with its own unique address.

Two types of parts make up the tree: files and directories. In fact, directories are special files that hold lists of files, but this is not something we need to think about on a daily basis.

Names of files and directories

File names are string values. The use of extensions is not compulsory in Linux. The file blinding_lights.mp3 is the same music file with the same name in Linux as in Windows. But the system will also recognize the filesome_text_file file as one of its own. The system is case-sensitive though: some_TEXT_file is a different name to it.

Unlike Windows, file visibility is not defined by some property of the file, but simply by its name. When the name of a file or directory starts with a dot, that file or directory becomes hidden. Such files and directories are commonly used for the storage of settings. For example, the system that keeps track of Git versions creates a subdirectory named .git in the project directory, whereas the config files for bash can be found in the file.bashrc in the home directory. While we are on the subject of home directories, let's talk about addressing.

Addressing: the file path

All roads lead to Rome, and in Linux, all file paths begin from the root directory. The path actually starts with the root catalog character symbol, and every subsequent directory down to every file or catalog are separated by the same slash. It's pretty much the same deal we described in our URL article.

Let's say a user named ispmanager creates a catalog namedcool in their home directory, containing the image snow.gif. The address of the corresponding file will be:/home/ispmanager/cool/snow.gif.

It is not necessary to remember the absolute file paths to move between directories or query individual files.

  • A single dot (.) marks a current directory (in our example, it's /home/ispmanager/cool, where the file snow.gif)is stored),
  • Two dots (..) mark the current directory's parent directory (in our example, the parent directory of cool is ispmanager) ,
  • The tilde (~) indicates the user's home directory (/home/ispmanager in our example)
  • The minus sign (-) indicates the directory preceding the current directory. This is to make it easier for us to switch between the last viewed directories.

It is easy to manage files and directories with this notation without the use of a cursor, typing the appropriate commands into the terminal. The move as such between directories is initiated by the command cd ("change directory"). We will discuss commands a little later. For now, let's see how the /home. our example).

Filesystem Hierarchy Standard

If you're a Windows user, you are certainly aware of paths that are "standard" in appearance. Program files, for instance, are usually stored at the address C:\Program Files. The Linux file system follows a set of rules enshrined under the name of FHS (Filesystem Hierarchy Standard).

Here are some of the more frequently mentioned directories:

  • / — — root catalog holding the entire file hierarchy,
  • /bin — key utility programs,
  • /boot — boot files,
  • /dev — key device files,
  • /etc — system config files,
  • /home — home user catalogers,
  • /lib — libraries required for the /bin programs to run,
  • /media — removable media points,
  • /opt — optional software,
  • /sys — device, driver and system data,
  • /tmp — temporary files,
  • /usr — the directory in which a secondary hierarchy is built for user data, inclusive of /usr/bin, /usr/local and other directories that have to be there for the multiuser mode to run properly;
  • /var — variable files: app cache, program status info, and pending tasks.

This by-directory division makes backup copying easier. What's more, you can set stringent security rules and set up access to individual directories. This division also comes in useful when Linux is used as an operating system on a physical web server.

Basic commands

The operating system has numerous commands in store for dealing with the file system. Most of the programs involved are stored in the /bin catalog. Here are the more popular ones:

  • pwd pulls up the entire path of the current working directory print working directory);
  • cd modifies the current directory (change directory). The command may be followed by the absolute directory path. Alternatively one may use the above mentionedcd .., cd -, while the same command without an argument cd would be identical to home directory passage cd ~;
  • ls pulls up a list of files and directories. This command has many optional arguments:ls -a will show all files, including hidden ones, ls -R will pull up a list of all files in the subdirectories, and so on;
  • mkdir make directory. The catalog's name in the current directory is to be specified after the command. Alternatively, specify the path to the place where the catalog with the given name is to be created.
  • touch creates a new blank file at a preset address;
  • rm removes files or directories. You should be careful with this command as it will remove files irretrievably;
  • mv moves files from one directory to another;
  • locate searches the entire tree for files and directories with a given name;
  • find searches the current directory;
  • df pulls up disk space use report for the system;
  • find searches the current directory;
  • du checks how much space a file or directory takes up.

In your comments, tell us if you'd like to learn more about the arguments for these commands or other Linux commands, and we will cover the subject in one of our next articles.

User rights

In Linux, every file comes with a set of access rights attached, defining which users are authorized to read the file, add data to it, or run it (this is important for the programs). The only user enjoying full access to the system isroot. This user can do anything: delete any file, launch or end any process, add or remove new users.

The awesome power of this user is a little over-the-top for everyday work. For security reasons, care is taken to minimize action under the username root.

All other users are subject to degrees of restriction on file reading and writing, program launch, and directory visibility. Therefore, if a regular user happens to install an undesirable program, its effects will not be allowed to bleed into the whole system. In this case, the administrator with root rights will come to the rescue.

File manager

It is easy to manage the file system via the terminal, but this work requires some expertise. In desktop versions of Linux, the graphic interface will make all the relevant tasks easier. As for the Linux server versions, the terminal is all you have. If you think the terminal is insufficient, an ispmanagerpanel can be installed on the server.

The ispmanager panel comes with a graphic file manager that has the files graphically organized in an arboreal pattern. It is easy to copy, move, load data to server, download files from server, or modify the rights of different user categories with this manager (elaborate documentation is available).