Understanding the File System and Structure in Linux

15 September , 2011 bill Linux

Introduction
The file system in Linux can be intimidating coming from other operating systems like Microsoft Windows. At first glance it may seem that there is no organisation to the files, but there is a method to this madness. After spending some more time with the file system in Linux, it will seem a lot more secure and organised.

File System
Linux supports many file systems such as EXT4, BTRFS and FAT32. In many of the file systems that Linux uses, file names are case sensitive. Network file systems such as SMB and NFS can be mounted permanently on a directory if it is available and online.

The Structure
The file structure in Linux is very different to the file system in Microsoft Windows. Windows separates partitions into drives identified by a letter followed by a colon punctuation mark (:). The advantage is if an application is causing damage to the drive recursively, the data on a drive identified by a different letter will be safe.

In Linux, partitions are mounted in empty directories, which is great for applications like media centres that scans a directory to identify media. New drives can be added to the system for new media and mounted inside the existing directory structure for scanning.

The Home Directory
Both Windows and Linux store configuration files for some applications in the user home directory. This enables applications to store different configurations for different users.

Users in both Windows and Linux have full permissions to create, edit and delete files in the users home directory only if a file or directory was not created by a different user such as an administrator.

Hidden Files
In windows any folder and file can hidden by adjusting the properties of the folder or file.

In Linux if a file or folder starts with a period (.), it is hidden. Hidden files can be viewed in Linux with Nautilus by pressing “CTRL and H” and with Dolphin by pressing “CTRL and .”. Using the command line, hidden files can be viewed by adding -a to the ls command.

ls -a

The Registry
Windows holds a lot of important information needed by the operating system and applications in the registry. The registry is a database of directories, keys and values. The registry in Windows can be edited with the following command:

regedit

In Linux this information is stored in the users home directory for information specific to the user and in the /etc directory for global configurations. Linux configuration files are standard text files that can be edited manually. Many of these configuration files have graphical editors now.

Log Files
Windows applications usually store log files for applications in the users home directory or in the same directory the application was installed. This is not definite as there is no real structure for Windows and logging.

In Linux, log files are stored in the /var/log directory. There are many graphical applications that will display log information. To see the last few lines of a log file in the console, the tail command can be used:

tail myfile.log

Installed Applications
In Windows applications are usually installed with an installer such as the Microsoft Installer. The installer will ask for administrative permissions and install the files required. Applications are usually stored in the program files directory. Shared files are stored in the system directories located in the windows directory. Drivers are stored in the driver directory located in the system directories.

Applications in Linux are usually installed with the package manager that is used by the Linux distribution. Linux packages help with installing dependencies and even uninstalling. There is also the option of installing applications from source code. a Make file included with the source code will compile and install the files in the right locations.

Binary files in Linux are stored in the bin directory such as /usr/bin and the libraries for the binaries are stored in /usr/lib. Some optional applications can be stored in the /opt directory

The /bin directory is for standard Linux applications such as ls, grep and cp. The /lib directory stores libraries for the binaries in the /bin directory

System binaries are stored in /sbin for standard Linux applications and /usr/sbin for user applications.

Devices
In Linux, devices are represented as empty files. This can come in handy for many reasons. One is to play a DVD movie by pointing to the optical device directly:

mplayer dvd://1 -dvd-device /dev/dvd

A list of devices in the dev directory can be displayed with the following command:

ls /dev

Mounted Devices
Optical, USB and other removable devices are mounted automatically at /media or /mnt which is a mount point (empty directory)  for mounting devices, networks, etc at a temporary location. These mountable devices can be mounted anywhere but are usually mounted at /mnt or /media.

Temporary Files
In Windows temporary files are stored in the appdata directory located in the users directory such as C:\Users\username\AppData\Local\Temp.

Linux stores temporary files in the /tmp directory. Some applications may store temporary files as a hidden file or in a hidden directory in the users home directory.

file, how to, linux, permissions, tutorial,

17 Responses to “Understanding the File System and Structure in Linux”


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress. Designed by elogi.