Book Image

Linux Shell Scripting Essentials

By : Sinny Kumari, Khem Raj
Book Image

Linux Shell Scripting Essentials

By: Sinny Kumari, Khem Raj

Overview of this book

Table of Contents (15 chapters)
Linux Shell Scripting Essentials
About the Author
About the Reviewers

Special files

The files other than regular files, directories, and link files are special files. They are as follows:

  • The block device file

  • The character device file

  • The named pipe file

  • The socket file

The block device file

A block device file is a file that reads and writes data in block. Such files are useful when data needs to be written in bulk. Devices such as hard disk drive, USB drive, and CD-ROM are considered as block device files. Data is written asynchronously and, hence, other users are not blocked to perform the write operation at the same time.

To create a block device file, mknod is used with the option b along with providing a major and minor number. A major number selects which device driver is being called to perform the input and output operation. A minor number is used to identify subdevices:

$ sudo mknod  block_device b 0X7 0X6

Here, 0X7 is a major number and 0X6 is a minor number in hexadecimal format:

$ ls -l block_device
brw-r--r--. 1 root root 7, 6 Aug 24 12:21 block_device...