Networking: A Beginner's Guide
mknod: Make Special Files
As discussed earlier, Linux accesses all of its devices through files. To create a file that
the system understands as an interface to a device, you must specify that the file is
of type block or character and has a major and minor number. To create this kind of
file with the necessary values, you use the mknod command. In addition to creating
interfaces to devices, you can use mknod to create named pipes.
The command's format is as follows:
[root@ford /root]# mknod name type [major] [minor]
where name is the name of the file; and type is the character b for block device, c for
character device, or p for named pipe. If you choose to create a block or character
device, you need to specify the major and minor number.
The only time you will need to create a block or character device is when installing
some kind of device driver that requires it. The documentation that comes with your
driver should tell you which values to use for the major and minor numbers.
For example, to create a named pipe called /tmp/mypipe, type the following:
[root@ford /root]# mknod /tmp/mypipe p
mkdir: Create a Home Directory
The mkdir command in Linux is identical to the one in other flavors of UNIX as well as
in MS-DOS. For example, to create a directory called mydir, type the following:
[root@ford /root]# mkdir mydir
The only option available is -p, which creates a parent directory if none exists. For
example, if you need to create /tmp/bigdir/subdir/mydir, and the only directory that
exists is /tmp, using -p will automatically create bigdir and subdir along with mydir.
Under Linux, you cannot abbreviate the mkdir command as md as you can under DOS.
rmdir: Remove Directory
The rmdir command offers no surprises if you are familiar with the DOS version of the
command. It simply removes an existing directory. For example, to remove a directory
called mydir, type the following:
[root@ford /root]# rmdir mydir
One command-line parameter available for this command is -p, which removes
parent directories as well. For example, if the directory /tmp/bigdir/subdir/mydir
exists and you want to get rid of all of the directories from bigdir to mydir, issue the
[root@ford /tmp]# rmdir -p bigdir/subdir/mydir