Unix File Types

Unix recognizes the following types of files:

Regular file
Text or binary data (e.g. an image).
Directory
Contains other files and directories.
Executable file
File with the "execute bit" set. Most commands are executable files.
Symbolic link
File is a "shortcut" that points to another file.
Device special file
An interface to a piece of hardware, such as a printer. You don't have to worry about this.
Named pipe
An interface to a network program. You don't have to worry about this.

Distinguishing Files

Use ls -F (fancy listing) or ls -l (long listing):

(~/tmp) 119% ls -F
answers/                 dump_grades*             problem_set_2.txt
current_assignment.txt@  problem_set_1.txt        problems/
(~/tmp) 120% ls -l
total 8
drwxrwxr-x   2 lstein       1024 Aug 29 22:58 answers/
lrwxrwxrwx   1 lstein         17 Aug 29 23:00 current_assignment.txt -> problem_set_2.txt
-rwxr-xr-x   1 lstein        359 Aug 29 23:05 dump_grades*
-rw-r--r--   1 lstein       1381 Aug 29 22:59 problem_set_1.txt
-rw-r--r--   1 lstein       2323 Aug 29 22:59 problem_set_2.txt
drwxrwxr-x   2 lstein       1024 Aug 29 22:58 problems/

With -F, regular files are listed normally, directories get a "/" appended to the end, symbolic links get an "@" appended to the end, and executable files get a "*".

The -l option creates a long listing which gives the file's owner, modification date, name, and permissions (the bizarre-looking first column). Symbolic links show a little arrow followed by the file or directory the link points to.

The file permission display should be interpreted this way:

 flags  owner group  world
   |    ---    ---    ---
   d    rwx    rwx    r-x   2 lstein    1024 Aug 29 22:58 problems/
flags
"d" = directory
"l" = link
"p" = pipe
"b" = block special device
"c" = character special device
owner
Permissions for the owner of the file/directory:
"r" = read permission
"w" = write permission
"x" = execute permissin
group
Permissions for the group owner of the file/directory.
world
Permissions for everyone else

For files, read, write, and execute permission do what you think they might do. For directories, read permission lets you list the contents of the directory, write permission lets you create or delete files in the directory, while execute permission lets you cd to the directory.

See the manual page on chmod for more information about file permissions.


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Sat Oct 9 18:18:47 EDT 1999