In UNIX, files are divided into categories called types. The most common available file types are:
- f : regular files
- d : directory files
Type
f files contain a program or text and are created with an editor such as vi or a compiler such as cc.
The file named “letter” in your shell account is an example of a regular file. If you use the
ls –1
command to show a full listing of the file named “letter,”
you will see a dash as the very first character of the output.
The dash indicates this is a regular file.
When searching for a regular file using the
find
command, use the
–type f
option.
Type d files are directories, which are folders that contain other files. The course-project file in your shell account is an example of a directory file.
Use the
–ld
option with the
ls
command to show a full listing of the course-project directory file.
A
d is the very first character of the output, which indicates that this is a directory file, as shown in the examples below:
When searching for a directory file using the
find
command, use the
–type d
option.
The two most common file types are regular files and directories. Regular files are by far the most common type of files in a UNIX system, with program source, documents, executable programs, and scripts all being stored as regular files. One could argue that executable files are a special type of regular file but their handling by the filesystem is just the same, that is, the file contains a stream of bytes that the filesystem never needs to interpret.
Directories are different however. Although they also contain a stream of bytes, filesystems interpret these bytes in a manner that allows users to see which files are present in the directory and how they are linked together from a hierarchical perspective. There are other file types which must be considered by programmers and administrators.