One of the most frustrating things about mastering a new OS can be figuring out where it keep files. Instead of keeping all important system files in a single directory, such as C:\Windows directory in MS Windows, Linux follows the lead of its UNIX cousins and spreads things out a bit more. Although the Linux and Windows setups involve different methods, they are both logical.
Linux may be all by itself on your hard drive, or may be it’s sharing your hard drive with another OS, such MS Windows. All the hard drive space you allocated for Linux during the installation process is the majority of your Linux filesystem.
The root Directory
Everything in the Linux filesystem is relative to the root directory, which is referred to as / and is the file-system base, a doorway into all your files.
The root directory refers to the highest layer of the file system tree. Normally only directories (not files) are located here. When the system is booted, the partition on which this directory is located is the first one mounted.
Because the kernel cannot fulfill all the tasks of the operating system, all programs that are run at the system start must be available on this partition.
The following directories always have to be on the same partition as the root directory: /bin, /dev/, /etc/, /lib/, and /sbin/.
|1||/bin||Essential commands that everyone needs to use at any time.|
|2||/boot||The information that boots the machine, including your kernel.|
|3||/dev||The device drivers for all the hardware that your system needs to interface with.|
|4||/etc||The configuration files for you system.|
|5||/home||The home directories for each of your users.|
|6||/lib||The libraries, or code that many programs (and the kernel) use.|
|7||/media||A spot where you add temporary media, such as floppy disks and CD-ROMs; not all distributions have this directory.|
|8||/mnt||A spot where you add extra file system components such as networked drives, items you aren’t permanently adding to your file system but that aren’t as temporary as CD-ROMs and floppies.|
|9||/opt||The location that some people decide to use (and some programs want to use) for installing new software packages, such as word processors and office suites.|
|10||/proc||Current setting for your kernel (operating system).|
|11||/root||The superuser’s (root user’s) home directory.|
|12||/sbin||The commands the system administrator needs access to.|
|13||/srv||Data for your system’s services (the programs that run in the background).|
|14||/sys||Kernel information about your hardware.|
|15||/tmp||The place where everyone and everything stores temporary files.|
|16||/usr||A complex hierarchy of additional programs and files.|
|17||/var||The data that changes frequently, such as log files and your mail.|
The directory /bin/ contains important executable programs that are required when no other file systems are mounted, such as all programs necessary for the system start.
These include the various shells, the most important commands for working with files, and several commands for system analysis and configuration.
The following table provides an overview of the contents of the /bin/ directory:
|1||/bin/bash||The bash shell|
|4||/bin/dd||Copying files byte-wise|
|6||/bin/mount||Mounting file systems|
This directory and its subdirectories contain system configuration files. Almost all these files are ASCII files, which can be processed with any editor.
Normal users can read nearly all of these files, but they cannot edit any of them. According to the FHS, no executable programs can be located here.
However, the subdirectories contain many shell scripts. Some important configuration files are listed in the following table:
|1||/etc/SuSE-release||Version number of the installed SUSE Linux Enterprise Server|
|2||/etc/inittab||Configuration file for the init process|
|3||/etc/init.d/*||Scripts for starting services|
|4||/etc/grub/conf||Configuration file of GRUB|
|5||/etc/modules.conf||Configuration file of the kernel modules|
|6||/etc/DIR_COLORS||Specifies the colors for 1s.|
|7||/etc/X11/XF86config||Configuration file of the X window System.|
|8||/etc/fstab||Table of the file systems automatically mounted at the system start.|
|9||/etc/profile||Login script of the shell.|
|10||/etc/passwd||User database; all information except passwords.|
|11||/etc/shadow||Encrypted passwords of users.|
|12||/etc/group||Database of user groups.|
|13||/etc/cups/*||Files for the CUPS printing system.|
|14||/etc/hosts||Allocation of computer names to IP addresses.|
|15||/etc/motd||Welcome message after a user logs in (message of the day)|
|16||/etc/issue||Linux welcome message before the login prompt.|
|17||/etc/sysconfig/*||Central configuration files of the system.|
The directory /sbin/ contains important programs for system administration. Programs that are run by normal users as well as located in /bin/.
Programs in the directory /sbin/ can also, as a rule, be run by normal users, but only to display the configured values. Changes to the configuration can only be made by the user root.
The following is an overview of important files in the directory /sbin/.
|1||/sbin/SuSEconfig||Used to configure the overall system; evaluates entries in the configuration files in the directory/etc/sysconfig/ and writes further configuration files.|
|2||/sbin/conf.d*||Contains more scripts from the SuSEconfig family. They are called up by /sbin/SuSEconfig.|
|3||/sbin/yast||Administration tool for SUSE Linux Enterprise Server.|
|5||/sbin/fsck||Checks file systems (file system check).|
|6||/sbin/init||Initializes the system.|
|7||/sbin/mkfs||Creates a file system (formatting).|
|8||/sbin/shutdown||Shuts down the system.|
/usr Directory Files
The directory /usr/, in accordance with the FHS, represents a second hierarchical layer.
This is the location for all application programs, graphical interface files, additional libraries, locally installed programs, and commonly shared directories containing documentation.
These include the following:
|1||/usr/X11R6/||Files of the X Window System|
|3||/usr/bin/||Almost all executable programs|
|4||/usr/local/||Locally installed programs, now frequently found in the directory /opt/|
|5||/usr/sbin/||Programs for system administration|
|7||/usr/Share/man/||The manual pages (Command descriptions)|
|8||/usr/src/||Source files of all programs and the kernel (if installed)|
This directory and its subdirectories contain files are located that can be modified while the system is running.
The following table provides an overview of the most important directories beneath /var/:
|1||/var/lib/||Variable libraries (such as databases for the commands Locate and rpm)|
|2||/var/log/||Log files for most services|
|3||/var/run/||Files with information on running processes|
|4||/var/spool/||Directory for queues (printers,email)|
|5||/var/lock/||Lock files to protect devices from multiple use|
Linux handles process information that is made available to users via the directory /proc/. This directory does not contain any real files and therefore does not occupy and space on the hard disk.
It is generated dynamically when it is accessed. Each process has its own directory. The values in these directories can be read out as if they were in a file. Some values can also be set by writing to the corresponding files. Changes to this virtual file system only have an effect as long as the system is running.
In addition to directories for each individual process, /proc/ also includes directories and files containing information about the state of the system.
The following are the most important of these:
|1||/proc/cpuinfo||Information about the processor|
|2||/proc/dma||Use of the DMA ports (Direct Memory Access)|
|3||/proc/interrupts||Use of the interrupt|
|4||/proc/ioports||Use of the intrasystem I/O ports|
|5||/proc/filesystems||File system formats that the kernel understands|
|7||/proc/mounts||Mounted file systems|
|8||/proc/net/*||Network-specific information and statistics in human-readable form|
|10||/proc/pci||Existing PCI devices|
|11||/proc/scsi/||Connected SCSI devices|
|12||/proc/sys/*||System and kernel information|
Directories That Cannot Be Exported
The following directories cannot be exported. They must always be located locally on each computer.
|2||/boot/||Kernel and boot files|
|6||/sbin/||Important programs for system administration|
The following directories can be shared:
|3||/usr/||The Hierarchy below /usr/|
Each hardware component existing in the system such as hard drive partitions, CD drives, printer, and mouse is represented as a file in the directory /dev/.
The hardware components are addressed via these files by writing to or reading from one of these files. Two find of device files are included:
- Character-oriented device files – For devices working sequentially, such as Printer, Mouse or Tape Drive
- Block-oriented device files – Such as Floppy disks and hard drives
|The system console
The first virtual console, reachable with Ctrl+Alt+F1.
|The first serial port.|
|The first parallel port|
|4||Floppy disk drives||/dev/fd0<
|The first floppy disk drive. if the drives are addressed via the device files fd0 and fd1, the kernel tries to recognize the floppy disk format itself.|
|5||IDE hard drives||/dev/hda
|The first IDE hard drive on the first IDE controller.
The first IDE hard drive on the second IDE controller.
To label the partitions, the device names are given numbers.
|6||IDE CD-ROM drives||/dev/hd*||The drives are named in the same way as the IDE hard drives. This means that is the second drive on the second IDE controller.|
|8||SCSI hard drives||/dev/sda
|The first SCSI hard drive.
With SCSI hard drives, the device names are given numbers to label the various partitions. For example, is the first primary partition on the first SCSI hard drive.
|9||SCSI CD-ROM drives||/dev/scd0
|The first SCSI CD-ROM drive.|