Wednesday, September 12, 2007

File type description

You must have used ls -l and recieved output something like this one.
-rw-r--r-- 1 jitendra jitendra 0 2007-07-28 19:19 mysqlaccess.log
drwxr-xr-x 11 jitendra jitendra 4096 2007-05-17 03:51 netbeans-5.5
-rw-r--r-- 1 root root 806 2007-05-04 13:49 python-defaults_2.5.1-0ubuntu3.dsc
-rw-r--r-- 1 jitendra jitendra 102447 2007-05-10 17:03 showthread.html
-rw-r--r-- 1 jitendra jitendra 29976 2007-09-06 18:02 ubuntu-files
-rw-r--r-- 1 jitendra jitendra 123 2007-08-26 21:11 version.h

Do you know what does the first characeter in the line denote? Basically, it denotes the file type. In the above output, you find '-' and 'd' as first characters but these are not the only ones. Let me tell you about the possible options and their meanings.
d         The entry is a directory.
As is clear, the entry denotes a directory.

D The entry is a door (Solaris).
The concept of door is derived from Solaris.

l The entry is a symbolic link.
Symbolic links are like shortcuts (M$-Windows naming convention).
l denotes
symbolic links. Use ln command to create symbolic links.

b The entry is a block special file.
As you may be aware that Linux treats every device as a file.
b denotes file
corresponding to block devices like disk partition,
RAM, etc.

c The entry is a character special file.
This is for another type of device called character devices. These
are not
hardware device. The entries falling under this category are
console, tty, etc.

p The entry is a FIFO (or "named pipe") special file.
Unlike normal files, "named pipe" do not contain any user information and
facilitate communication between two processes by reading/writing from/to

s The entry is an AF_UNIX address family socket.
As is clear, this file is for socket connection.The connection is internal
can't be invoked from outside.

- The entry is an ordinary file.
The files we create are generally of this type.
The text files, graphics and
all other are candidate of this type of file.

If you have never come across these symbols, use 'ls -l' in /dev directory. You will find most of them. However, if you are an end-user, you will never need to create files of type except '-', 'd' and 'l'.

What type of file types did you locate?

No comments: