Friday, July 4, 2008

Linux file system

Everything that you use or save on a computer is stored as a file on disk drives of some sort. Programs are stored as files. Other types of information, such as word processing files, spreadsheets, and photographs, are stored as files, too. In fact, Linux organizes every resource (except network connections) as a file. All of these resources together are considered a file system.

Linux interacts with all devices as if they are files. For instance, your hard drive is viewed as the file /dev/hda or /dev/hdb. Each file is actually the IDE interface of the first and second hard drive, respectively.


Directory rules

Files are stored inside directories. Directories are actually files themselves whose sole purpose is to allow files to be logically organized.

Linux directories are like Windows folders.

There's no requirement that any particular files have to be located in any particular directories. However, all Linux computers adhere to conventions that provide these general organization rules:

Directories can contain directories. There is no practical limit to the number of directories within directories.

A directory that contains another directory is called the parent.

The directory inside a directory is the child of the parent.

The slash (/) character separates directories.

Microsoft Windows uses backslashes (\), rather than forward slashes (/), to separate directories.

The root directory is the home location of all other directories.

Root is designated by the first slash in any directory list. For instance, if you want to see the contents of the etcetera directory, where configuration files are stored, you type the command ls /etc at the command prompt. Using the slash character tells the command to look in the root directory for the etc directory. (Linux's root directory is equivalent to the Windows C:\ drive.)

A path is a list of one or more directories. You specify a path when describing where to find a file or directory. For instance, the path to the file containing this chapter on my computer is /home/paul/doc/ulfd. Each directory — home, paul, doc, ulfd — is part of the path; the first slash (/) is the root directory.


Common directories

In the future, if and when you start to perform more Linux administration, it's useful to know what and where some of the common Linux directories are. The following list introduces the location and purpose of some of the common Linux directories; all of the directories are created and populated by default when you install Ubuntu (or run Ubuntu from a live CD-ROM):

/boot Linux kernels and their supporting files. After you install Linux, you'll find the Linux kernel saved in /boot.

/dev Device files. Physical devices are represented as files by the Linux kernel. The kernel reads and writes to devices through files contained in this directory. So is your hard drive, and if you have a printer or a USB memory disk connected to your computer, for example, you'll find a corresponding device file in this directory.

/etc System configuration files. Files in this directory allow your computer to automatically use networking, printers, and other devices when they've been configured.

/home User account directories. Your user account home directory, created during the installation process. For instance, if you created a user account called heidi during the Ubuntu installation, that account will have a home directory /home/heidi created for it.

/proc A pseudo directory. This directory is not physically located on any disk drive but is a view into the Linux kernel itself. Linux allows you to view certain internal data structures, and in some cases, control them via files found here.

It isn't necessary to use the /proc file system unless you're performing very advanced system administration tasks. Ubuntu makes the everyday management of Ubuntu very easy by providing utilities that make it unnecessary to use the /proc file system.

/tmp Temporary files that can be deleted after you've used them. For instance, there are many files that Linux creates to manage or facilitate running utilities and applications that are stored temporarily in this directory.

/usr Additional directories that store system and application programs, libraries, and supporting files.

Libraries are small pieces of software — called subroutines or functions in programming speak — that perform simple, common tasks and are shared by multiple programs and applications. Programmers use libraries when writing an application so they don't have to "reinvent the wheel" every time they need to perform some common task; for instance, a Web browser and e-mail client application and word processor all use the same library function to read and write files on a Linux file system.

/usr/bin User applications and utility programs. /usr/bin contains applications like the Firefox Web browser and Evolution e-mail/calendar, and utilities like the ls command. Most applications and utilities are stored here by default.

/usr/sbin System applications and utility programs. /usr/sbin is similar to /usr/bin/, but it stores applications and utilities used for system administration. /usr/sbin is not accessible by users unless they use sudo to gain superuser privilege.

/usr/local Third-party or user-supplied applications, utility programs, configuration files, databases, and so on. You typically use this directory structure to store applications and utilities that aren't part of the Ubuntu installation. For instance, if you download a beta version of Firefox, you should install it in /usr/local/bin so as not to overwrite the production version found in /usr/bin — and also to reduce confusion about what version resides where.

/var Files that vary with time. This directory contains files that the operating system creates, deletes, reads, and writes to. For instance, when you print a document, a temporary file holding the formatted text gets written to the /var/spool directory. It's deleted when the print job finishes.

For instance, when you print a document, Linux creates an output file to send to the printer — but first it stores, temporarily, the output in /var/spool/lp. After the document is printed, Linux deletes the temporary file.


Differences between Linux and Windows

Linux files and directories are similar to Windows files and folders, but there are a few differences:

Linux uses different names — forward slashes, backward ones, — but the concept is the same.

The Linux root directory / is replaced by a drive symbol, such as the common C:\ drive.

You also have to explicitly mount a file system to use it in Linux. Linux must mount a file system before it can start using the file system.

Linux has gotten very good at hiding such processes. For instance, plug your USB flash memory device into your Ubuntu computer, and you'll see a window showing its contents in a few seconds. Ubuntu detected and mounted the device without intervention.


Source of Information : Ubuntu Linux For Dummies

No comments: