If you experience any difficulty in accessing content on our website, please contact us at 1-866-333-8917 or email us at support@hudsonvalleyhost.com and we will make every effort to assist you.

By
 
October 19, 2018

WHAT

  Linux
Deluxe company -

As a regular Linux user, you are familiar with /home/username, but sometimes it does get a bit confusing to look for where a package is installed, where a config file exists and so on. Linux directories are organized in a way that files that perform specific functions are located at specific locations. There is a clear demarcation between system files and those owned by the user. Even on the local desktop versions of Linux, permissions prevent sole users from accidentally modifying core configurations. This article is your starting point to the Linux Folder & Directory structure.

Root

Not to be confused with the user “root”, this is the base of the Linux directory structure. Everything else is a sub-directory of this folder. This is true even if you have multiple disks and partitions attached to the server. Identified as /

Home

/home is the location where user directories are present. Every user gets a sub-directory under this location (unless created with the –no-create-home parameter). By default, permissions are segregated by user. The /home directory contains information about the terminal settings, application settings, command history often as hidden directories (for e.g. .ssh).

The home directory for a user is referenced by an alias ~. To go to your home directory you could issue cd ~ to get there instead of having to type the longer cd /home/username. The unix variable for the home directory is $HOME

However, /home is not the home for the root (superuser). /root is the home for the root user

Boot

This folder contains important files required in the boot-up process, including the Linux Kernel. If you are using GRUB (Grand Unified Boot Loader), you will find this as a sub-directory under /boot

bin

/bin contains binaries and other executable programs. These contain commands used by all users of the system. Common commands you will find here are ps, echo, mkdir etc.

Sbin

/sbin also has binary and executables. Though they are mostly meant for the system administrator. Utilities such as fsck, iptables and service.

USR

/usr is mistaken as a shortform of “user” (though it was true at one point in time), but more recently expanded to “User System Resources” as it contains programs and executables added by the user. If you are wondering why have a separate /usr library to store executables, it is because initially /bin was to contain the executables required for basic system operation and /usr would be on a different partition which could be mounted later.

/usr/bin folder contains the programs installed by the user. If you installed php, the executable would be in /usr/bin/php

There are additional directories under /usr such as /usr/sbin, /usr/lib etc. The /usr/sbin folder contains executables used for administrative purposes, such as adduser. The lib directory under /usr contains the libraries required for compilation

ETC

This folder contains application configuration files. This folder also contains the startup and shutdown shell scripts for individual programs. For e.g., your nginx configuration file would most likely be at /etc/nginx/nginx.conf

Also at this location is the /etc/passwd file that contains the list of all the users and also the /etc/shadow file which contains the encrypted passwords. The folder name is derived from etcetera, i.e. everything else, which makes sense from an application point of view. The executable is in /bin or /usr/bin and everything else about the application like its configuration gets a directory by itself.

VAR

Standing for Variable, this directory contains miscellaneous data related to applications such as the log files (/var/log), email boxes (/var/mail), mail queues (/var/spool). The famous /var/www folder is often the root for a web server.

OPT

Optional add-on applications reside here. Typically if you install an application from outside of the package manager, they might get installed into the /opt directory. I installed Paperspace on my laptop and it placed itself in /opt/paperspace directory.

Proc

The /proc is a virtual filesystem that contains information about running processes. It does not contain real files, rather information about the system at run time. You might see numbered directories under /proc each corresponding to a process ID. You could cat a file under this folder and find more information about the system. For e.g., cat /proc/cpuinfo gives you details of the CPU such as the model name, number of cores CPU speed etc.

dev

The /dev directory contains the device files. It contains devices like the terminal (identified as tty*), usb devices attached etc. You may know the /dev/zero location (which returns null characters) from popular Unix Bench scripts which use the dd command

dd bs=1M count=1024 if=/dev/zero of=test conv=fdatasync

Media

This is a temporary mount point created for adding removable devices. For e.g., /media/cdrom. Usually empty on a VPS

Mnt

Another temporary mount directory where you can mount filesystems. Again, this is typically empty on a VPS

Tmp

This is a temporary folder created by the Linux system and users. At the time of the reboot, all files under this directory are deleted.

I hope this article has given you the basic direction map when you are troubleshooting your VPS to help you quickly navigate to the logs or head over to /etc to tweak application configuration.

Subscribe Email