作为一个初学者,我在问如何知道文件在linux中是否特别?有什么命令可以显示这些数据吗?
发布于 2018-06-02 02:28:17
一种方法是使用file命令:
cd /dev
file tty这将输出如下所示:tty: character special
告诉您文件"tty“是一个特殊的字符型文件。也有块特价。
有关file命令的更多信息,请参见:man file或https://linux.die.net/man/1/file。
发布于 2018-06-02 02:23:31
如果您指的是device files,您可以使用file实用程序进行检查,例如:
$ file /dev/sda
/dev/sda: block special (8/0)
$ file /dev/null
/dev/null: character special (1/3)您还可以在-l中使用GNU ls
$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Jan 20 20:54 /dev/null
$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Jan 20 20:54 /dev/sda如文档中所述:
The file type is one of the following characters:
(...)
‘b’
block special file
‘c’
character special file或stat
$ stat /dev/sda
File: '/dev/sda'
Size: 0 Blocks: 0 IO Block: 4096 block special file
Device: 6h/6d Inode: 10245 Links: 1 Device type: 8,0
Access: (0660/brw-rw----) Uid: ( 0/ root) Gid: ( 6/ disk)
Access: 2018-01-20 20:54:41.153354807 +0100
Modify: 2018-01-20 20:54:41.153354807 +0100
Change: 2018-01-20 20:54:41.153354807 +0100
Birth: -
$ stat /dev/null
File: '/dev/null'
Size: 0 Blocks: 0 IO Block: 4096 character special file
Device: 6h/6d Inode: 1029 Links: 1 Device type: 1,3
Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-01-20 20:54:41.124354808 +0100
Modify: 2018-01-20 20:54:41.124354808 +0100
Change: 2018-01-20 20:54:41.124354808 +0100
Birth: -https://stackoverflow.com/questions/50648972
复制相似问题