- Back to Home »
- Linux Basic »
- Linux /dev directory
Thursday, July 2, 2015
Thư mục /dev trong linux là một thư mục đặc biệt chứa tất cả các device file, để xem được bên trong /dev có gì bạn dùng lệnh:
$ ls -l /dev/
total 0
crw-------. 1 root root 10, 235 Jul 2 20:18 autofs
drwxr-xr-x. 2 root root 240 Jul 3 2015 block
drwxr-xr-x. 2 root root 80 Jul 3 2015 bsg
crw-------. 1 root root 10, 234 Jul 2 20:18 btrfs-control
drwxr-xr-x. 3 root root 60 Jul 3 2015 bus
lrwxrwxrwx. 1 root root 3 Jul 2 20:18 cdrom -> sr0
drwxr-xr-x. 2 root root 3720 Jul 2 20:18 char
crw-------. 1 root root 5, 1 Jul 2 20:18 console
lrwxrwxrwx. 1 root root 11 Jul 3 2015 core -> /proc/kcore
drwxr-xr-x. 6 root root 140 Jul 2 20:18 cpu
crw-------. 1 root root 10, 62 Jul 2 20:18 cpu_dma_latency
drwxr-xr-x. 5 root root 100 Jul 3 2015 disk
drwxr-xr-x. 2 root root 100 Jul 3 2015 dri
crw-rw----. 1 root video 29, 0 Jul 2 20:18 fb0
lrwxrwxrwx. 1 root root 13 Jul 3 2015 fd -> /proc/self/fd
crw-rw-rw-. 1 root root 1, 7 Jul 2 20:18 full
crw-rw-rw-. 1 root root 10, 229 Jul 2 20:18 fuse
crw-------. 1 root root 247, 0 Jul 2 20:18 fw0
crw-------. 1 root root 250, 0 Jul 2 20:18 hidraw0
crw-------. 1 root root 10, 228 Jul 2 20:18 hpet
drwxr-xr-x. 2 root root 0 Jul 2 20:18 hugepages
prw-------. 1 root root 0 Jul 2 20:18 initctl
drwxr-xr-x. 4 root root 500 Jul 2 20:18 input
crw-r--r--. 1 root root 1, 11 Jul 2 20:18 kmsg
crw-rw----+ 1 root root 10, 232 Jul 2 20:18 kvm
srw-rw-rw-. 1 root root 0 Jul 3 2015 log
crw-rw----. 1 root disk 10, 237 Jul 2 20:18 loop-control
crw-rw----. 1 root lp 6, 0 Jul 2 20:18 lp0
crw-rw----. 1 root lp 6, 1 Jul 2 20:18 lp1
crw-rw----. 1 root lp 6, 2 Jul 2 20:18 lp2
crw-rw----. 1 root lp 6, 3 Jul 2 20:18 lp3
drwxr-xr-x. 2 root root 60 Jul 3 2015 mapper
crw-------. 1 root root 10, 227 Jul 2 20:18 mcelog
crw-------. 1 root root 245, 0 Jul 2 20:18 media0
crw-------. 1 root root 246, 0 Jul 2 20:18 mei0
crw-r-----. 1 root kmem 1, 1 Jul 2 20:18 mem
crw-------. 1 root root 10, 59 Jul 2 20:18 memory_bandwidth
drwxrwxrwt. 2 root root 40 Jul 3 2015 mqueue
drwxr-xr-x. 2 root root 60 Jul 2 20:18 net
crw-------. 1 root root 10, 61 Jul 2 20:18 network_latency
crw-------. 1 root root 10, 60 Jul 2 20:18 network_throughput
crw-rw-rw-. 1 root root 1, 3 Jul 2 20:18 null
crw-------. 1 root root 10, 144 Jul 2 20:18 nvram
crw-r-----. 1 root kmem 1, 4 Jul 2 20:18 port
crw-------. 1 root root 108, 0 Jul 2 20:18 ppp
crw-rw-rw-. 1 root tty 5, 2 Jul 2 21:06 ptmx
crw-------. 1 root root 248, 0 Jul 2 20:18 ptp0
drwxr-xr-x. 2 root root 0 Jul 3 2015 pts
crw-rw-rw-. 1 root root 1, 8 Jul 2 20:18 random
drwxr-xr-x. 2 root root 60 Jul 3 2015 raw
lrwxrwxrwx. 1 root root 4 Jul 3 2015 resume -> sda7
crw-rw-r--+ 1 root root 10, 55 Jul 2 20:18 rfkill
lrwxrwxrwx. 1 root root 4 Jul 2 20:18 rtc -> rtc0
crw-------. 1 root root 254, 0 Jul 2 20:18 rtc0
brw-rw----. 1 root disk 8, 0 Jul 2 20:18 sda
brw-rw----. 1 root disk 8, 1 Jul 2 20:18 sda1
brw-rw----. 1 root disk 8, 2 Jul 2 20:18 sda2
brw-rw----. 1 root disk 8, 3 Jul 2 20:18 sda3
brw-rw----. 1 root disk 8, 5 Jul 2 20:18 sda5
brw-rw----. 1 root disk 8, 6 Jul 2 20:18 sda6
brw-rw----. 1 root disk 8, 7 Jul 2 20:18 sda7
brw-rw----. 1 root disk 8, 8 Jul 2 20:18 sda8
brw-rw----. 1 root disk 8, 9 Jul 2 20:18 sda9
crw-rw----. 1 root disk 21, 0 Jul 2 20:18 sg0
crw-rw----+ 1 root cdrom 21, 1 Jul 2 20:18 sg1
drwxrwxrwt. 2 root root 120 Jul 2 21:06 shm
crw-------. 1 root root 10, 231 Jul 2 20:18 snapshot
drwxr-xr-x. 3 root root 280 Jul 2 20:18 snd
brw-rw----+ 1 root cdrom 11, 0 Jul 2 20:18 sr0
lrwxrwxrwx. 1 root root 15 Jul 3 2015 stderr -> /proc/self/fd/2
lrwxrwxrwx. 1 root root 15 Jul 3 2015 stdin -> /proc/self/fd/0
lrwxrwxrwx. 1 root root 15 Jul 3 2015 stdout -> /proc/self/fd/1
crw-------. 1 root root 10, 224 Jul 2 20:18 tpm0
crw-rw-rw-. 1 root tty 5, 0 Jul 2 20:18 tty
crw--w----. 1 root tty 4, 0 Jul 2 20:18 tty0
crw--w----. 1 root tty 4, 1 Jul 2 20:18 tty1
crw--w----. 1 root tty 4, 10 Jul 2 20:18 tty10
crw--w----. 1 root tty 4, 11 Jul 2 20:18 tty11
crw--w----. 1 root tty 4, 12 Jul 2 20:18 tty12
crw--w----. 1 root tty 4, 13 Jul 2 20:18 tty13
crw--w----. 1 root tty 4, 14 Jul 2 20:18 tty14
crw--w----. 1 root tty 4, 15 Jul 2 20:18 tty15
crw--w----. 1 root tty 4, 16 Jul 2 20:18 tty16
crw--w----. 1 root tty 4, 17 Jul 2 20:18 tty17
crw--w----. 1 root tty 4, 18 Jul 2 20:18 tty18
crw--w----. 1 root tty 4, 19 Jul 2 20:18 tty19
crw--w----. 1 root tty 4, 2 Jul 2 20:18 tty2
crw--w----. 1 root tty 4, 20 Jul 2 20:18 tty20
crw--w----. 1 root tty 4, 21 Jul 2 20:18 tty21
crw--w----. 1 root tty 4, 22 Jul 2 20:18 tty22
crw--w----. 1 root tty 4, 23 Jul 2 20:18 tty23
crw--w----. 1 root tty 4, 24 Jul 2 20:18 tty24
crw--w----. 1 root tty 4, 25 Jul 2 20:18 tty25
crw--w----. 1 root tty 4, 26 Jul 2 20:18 tty26
crw--w----. 1 root tty 4, 27 Jul 2 20:18 tty27
crw--w----. 1 root tty 4, 28 Jul 2 20:18 tty28
crw--w----. 1 root tty 4, 29 Jul 2 20:18 tty29
crw--w----. 1 root tty 4, 3 Jul 2 20:18 tty3
crw--w----. 1 root tty 4, 30 Jul 2 20:18 tty30
crw--w----. 1 root tty 4, 31 Jul 2 20:18 tty31
crw--w----. 1 root tty 4, 32 Jul 2 20:18 tty32
crw--w----. 1 root tty 4, 33 Jul 2 20:18 tty33
crw--w----. 1 root tty 4, 34 Jul 2 20:18 tty34
crw--w----. 1 root tty 4, 35 Jul 2 20:18 tty35
crw--w----. 1 root tty 4, 36 Jul 2 20:18 tty36
crw--w----. 1 root tty 4, 37 Jul 2 20:18 tty37
crw--w----. 1 root tty 4, 38 Jul 2 20:18 tty38
crw--w----. 1 root tty 4, 39 Jul 2 20:18 tty39
crw--w----. 1 root tty 4, 4 Jul 2 20:18 tty4
crw--w----. 1 root tty 4, 40 Jul 2 20:18 tty40
crw--w----. 1 root tty 4, 41 Jul 2 20:18 tty41
crw--w----. 1 root tty 4, 42 Jul 2 20:18 tty42
crw--w----. 1 root tty 4, 43 Jul 2 20:18 tty43
crw--w----. 1 root tty 4, 44 Jul 2 20:18 tty44
crw--w----. 1 root tty 4, 45 Jul 2 20:18 tty45
crw--w----. 1 root tty 4, 46 Jul 2 20:18 tty46
crw--w----. 1 root tty 4, 47 Jul 2 20:18 tty47
crw--w----. 1 root tty 4, 48 Jul 2 20:18 tty48
crw--w----. 1 root tty 4, 49 Jul 2 20:18 tty49
crw--w----. 1 root tty 4, 5 Jul 2 20:18 tty5
crw--w----. 1 root tty 4, 50 Jul 2 20:18 tty50
crw--w----. 1 root tty 4, 51 Jul 2 20:18 tty51
crw--w----. 1 root tty 4, 52 Jul 2 20:18 tty52
crw--w----. 1 root tty 4, 53 Jul 2 20:18 tty53
crw--w----. 1 root tty 4, 54 Jul 2 20:18 tty54
crw--w----. 1 root tty 4, 55 Jul 2 20:18 tty55
crw--w----. 1 root tty 4, 56 Jul 2 20:18 tty56
crw--w----. 1 root tty 4, 57 Jul 2 20:18 tty57
crw--w----. 1 root tty 4, 58 Jul 2 20:18 tty58
crw--w----. 1 root tty 4, 59 Jul 2 20:18 tty59
crw--w----. 1 root tty 4, 6 Jul 2 20:18 tty6
crw--w----. 1 root tty 4, 60 Jul 2 20:18 tty60
crw--w----. 1 root tty 4, 61 Jul 2 20:18 tty61
crw--w----. 1 root tty 4, 62 Jul 2 20:18 tty62
crw--w----. 1 root tty 4, 63 Jul 2 20:18 tty63
crw--w----. 1 root tty 4, 7 Jul 2 20:18 tty7
crw--w----. 1 root tty 4, 8 Jul 2 20:18 tty8
crw--w----. 1 root tty 4, 9 Jul 2 20:18 tty9
crw-rw----. 1 root dialout 4, 64 Jul 2 20:18 ttyS0
crw-rw----. 1 root dialout 4, 65 Jul 2 20:18 ttyS1
crw-rw----. 1 root dialout 4, 66 Jul 2 20:18 ttyS2
crw-rw----. 1 root dialout 4, 67 Jul 2 20:18 ttyS3
crw-------. 1 root root 10, 239 Jul 2 20:18 uhid
crw-------. 1 root root 10, 223 Jul 2 20:18 uinput
crw-rw-rw-. 1 root root 1, 9 Jul 2 20:18 urandom
drwxr-xr-x. 2 root root 60 Jul 3 2015 usb
crw-------. 1 root root 251, 0 Jul 2 20:18 usbmon0
crw-------. 1 root root 251, 1 Jul 2 20:18 usbmon1
crw-------. 1 root root 251, 2 Jul 2 20:18 usbmon2
drwxr-xr-x. 4 root root 80 Jul 2 20:18 v4l
crw-------. 1 root root 10, 58 Jul 2 20:18 vboxdrv
crw-------. 1 root root 10, 57 Jul 2 20:18 vboxdrvu
crw-------. 1 root root 10, 56 Jul 2 20:18 vboxnetctl
drwxr-x---. 4 root vboxusers 80 Jul 2 20:18 vboxusb
crw-rw----. 1 root tty 7, 0 Jul 2 20:18 vcs
crw-rw----. 1 root tty 7, 1 Jul 2 20:18 vcs1
crw-rw----. 1 root tty 7, 2 Jul 2 20:18 vcs2
crw-rw----. 1 root tty 7, 3 Jul 2 20:18 vcs3
crw-rw----. 1 root tty 7, 4 Jul 2 20:18 vcs4
crw-rw----. 1 root tty 7, 5 Jul 2 20:18 vcs5
crw-rw----. 1 root tty 7, 6 Jul 2 20:18 vcs6
crw-rw----. 1 root tty 7, 128 Jul 2 20:18 vcsa
crw-rw----. 1 root tty 7, 129 Jul 2 20:18 vcsa1
crw-rw----. 1 root tty 7, 130 Jul 2 20:18 vcsa2
crw-rw----. 1 root tty 7, 131 Jul 2 20:18 vcsa3
crw-rw----. 1 root tty 7, 132 Jul 2 20:18 vcsa4
crw-rw----. 1 root tty 7, 133 Jul 2 20:18 vcsa5
crw-rw----. 1 root tty 7, 134 Jul 2 20:18 vcsa6
drwxr-xr-x. 2 root root 60 Jul 2 20:18 vfio
crw-------. 1 root root 10, 63 Jul 2 20:18 vga_arbiter
crw-------. 1 root root 10, 137 Jul 2 20:18 vhci
crw-------. 1 root root 10, 238 Jul 2 20:18 vhost-net
crw-rw----+ 1 root video 81, 0 Jul 2 20:18 video0
crw-------. 1 root root 10, 130 Jul 2 20:18 watchdog
crw-------. 1 root root 253, 0 Jul 2 20:18 watchdog0
crw-------. 1 root root 253, 1 Jul 2 20:18 watchdog1
crw-rw-rw-. 1 root root 1, 5 Jul 2 20:18 zero
/dev/fd0
Đĩa mềm
/dev/fb0
Framebuffer device.
/dev/hda
/dev/hda is the master IDE drive on the primary IDE controller. /dev/hdb the slave drive on the primary controller. /dev/hdc , and /dev/hdd are the master and slave devices on the secondary controller respectively
/dev/psaux
The PS/2 mouse port.
/dev/random or /dev/urandom
These are kernel random number generators. /dev/random is a non-deterministic generator which means that the value of the next number cannot be guessed from the preceding ones. It uses the entropy of the system hardware to generate numbers. When it has no more entropy to use then it must wait until it has collected more before it will allow any more numbers to be read from it. /dev/urandom works similarly. Initially it also uses the entropy of the system hardware, but when there is no more entropy to use it will continue to return numbers using a pseudo random number generating formula. This is considered to be less secure for vital purposes such as cryptographic key pair generation. If security is your overriding concern then use /dev/random, if speed is more important then /dev/urandom works fine. They are character devices on major node 1 with minor nodes 8 for /dev/random and 9 for /dev/urandom.
/dev/sda
The first SCSI drive on the first SCSI bus. The following drives are named similar to IDE drives. /dev/sdb is the second SCSI drive, /dev/sdc is the third SCSI drive, and so forth.
/dev/ttyS0
The first serial port.
/dev/input/*
Mouse and keyboard,...
/dev/zero
This is a simple way of getting many 0s. Every time you read from this device it will return 0. This can be useful sometimes, for example when you want a file of fixed length but don't really care what it contains. It is a character device on major node 1 and minor node 5.
/dev/null
The bit bucket. A black hole where you can send data for it never to be seen again. Anything sent to /dev/null will disappear. This can be useful if, for example, you wish to run a command but not have any feedback appear on the terminal. It is a character device on major node 1 and minor node 3.
Bài viết liên quan:
+ File System
+ Device file
+ Wiki