Home COMSC-171 <- Prev Next ->

Files

A UNIX file is stored as a stream of bytes by the operating system. Additional structure may be added by application programs but has no meaning to UNIX itself.

A UNIX direcory (folder) is a special file which contains the names of other files and directories. The UNIX directories form a hierarchy based at / (root). Directory and file names are separated by the / character.

UNIX filenames may contain any characters except / (slash) and NUL (ASCII 0). UNIX filenames (and almost everything else in UNIX) are case sensitive. It is always safe to use the characters A-Z, a-z, 0-9, and _ (underscore). The characters . (dot), + (plus), and - (minus) may be used without problems unless they begin the filename. Filenames beginning with . are usually treated as hidden files and filenames beginning with + or - may be confused with command options. Length of filenames is almost unrestricted but very long names can get impractical.

The special name . (dot) refers to the current directory. The special name .. (dot dot) refers to the parent of the current directory (one level closer to root). An absolute pathname begins with / and is relative to /. A relative pathname does not begin with / and is relative to the current directory.

UNIX device drivers (code to control hardware) are treated as files which may be read and written in the same manner as ordinary disk files. Character devices are accessed one character at a time. Block devices (usually for mass storage) are accessed in blocks, commonly between 512 bytes and 4 kilobytes.

A UNIX filesystem is a mass storage unit roughly equivalent to a partition (or drive letter) in Windows. UNIX filesystems are all attached to a single directory hierarchy, usually on empty nodes. UNIX does not use drive letters. Some versions of UNIX recognize more than a hundred filesystem types.

The mount command is used without arguments to list the filesystems attached to the directory. With options and arguments mount can attach or detatch filesystems. The file /etc/fstab lists the characteristics of filesystems known to the system.