why device files do not open with vim or nano
root@heena:/dev/disk/by-label# ls
PENDRIVE System\x20Reservednow when I open PENDRIVE using vim or nano, I get an empty file.
but I understand that everything is file in linux including pendrive.
Question is why nano or vim is unable to open and show the real content of the file, if even devices are considered as file in linux?
1 Answer
You are right, everything is file in Linux. But vim or nano can not handle those types of files. So when you open them they shows empty. Actually they contain info in a manner that is not human readable.
If you try to open with emacs like
sudo emacs <file>You get the message,
File exists, but can not be read.If you wish to see what is inside try,
sudo cat /dev/disk/by-level/<file>You could see different random characters.
Note:
The file at /dev/disk/by-level/<file> is actually a softlink to /dev/sdbx. You can see using this in terminal,
$ ls -l /dev/disk/by-level/<file>
lrwxrwxrwx 1 root root 10 Jan 7 17:33 /dev/disk/by-label/<file> -> ../../sdbx