File System

Published:

In this note, I present a preferred directory structures for development. I prefer keeping them similar to production layout because then only one setup need to be remembered.

I only briefly describe the most important system folders such as /etc and /home. Developers usually don't need to access the system files, more can be read from other sources such as [1].

/home, the User Directory

The /home directory usually have subfolders of users /home/{username}. The logged-in user's home folder is usually referred as ~. The Windows equivalent is C:\Users\{username}.

The folder is important as users' configurations and files are kept there. The files are usually not visible to other users if permissions are not explicitly granted.

/etc, the System Configurations

The /etc contains the configuration files of installed software. The files there should not be modified without consulting the documentation of the software.

Perhaps, the most important are system startup configurations such as systemd. This could be configured by adding files to /etc/systemd/system/{configuration_file}.

Permissions

For the security, the files should have minimum permissions.

I find the numeric notations hard to read, so I prefer symbolic notation. That the equivalent of 0644 is -rw-r--r--, where they are read in groups of three. The groups in the notation are owner, group, and public. The first character may be d which means it is a directory.

The notation for full permission of one group is rwx, where r read, w write, and x execute.

The reason I avoid cPanel-based shared-hosting services is because they defaulted my files to -rwxrwxrwx which gives everyone full permissions.

Owner is usually a user that created the file. This can be changed with chmod. Group is a group of users that have been explicitly added to the directory with chgrp. They are added as group. Public means that anyone can perform allowed operations.

More about the permission commands will be discussed in a separate article.

Hidden Files

A convention of prefixing files or folders with . (dot) is to mark directory as hidden [4].

My File Structure

In Windows systems, I try to emulate this structure. I use this structure both in production and locally.

/
    etc/
    lab/
    home/
        {work_user}/
            .ssh/
            open-source/
            projects/
            prototypes/
        {personal_user}/
            .ssh/
            open-source/
            projects/
            prototypes/

lab/ is my global files directory. In production, some other block storages may be mounted to root.

References

  1. https://en.wikipedia.org/wiki/Unix_filesystem
  2. https://en.wikipedia.org/wiki/Systemd
  3. https://en.wikipedia.org/wiki/File_system_permissions
  4. https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory