Most of the people who are new to Linux are confused about
directories and File structure on Linux. When you boot any Linux
distribution ‘root partition’ is mounted at /. Every files and folder
are mounted under /. You don’t find any drive name like (C, D) etc in
Linux(if it is not dual booted). Moreover In Linux, program are located
in different directories. For examples less command is located under
/usr/bin directory. Therefore the directory structure of Linux/Unix is
intimidating especially for the users who have migrated from windows.
The basic difference is:
Linux/Unix always use forward slash to denote filesystem hierarchy whereas windows use backslash.
/usr/include : Contains header files for C and C++ programming languages
/usr/lib : Contains libraries for C and C++ programming languages.
/usr/local : Contains local files. It has a similar directories as /usr contains.
/usr/sbin : Contains administrative commands.
/usr/share : Contains files that are shared, like, default configuration files, images, documentation, etc.
/usr/src : Contains the source code for the Linux kernel.
/var
Includes user specific files such as mail message, database of installed programs, log files etc.
/var/cache: Storage area for cached data for applications.
/var/lib: Contains information related to the current state of applications. Programs modify this when they run.
/var/lock: Contains lock files which are checked by applications so that a resource can be used by one application only.
/var/log: Contains log files for different applications.
/var/mail: Contains users emails.
/var/opt: Contains variable data for packages stored in /opt directory.
/var/run: Contains data describing the system since it was booted.
/var/spool: Contains data that is waiting for some kind of processing.
/var/tmp: Contains temporary files preserved between system reboots
/tmp
Difference between Linux and Windows File Structure
In windows almost all the program files are installed in ‘program file” by default unless user specify the specific directory. In Linux directory system are categories on the basis of structure of program. For example configuration files are in /etc, all binary files are in /bin or /usr/bin or /usr/local/bin and so on.Windows file Structure
\\Folder\\subfolder\\file.txtLinux File Structure
Linux/Unix always use forward slash to denote filesystem hierarchy whereas windows use backslash.
Understanding File system in Linux/Unix
Download Complete High-Quality Image HERE
Image credit: skill2die4@yahoo.com
/bin:- Contains the executable programs that are part of the Linux operating system.
- Many Linux commands such as cat, cp, ls, more, and tar are located in /bin.
- Example ls, cat, cp.
/dev:
- All the devices like input devices, sound card, modems are stored.
- It is a virtual directory that contains devices files.
- Example : /dev/udp, /dev/urandom, /dev/sda1
- Contains config folder of entire operating system.
- All the global setting like ssh, telnet, and smtp/pop3 mail servers.
- Also contains system’s password file like group lists, user skeletons, and cron jobs.
- Example: /etc/resolv.conf, /etc/logrotate.conf
- Default directory for users to store the personal files.
- Example /home/saugat, /home/sachit
- contains binary executables typtically used by system admnistrator only available to root.
- Mostly used for system maintenance purpose
- Commands such as mount, shutdown, umount, reside here
- Example: /sbin/halt/ /sbin/ip6tables
- contains shareable and read only data
- contains binaries, libraries, documentation and source code for second level program
/usr/include : Contains header files for C and C++ programming languages
/usr/lib : Contains libraries for C and C++ programming languages.
/usr/local : Contains local files. It has a similar directories as /usr contains.
/usr/sbin : Contains administrative commands.
/usr/share : Contains files that are shared, like, default configuration files, images, documentation, etc.
/usr/src : Contains the source code for the Linux kernel.
/var
Includes user specific files such as mail message, database of installed programs, log files etc.
/var/cache: Storage area for cached data for applications.
/var/lib: Contains information related to the current state of applications. Programs modify this when they run.
/var/lock: Contains lock files which are checked by applications so that a resource can be used by one application only.
/var/log: Contains log files for different applications.
/var/mail: Contains users emails.
/var/opt: Contains variable data for packages stored in /opt directory.
/var/run: Contains data describing the system since it was booted.
/var/spool: Contains data that is waiting for some kind of processing.
/var/tmp: Contains temporary files preserved between system reboots
/tmp
- All the temporary files are store here.
- The files under this directory are deleted when system is rebooted.
- For example: when new program is installed it use /tmp/ to put files during installation that won’t be needed after the program is installed.
/mnt
/proc- Default location for mouting devices like cdrooms, floppy disk dries, USB memory sticks etc.
- Example : /mnt/cdroom
- contains information about system process
- virtual file system that contains information about file system.
- Example /proc/cpuinfo, /proc/swaps
/lib
- share libraries are stored(perl, python, C, etc.)
- /lib/ are also a kernel modules
- Example: ld-2.11.1.so, libncurses.so.5.7
/opt
- Config file for add on Application software are found here.
- Third party application should be installed in this directory.
/root
- Home directory of system administrator.’root’.
- Root user has write privilege under this directory
- Contains everything required for boot process.
- Stores data that is used before the kernel begins executing user-mode program.
- Example: /boot/boot.b, /boot/chain.b, /boot/config-kernel-version