In a Linux environment, the device files are in the/dev directory, and the device files do not occupy disk blocks to store the data, so the device files are not size, but the metadata is identified on the Inode table. The metadata contains the device number of the appliance.
Device number is the main device good, secondary device number, the main device number indicates the device type. Device file chunking device file (b), character device file (c).
Block devices randomly access devices by block
Character devices are linearly accessed in character units
b HDD
C keyboard
The main device number major is used to identify the device type
Secondary device number Ninor numbers identify different devices of the same type
Block devices
[Email protected] ~]# ll-h/dev/|grepsdlrwxrwxrwx. 1Root root4June7 -: +RootSDA2BRW-RW----.1Root disk8,0June7 -: +SDABRW-RW----.1Root disk8,1June7 -: +SDA1BRW-RW----.1Root disk8,2June7 -: +SDA2BRW-RW----.1Root disk8,3June7 -: +SDA3BRW-RW----.1Root disk8,4June7 -: +SDA4BRW-RW----.1Root disk8,5June7 -: +SDA5BRW-RW----.1Root disk8,6June7 -: +Sda6
The main device number is 8,0~6 identify different partitions
Character device--virtual terminal
Ll-h/dev/|greptty[[:d igit:]]*$--colorlrwxrwxrwx. 1Root root4June7 -: +SysttyTTY0CRW-rw-rw-.1Root TTY5,0June7 -: +TTYCRW--W----.1Root TTY4,0June7 -: +TTY0CRW-------.1Root root4,1June7 -: +TTY1CRW--W----.1Root TTY4,TenJune7 -: +TTY10CRW--W----.1Root TTY4, OneJune7 -: +Tty11
Character device--analog terminal
grep pts[[:d igit:]]*$--colordrwxr-xr-x. 2 root root 0 June 7: pts
command who to see how many people are currently linked to Linux. I opened 2 windows using the Xshell link linux,xshell. At this point, redhat in VMware Workstation is just booting and not landing.
Command who am I to see which terminal I am currently using
[Email protected] ~]#W.H.O.Root pts/0 2018- .- - -: A(192.168.80.1) root pts/1 2018- .- - -: .(192.168.80.1) [[email protected]~]#W.H.O.am iroot pts/0 2018- .- - -: A(192.168.80.1)
VMWare workstation Redhat Landing in execution of appeal order
[Email protected] ~]#W.H.O.Root Tty12018- .- - -: ,Root pts/0 2018- .- - -: A(192.168.80.1) root pts/1 2018- .- - -: .(192.168.80.1) [[email protected]~]#W.H.O.am iroot pts/0 2018- .- - -: A(192.168.80.1)
Create a character device file, specify the main device number 66, secondary device number 0
Mknod the 0 ~]# ll/dev/zqcrw10 June 7: Dev/zq
In fact, the device files in the environment do not need to be created manually, as long as the device is connected, Linux will automatically assign the primary and secondary device number when booting. You should not normally send data directly to the device, which is dangerous. The following demo sends a message to the device file
Here's a dangerous command.
Break the first partition of the disk
Echo " execute this command after your Linux system restarts or shuts down after the next boot, it will not start properly. ">>/dev/~]# reboot
Messing up the entire disk
Echo " execute this command after your Linux system restarts or shuts down after the next boot, it will not start properly. ">>/dev/~]# reboot
Because writing data to the disk SDA, the MBR is directly overwritten, causing the MBR to get corrupted. If you do not restart the system, nothing is done. Once the system is restarted, it will never get in again.
Linux Disk Management--device files