What happens if you delete a device file?

Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)

If some command/service already opened that file, it already has a handle to the device and will continue working.

If some command/service tries to open a new connection, it will try to access that file and fail because of "file not found".

Usually those files are populated by udev, which automatically creates them at system startup and on special events like plugging in a USB device, but you could also manually create those using mknod.


Device files are actually a filesystem alias for an entry in the kernel's device table. If you look at the /dev files with "ls -l" you'll see they have a major device number and a minor device number. If you delete the files from the filesystem, you can always recreate them using the appropriate tools to relink the special file to the entry in the kernel device table -- see mknod(1).


From that moment on, they can only be accessed by programs that had those devices already open. So, it's no way to unmount filesystems. And with udev, a reboot might restore those devices. A strange way to learn unix.