05 January, 2013

Differences between Linux and Windows is directory structure

One of the most noticeable differences between Linux and Windows is the directory structure. Not only is the format different, but the logic of where to find things is different.

Introduction
In Windows, you use this format to access a directory D:\Folder\subfolder\file.txt
In Linux, this is the basic format /Folder/subfolder/file.txt

You'll notice that the slashes are forward slashes in Linux versus backslashes in Windows. Also, there is no drive name (C:, D:, etc.) in Linux.
At boot, the ‘root partition' is mounted at /. All files, folders, devices and drives are mounted under /. Though it is not apparent from this example, it is important to note that files and folders in Linux are case sensitive.
/Folder/subfolder/file.txt is not the same as /folder/subfolder/file.txt.

Linux Directory Structure Overview

The Directory Structure in Unix & Linux are a unified Directory Structure where in all the directories are unified under the "/" Root file system. Irrespective of where the File System is physically mounted all the directories are arranged hierarchically under the Root file system.

The Linux Directory Structure follows the "Filesystem Hierarchy Structure (FHS)" maintained by the Free Standards Group although most of the distributions sometimes tend to deviate from the standards.
Let’s have a quick stroll across the different directories under the Linux Filesystem Hierarchy Structure.

"/" Root
The Directory Structure starts with the Root file system "/" and is indeed the root directory for the whole structure.The partition where / (the root directory) will be located on a UNIX or UNIX-compatible system.

/boot
The /boot directory contains the Boot loader files including Grub or Lilo, the Kernel, initrd and system.map config files

/sys
This contains the Kernel, Firmware and system related files.

/sbin
Contains the essential System Binaries and System Administration tools essential for the system operation and performance.

/bin
Contains the essential binaries for users and those utilities that are required in single user mode. examples, include cat, ls, cp etc.

/lib
Contains the library files for all the binaries held in the /sbin & /bin directories.

/dev
The /dev directory contains the essential system files and drivers.

/etc
The /etc/directory contain essential System configuration files including /etc/hosts, /etc/resolv.conf, nsswitch.conf, defaults and network configuration files. These are mostly host specific system and application configuration files.

/home
All the user home directories are held under this directory with the exception of the root home directory which is kept under /root directory. This directory holds users files, personal settings like .profile etc.

/media
A generic mount point for removable media like CD-ROM, USB, Floppies etc.

/mnt
A generic mount point for temporary file systems. This comes handy particularly when troubleshooting from CDROM etc. wherein you might have to mount the Root file system and edit configurations.

/opt
A rarely used directory in Linux for Optional Software Packages. This is extensively used in UNIX OS like Sun Solaris where the software packages are installed.

/usr
A sub hierarchy to the root file system which is a User data directory. This contains user specific utilities and applications. You will again see a lot of important but not critical file systems are mounted. Here you would again find a bin, sbin & lib directory which contains non-critical user and system binaries and related libraries and a share directory. Also found here are the include directory with include files.

/usr/sbin
Contains Non-essential Non-critical system binaries and network utilities.

/usr/bin
Contains Non-Essential Non-critical command binaries for users.

/usr/lib
Library files for the binaries in /usr/bin & /usr/sbin directory.

/usr/share
A platform-independent shared data directory.

/usr/local
A sub hierarchy under the /usr directory which has Local System specific data including user and system binaries and their libraries.

/var
The /var directory is mostly mounted as a separate filesystem under the root where in all the variable content like logs, spool files for printers, crontab,at jobs, mail, running process, lock files etc. Care has to be taken in planning this file system and maintenance as this can fill up pretty quickly and when the FileSystem is full can cause system and application operational issues.

/tmp
A temporary file system which hold temporary files which are cleared at system reboot. There is also a /var/tmp directory which holds temporary files too. The only difference between the two is that /var/tmp directory holds files that are protected at system reboot. In other words, /var/tmp files are not flushed upon a reboot.
Then you have the virtual (psuedo) file system /proc which reside in the memory and is mounted under the Root holding kernel and process stats in text file formats.

No comments:

Post a Comment

Your feedback is always appreciated. I will try to reply to your queries as soon as possible- Amol Ghuge

Note: Only a member of this blog may post a comment.