Computer History Notes - Herong's Tutorial Notes - v3.13, by Herong Yang
UNIX File System Hierarchy
This section provides a quick introduction of UNIX file system hierarchy.
On a UNIX system, almost all resources are represented as files in a single file system hierarchy.
For example, the first floppy disk drive is represented as a device file: /dev/fd0. Data can be read from and write to a floppy disk directly through /dev/fd0. But if a floppy disk has file system structure, it can also be mounted to the file system hierarchy.
The "df" command displays usage information of physical storage devices that are mounted on the current file system hierarchy:
#df Filesystem 1024-blocks Used Available Capacity Mounted on /dev/hda1 198275 134358 53672 71% / /dev/hda3 92333 1 87564 0% /mnt/backup /dev/df0 1676 960 716 57% /mnt/floppy
The output tells us that 3 storage devices with file systems are mounted on the file system hierarchy:
UNIX system also has a very interesting special file called /dev/null, representing an empty file for reading and a black hole for writing. /dev/null is very useful for truncating log files that are currently in use. Here is an example of commands to rotate the mail.log file once a day on a Solaris system:
#vi /usr/lib/newsyslog cd /var/log test -f mail.log.2 && mv mail.log.2 mail.log.3 test -f mail.log.1 && mv mail.log.1 mail.log.2 test -f mail.log.0 && mv mail.log.0 mail.log.1 mv mail.log mail.log.0 cp /dev/null /var/log/mail.log chmod 644 /var/log/mail.log kill -HUP `cat /etc/syslog.pid` #crontab -e root 59 23 * * 6 /usr/lib/newsyslog
Table of Contents