Chapter 5. Device Files

Table of Contents
The MAKEDEV Script
The mknod command
Device List

This chapter gives an overview of what a device file is, and how to create one. It also lists some of the more common device files. The canonical list of device files is /usr/src/linux/Documentation/devices.txt if you have the Linux kernel source code installed on your system. The devices listed here are correct as of kernel version 2.2.17.

The MAKEDEV Script

Most device files will already be created and will be there ready to use after you install your Linux system. If by some chance you need to create one which is not provided then you should first try to use the MAKEDEV script. This script is usually located in /dev/MAKEDEV but might also have a copy (or a symbolic link) in /sbin/MAKEDEV. If it turns out not to be in your path then you will need to specify the path to it explicitly.

In general the command is used as:

	# /dev/MAKEDEV -v ttyS0
	create ttyS0   c 4 64 root:dialout 0660
	
This will create the device file /dev/ttyS0 with major node 4 and minor node 64 as a character device with access permissions 0660 with owner root and group dialout.

ttyS0 is a serial port. The major and minor node numbers are numbers understood by the kernel. The kernel refers to hardware devices as numbers, this would be very difficult for us to remember, so we use filenames. Access permissions of 0660 means read and write permission for the owner (root in this case) and read and write permission for members of the group (dialout in this case) with no access for anyone else.