Unix file types

Unix file types

For normal files in the file system, Unix does not impose or provide any internal file structure. This implies that from the point of view of the operating system, there is only one file type.

The structure and interpretation thereof is entirely dependent on how the file is interpreted by software.

Unix does however have some special files. These special files can be identified by the ls -l command which displays the type of the file in the first alphabetic letter of the file system permissions field. A normal file is indicated by a dash ('-').

Contents

Regular file

Being the well known entity files are, files are also called "regular files" to distinguish them from "special files". They show up in ls -l without a specific character in the mode field:

$ ls -dl /etc/passwd
-rw-r-—r-- ... /etc/passwd

Directory

The most common special file is the directory. The layout of a directory file is defined by the filesystem used. As several filesystems, both native and non-native, are available under Unix, there is not one directory file layout.

A directory is marked with a d as the first letter in the mode field in the output of `ls -dl` or `stat`, e.g.

$ ls -dl /
drwxr-xr-x 26 root root 4096 Sep 22 09:29 /

$ stat /
  File: "/"
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 802h/2050d      Inode: 128         Links: 26
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
...

Symbolic link

A symbolic link is a reference to another file. This special file is stored as a textual representation of the referenced file's path (which means the destination may be a relative path, or may not exist at all).

A symbolic link is marked with an l (lower case L) as the first letter of the mode string, e.g.

lrwxrwxrwx ... termcap -> /usr/share/misc/termcap
lrwxrwxrwx ... S03xinetd -> ../init.d/xinetd

Named pipe

One of the strengths of Unix has always been interprocess communication. Amongst the facilities provided by the OS are so-called pipes. These pipes connect the output of one Unix process to the input of another. This is fine if both processes are living in the same parent process space, started by the same user. There are however circumstances where the communicating processes must use named pipes. One such circumstance is that the processes have to be executed under different user names and permissions.

These named pipes are special files that can exist anywhere in the file system. These named pipe special files are made with the command mkfifo as in mkfifo mypipe.

A named pipe is marked with a p as the first letter of the mode string, e.g.

prw-rw---- ... mypipe

Socket

A socket is a special file used for inter-process communication. These allow communication between two processes. In addition to sending data, processes can send file descriptors across a Unix domain socket connection using the sendmsg() and recvmsg() system calls.

Unlike named pipes sockets are fully duplex-capable.

A socket is marked with an s as the first letter of the mode string, e.g.

srwxrwxrwx ... /tmp/.X11-unix/X0

Device file

In Unix almost all things are handled as files and have a location in the file system — even hardware devices like hard drives. The great exception for devices and the files that represent them are network devices that do not turn up in the file system but are handled separately.

Device files are used to apply access rights and to direct operations on the files to the appropriate device drivers.

Unix makes a distinction between character devices and block devices. The distinction is roughly as follows:

  • character devices provide only a serial stream of input or output;
  • block devices are randomly accessible;

although, for example, disk partitions may have both character devices that provide unbuffered random access to blocks on the partition and block devices that provide buffered random access to blocks on the partition.

A character device is marked with a c as the first letter of the mode string. Likewise, a block device is marked with a b, e.g.

crw------- ... /dev/null
brw-rw---- ... /dev/sda

Door

A door is a special file for inter-process communication between a client and server, currently implemented in the Sun Solaris operating system only.

A door is marked with a D (upper case) as the first letter of the mode string, e.g.

Dr--r--r-- ... name_service_door

Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Unix — (officially trademarked as UNIX, sometimes also written as Unix with small caps) is a computer operating system originally developed in 1969 by a group of AT T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and… …   Wikipedia

  • File (Unix) — file is a standard Unix program for determining the type of data contained in a computer file. History The original version of file originated in Unix Research Version 4 [See [http://www.darwinsys.com/file/file v4.1.txt] this copy of the UNIX V4… …   Wikipedia

  • File — has several meanings:* Filing cabinet * File (tool) * A nail file * Filing (legal) * Filing (manufacturing process) * File (formation) Military term for a single column of men one in front of the other. See also Rank (formation) * File (chess) *… …   Wikipedia

  • File format — A file format is a particular way that information is encoded for storage in a computer file. Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice …   Wikipedia

  • Unix shell — A Unix shell, is a command line shell that provides the traditional user interface for the Unix operating system and for Unix like systems. Users direct the operation of the computer by entering command input as text for a command line… …   Wikipedia

  • File manager — For the Windows 3.x file manager, see File Manager (Windows). A file manager or file browser is a computer program that provides a user interface to work with file systems. The most common operations performed on files or groups of files are:… …   Wikipedia

  • File System — Système de fichiers Pour les articles homonymes, voir FS et SGF. Un système de fichiers (file system ou filesystem en anglais) ou système de gestion de fichiers (SGF) est une structure de données permettant de stocker les informations et de les… …   Wikipédia en Français

  • File system — Système de fichiers Pour les articles homonymes, voir FS et SGF. Un système de fichiers (file system ou filesystem en anglais) ou système de gestion de fichiers (SGF) est une structure de données permettant de stocker les informations et de les… …   Wikipédia en Français

  • File Allocation Table — For other uses, see Fat (disambiguation). FAT Developer Microsoft Full Name File Allocation Table FAT12 (12‑bit version) FAT16/FAT16B (16‑bit versions) FAT32 (32‑bit version with 28 bits used) Introduced …   Wikipedia

  • File shortcut — A file shortcut in Microsoft Windows is a small file containing a target URI or GUID to an object, or the name of a target program file that the shortcut represents. The shortcut might additionally specify parameters to be passed to the target… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”