Pawan Sharma | August 25, 2012 | Be the first to comment!

Files and Types of files in RHEL6

In this post we will discuss different types of files in Redhat Enterprise Linux 6. There are 7 types of files in Linux. As we all know "everything in Linux is a file". Linux treat everything as file, also hardware devices like CPU, Memory, keyboard, mouse and even a process is also considered as a file. A directory (aka folder) is also considered as a file containing list of files. Whenever a file is created in Linux it gets an inode number (index inode) which contains information like owner, file type, permission, date of creation etc.

To check the type of file we can use “ls -l” command :

# ls -l /erc/passwd
-rw-r--r-- 1 root root 3363 Aug 12 17:25 /etc/passwd

The above command give different information about a file, like its owner, group, creation time, permission etc, we will discuss it in another post. The very first character represents type of file, in the above example the first character is a "-" which indicates that it is a regular file.

There are seven types of files in Linux.

  1. REGULAR Files (-): Regular files are represented by “-“ in ls -l command output. Regular files are common files containing text like scripts or data. 
  2.  DIRECTORIES (d): Directories are represented by “d”. As mentioned above directories are special files that contains list of other files. 
  3. SYMBOLIC Links (l): Symbolic links are represented by “l”. A symbolic link is a reference to another file or in common language it is shortcut to another file. 
  4. NAMED PIPE (p): Named pipes are represented by “p”. Named pipes are like sockets for communication between processes. 
  5. SOCKET (s): These are represented by “s” Sockets are special files that provides inter process networking. 
  6. CHARACTER Device Files (c): Character device files are represented by “c”. These files represent devices which read/write 0 or more bytes in a stream like TTY or keyboard. 
  7. BLOCK Device Files (b): Block device files are represented by “b”. Block device can read/write bytes in a fixed size blocks like HDD or a partition.

Each type of file represented by different color in terminal. Like

       File Type               Colour
  • Regular File          White
  • Directory               Blue
  • Symbolic Link        Cyan
  • Socket                   Purple
  • Named Pipes         Red
  • Device File            Yellow 
File types in Linux
Type of files in RHEL 6
For any questions please feel free to comment.

No comments:

Post a Comment