Getting Started : The File System

File System Structure

The Unix file structure is hierarchical, with the / (root) directory being the highest level. The following diagram represents a typical Unix file system.

Figure 1 Example of a Typical Unix System File Structure

/bin
Contains commands and utilities used regularly. They are mainly binary executable files, hence the name. Typical examples in this directory would be cp, cd, mkdir.
/dev
Contains special files used to represent real physical devices, such as disks and terminals.
/etc
Contains various files and commands used for system administration, for example initialization files for users.
/lib
Contains libraries used by various programs and programming languages.
/tmp
Acts as a workspace area for all users to temporarily store (possibly very large) files.
/usr
Contains miscellaneous directories. May contain user files in a large system.

 

Filenames may contain up to 255 characters, although a sensible limit (allowing for portability between different Unix systems) is 14 characters. Almost any character may be used within a filename, but it is recommended that only letters, numbers, dots (.), hyphens (-) and underscores (_) are used. Do not use hyphens at the beginning of a filename, and note that filenames beginning with a dot (.) are treated as special files. The filename is simply a set of characters. There is no concept of the filetype or file extension as seen in other operating systems (VAX/VMS or MSDOS for example), although certain commands will assume that files end in a particular sequence of characters. For example, the f77 Fortran compiler assumes that the source files end with .f.

Examples of Filenames

The following are valid Unix filenames; each name refers to a different file.

data1982      data.1982     addfil.f
gordonmes     GORDONMES     gordonMES

Wildcard Characters to Match Filenames

The following wildcard characters may be used when referring to groups of files.

* matches any sequence of zero or more characters

? matches any single character

[string] matches any of the characters in string

Examples

data* finds all files beginning with data

*data* finds all files containing data

data19?? finds all 8-character filenames beginning with data19

data198[268] finds data1982, data1986 and data1988