After the regular, FIFO and socket file types, mknod can also create device files. These are used to access devices.
Granting access to devices is considered a privileged operation. Generally, we don't want to create arbitrary device nodes and make them accessible to regular users. That would be Bad.
[Aside: Typically device access is granted by changing the permissions on an existing device node instead. On standard Linux,
/dev/ is controlled by
udev, so you muck around with extra udev rules].
$ mount|grep -w /
/dev/mapper/vg_fossil-root on / type ext4 (rw,seclabel,data=ordered)
$ ls -l /dev/mapper/vg_fossil-root
lrwxrwxrwx. 1 root root 7 Jan 18 08:46 /dev/mapper/vg_fossil-root -> ../dm-0
$ ls -l /dev/dm-0
brw-rw----. 1 root disk 253, 0 Jan 18 08:46 /dev/dm-0
# mknod root-partition b 253 0
# chmod a+rw root-partition # make file available as if created as a normal user
Now I have direct access to the device which stores your filesystem.
$ ls -l root-partition
brw-rw-rw-. 1 root root 253, 0 Jan 18 15:05 root-partition
I can read data from files I wouldn't otherwise have permissions on
$ grep secret root-parition
Binary file root-partition matches
Or remove the "echo" in front of this next command, and your filesystem will no longer exist.
$ echo dd if=/dev/zero of=root-partition
After creating extra device files to play with, you can remove them safely without damaging anything.
$ rm root-partition
Unless of course you make a mistake and remove the wrong file, or perhaps literally all the files. This command will not provide undo/undelete or prompt for confirmation. The command line is unforgiving :). The sole protection is that without
*, it will not remove any directories.