If you have installed Linux on your system, then there are different pre-created directories. This directories are created by Linux as per its conventions to put its system created files. You can also put your own files in these directories.
File systems store user and system data that are the basis of users’ work on the system and the system’s existence.
The Linux filesystem is called a tree. It consists of a set of connected files. This structure allows you to organize files so you can easily find any particular one. On a standard Linux system, each user starts with one directory, to which the user can add subdirectories to any desired level. By creating multiple levels of subdirectories, a user can expand the structure as needed.
Ordinary Files and Directory Files
The tree representing the filesystem is usually pictured upside down with its root at the top. At the end of each path is either an ordinary file or a directory file. Ordinary files, or simply files, appear at the ends of paths that cannot support other paths. Directory files, also referred to as directories or folders, are the points that other paths can branch off from.
When you refer to the tree, up is toward the root and down is away from the root. Directories directly connected by a path are called parents (closer to the root) and children (farther one). On a standard Linux system, each user starts from the root. A pathname is a series of names that trace a path along branches from one file to another.
Every file has a filename. The maximum length of a filename varies with the type of filesyste. Linux supports several types of filesystems. Most modern filesystems allow files with names up to 255 characters long. Although you can use almost any character in a filename, you will avoid confusion if you choose characters from the following list:
Like the children of one parent, no two files in the same directory can have the same name. Files in different directories, like the children of different parents, can have the same name.
Although Linux allows you to use SPACEs within filenames, it is a poor idea. Because a SPACE is a special character, you must quote it on a command line. Use periods or underscores instead of SPACEs.
A filename extension is the part of the filename that follows an embedded period. Filename extensions help describe the contents of the file.
A filename that begins with a period is called a hidden filename (or a hidden file or sometimes an invisible file) because ls does not normally display it. Use the command ls –a to display all filenames, including hidden ones.
Different distributions of Linux has slight difference in directory structure, but some important directories (like boot, var, etc) are common.
1. / (Root Directory)
This is the root or main directory. The root directory of the filesystem hierarchy does not have a name. It is referred to as the root directory and is represented by a slash (/) standing alone or at the left end of a pathname.
2. /bin Directory
Bin stands for binary. This directory contains useful Linux software or command. It contains commands which are used by administrator and other users. This directory does not have any other sub directories.
3. /boot Directory
Boot directory contains files required for booting Linux. It also stores data related to kernel loading. It contains grub loader files also.
4. /dev Directory
Dev stands for device. This directory contains files related to hardware devices in Linux. It contains files related to hard disc, CD ROM, audio, input devices, and others.
5. /etc Directory
Etc stands for etcetera. This directory is brain of Linux. It contains configuration files related to system and user packages. For example, it contains configuration for X11 which is system package and your apache web server which is a user package. If you have PHP installed, then configuration file of PHP (php.ini) is stored here.
6. /home Directory
Home directory is the directory for users. This is similar to My Document Folder in Windows. If you create a user in Linux, a folder is created in the home directory for that user. Only administrator and the user can access the directory.
When you first log in on a system or start a terminal, the working directory is your home directory. Linux home directories are typically located in /home.
7. /lib Directory
This directory contains various libraries which are used by different commands on Linux.
8. /media Directory
This directory is mount point for removable media. It is used for removable media. When you insert USB stick or CD, then a folder in the media directory is automatically created for that.
9. /mnt Directory
This directory is also use for mount point. But, it is used for mounting all devices and file system. Mounting is process by which you can make other device file system available to the Linux.
10. /opt Directory
Opt stands for optional. This directory is for all optional or additional software. All add-on that are not part of default Linux distribution should go in /opt directory.
11. /root Directory
This directory is home directory of root user or super administrator user. For general user, home directory is created under /home/username directory. But for root user home directory is /root.
12. /sbin Directory
Sbin stands for system binary. This directory is identical to /bin directory. It stores binary executable files that can only be used for system maintenance or administrative task. Generally, it contains binary executable of booting, backup, restoration, and others.
13. /usr Directory
Usr stands for unix system resources. This directory is one of the most useful directories in Linux operating system. It contains data like binary, documentation, library, which can be shared among users. Basically, it contains read only data. This is user system resource directory on the Linux file system.
14. /var directory
Var stands for variable. This directory is also one of the most important directories in the Linux. It is opposite of /usr directory. It contains all variables files. Basically, it sores data which dynamically changes like logs. This directory stores backup, db server middle-ware files, if running apache then .html files, etc.
15. /tmp directory
This directory contains temporary files. You can use this directory to store your files temporary. For example, suppose you want to download and install a package. You can download the package in /tmp directory and install it. This directory is accessible from all users.
Sometimes, some running packages of Linux create temporary files in /tmp directory and store data for short terms use. Do not delete any files from /tmp directory if you are not sure of why it is created. It may crash any user program.