Q. What is a char file and a block file? Is there any difference between them?
These both files are related to writing data and reading data from one place to other place. But the difference between them is how they read/write data.
character file: A char file is a hardware file which reads/write data in character by character fashion. Some classic examples are keyboard, mouse, serial printer. If a user use a char file for writing data no other user can use same char file to write data which blocks access to other user. Character files uses synchronise Technic to write data. Of you observe char files are used for communication purpose and they can not be mounted.
Example character files: /dev/autofs, /dev/console, /dev/crash, /dev/lp0, /dev/null, /dev/ppp, /dev/random, /dev/tty etc
ls -l output for a char file:
[root@yumserver dev]# ls -l tty0
crw–w—- 1 root root 4, 0 Dec 31 11:45 tty0
Block file: A block file is a hardware file which read/write data in blocks instead of character by character. This type of files are very much useful when we want to write/read data in bulk fashion. All our disks such are HDD, USB and CDROMs are block devices. This is the reason when we are formatting we consider block size. The write of data is done in asynchronous fashion and it is CPU intensive activity. These devices files are used to store data on real hardware and can be mounted so that we can access the data we written. Have a look at our other post on getting block size of a device.
Block file examples:/dev/loop0, /dev/ram0, /dev/sda1, /dev/sr0.
ls -l output for a block file
[root@yumserver dev]# ls -l sda1
brw-rw—- 1 root disk 8, 1 Dec 31 11:45 sda1
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
Anisble: ERROR! unexpected parameter type in action:
Fix- June 29, 2020
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018