Guide to Unix/Files

< Guide to Unix

/etc/


/etc/fstab

The fstab (for file systems table) file is commonly found on Unix and Unix-like systems and is part of the system configuration. The fstab file typically lists all used disks and disk partitions, and indicates how they are to be used or otherwise integrated into the overall system's file system.

Traditionally, the fstab was only read by programs, and not written to. However, more modern system administration tools can automatically build and edit fstab, or act as graphical editors for it. It is the duty of the system administrator to properly create and maintain this file.

The file may have other names on a given Unix variant; for example, it is /etc/vfstab on Solaris.

Example

The following is an example of a fstab file on a Red Hat Linux system:


# device name		mount point		fs-type	options		dump-freq pass-num
LABEL=/                 /                       ext3    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0

# my removable media
/dev/cdrom              /mnt/cdrom              udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0

# my NTFS Windows XP partition
/dev/hda1               /mnt/WinXP              ntfs    ro,defaults     0 0

/dev/hda6               swap                    swap    defaults        0 0

# my files partition shared by windows and linux
/dev/hda7               /mnt/shared             vfat    umask=000       0 0

( kudzu is an option specific to Red Hat and Fedora Core )

The first column indicates the device name or other means of locating the partition or data source. The second column indicates where the data is to be attached to the filesystem. The third column indicates the filesystem type, or algorithm to use to interpret the filesystem. The fourth column gives options, including if the filesystem should be mounted at boot. The fifth column adjusts the archiving schedule for the partition (used by dump). The sixth column indicates the order in which the fsck utility will scan the partitions for errors when the computer powers on. A value of zero in either of the last 2 columns disables the corresponding feature (http://www.humbug.org.au/talks/fstab/fstab_structure.html).

To get more information about the fstab file you can read the man page about it.

The Kfstab graphical configuration utility is available for KDE for editing fstab.

See also

/etc/group

/etc/group stores the definitive list of the users groups and their members.

A typical entry is:

root::0:root,alice

It has four sections which going from left to right are,

/etc/passwd

/etc/passwd is the user authentication database, it contains a list of users and their associated internal user id numbers. Historically it also included passwords, however as this file needs to world readable (so all programs can use it to convert between username and user id) it is no longer considered secure to keep passwords in this file.

An entry in this file is of the form:

alice:*:134:20:Alice Monkey:/home/alice/:/bin/bash

It has seven sections which going from left to right are,

/etc/profile

/etc/profile contains the system default settings for users who login using the Bourne shell, "/bin/sh". When these users login, the Bourne shell runs the commands in this file before giving the shell prompt to the user. Most of these commands are variable assignments which configure the behavior of the shell.

Some Bourne-compatible shells also use this file, but other shells, such as the C shell, do not.


/etc/shadow

/etc/shadow contains the passwords for users in systems which use shadowing.

alice:43SrweDe3F:621:5:30:10:100:900:

The sections are:

/etc/sysctl.conf

/etc/sysctl.conf configures the behavior of the running Unix kernel. During system boot, the scripts read this file and use "sysctl" to set the parameters shown in the file. Changing the file has no effect before the next reboot.

Files to be merged in to the list

/proc/

/var/

/boot/

/dev/

/dev/cdrom

/dev/cdrom is not an actual device, but on many systems it is a symbolic link to the actual CD device. For example, a Linux system with /dev/hdb for its floppy drive is likely to have a link /dev/cdrom which redirects to /dev/hdb.

/dev/fd*

At Linux, /dev/fd0 is the first floppy disk drive at the system. Use /dev/fd0H1440 to operate the first floppy drive in high density mode. Generally, this is invoked when formatting a floppy drive for a particular density. Slackware comes with drivers that allow for formatting a 3.5" diskette with up to 1.7MB of space. Red Hat and Mandrake do not contain these device driver files by default.

Likewise, /dev/fd1 is the second floppy disk drive.

/dev/hd*

At Linux, /dev/hda is the first IDE hard drive. The second drive is either /dev/hdb or /dev/hdc, depending on the hardware configuration. Some IDE hardware allows up to four drives, including /dev/hdd.

Many machines have one hard drive (hda) and one cdrom drive (hdc on many machines, but hdb on some). Often, /dev/cdrom is a symbolic link to the cdrom drive.

Partitions are numbered from 1, like /dev/hda1, /dev/hda2, ...

/dev/null

/dev/null is a do-nothing device to use when one wants to ignore or delete program output. This file is useful when a program expects to save to a file, but you want not to save anything. This file can also be used as input to a program to represent an empty file.

There is no actual hardware associated with the /dev/null device.

Examples:

Deleting file called "x" (command rm x) sometimes causes an error, for example if the file does not exist:

$ rm x
rm: x: No such file or directory

One can hide the error by redirecting it to a file. By using /dev/null as the file, the error never saves to an actual file.

Bourne shell:
$ rm x > /dev/null 2>&1

In the Bourne shell, the "2>&1" redirects the standard error of "rm" (where the error appears) to standard output, then the ">" redirects the standard output to /dev/null.

One way to make an empty file called "y" is:

$ cat /dev/null > y

The "cat" command copies the file "/dev/null" to standard output, and the shell operator ">" redirects this output to "y". The "/dev/null" file seems empty when read, so the file "y" appears, but is also empty. (Note that in this case, simply "> y" will do the same thing.)

Dot files

There is some redundancy across these programs. For example, the look and behavior of emacs can be customized by usinng the .emacs file, but also by adding the appropriate modifications to the .Xdefaults file. Default versions of these files are often installed in users' home directories when the software packages that use them are installed. If a program doesn't find its configuration file in the user's home directory, it will often fall back on a system-wide default configuration file installed in one of the subdirectories that the package lives in.

Directories

Different distributions have different directory structures, despite attempts at standardization such as the Linux Filesystem Hierarchy Standard (FHS) organization.

External link: Modified Directory Structure

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.