![输出“ls -l”命令中有多少种可能的文件类型?](https://linux22.com/image/159959/%E8%BE%93%E5%87%BA%E2%80%9Cls%20-l%E2%80%9D%E5%91%BD%E4%BB%A4%E4%B8%AD%E6%9C%89%E5%A4%9A%E5%B0%91%E7%A7%8D%E5%8F%AF%E8%83%BD%E7%9A%84%E6%96%87%E4%BB%B6%E7%B1%BB%E5%9E%8B%EF%BC%9F.png)
通常,输出命令中可能的文件类型ls -l
为d
和-
,分别代表目录和常规文件。
除此之外,我l
在 macOS 上的输出中看到了另一种类型。
drwxr-xr-x 8 yongjia staff 256 Aug 31 06:58 .
drwxr-xr-x 4 yongjia staff 128 Aug 30 11:31 ..
lrwxr-xr-x 1 root wheel 1 Aug 17 07:25 Macintosh HD -> /
那么,输出ls -l
命令中有多少种可能的文件类型?
答案1
报告的文件类型ls
取决于底层文件系统、操作系统的功能以及ls
.
类型l
是常见的符号链接文件类型。
这(应该)记录在您的ls
手册中。
在 OpenBSD 上(macOS 和 AIX 具有相同的列表,但顺序不同):
- regular file
b block special file
c character special file
d directory
l symbolic link
p FIFO
s socket link
在 NetBSD 上(FreeBSD 也有相同的,不带a
和A
):
- Regular file.
a Archive state 1.
A Archive state 2.
b Block special file.
c Character special file.
d Directory.
l Symbolic link.
p FIFO.
s Socket link.
w Whiteout.
来自info ls
(即GNUls
手册):
‘-’
regular file
‘b’
block special file
‘c’
character special file
‘C’
high performance (“contiguous data”) file
‘d’
directory
‘D’
door (Solaris 2.5 and up)
‘l’
symbolic link
‘M’
off-line (“migrated”) file (Cray DMF)
‘n’
network special file (HP-UX)
‘p’
FIFO (named pipe)
‘P’
port (Solaris 10 and up)
‘s’
socket
‘?’
some other file type
在 Solaris 11 上:
d
The entry is a directory.
D
The entry is a door.
l
The entry is a symbolic link.
b
The entry is a block special file.
c
The entry is a character special file.
p
The entry is a FIFO (or “named pipe”) special file.
P
The entry is an event port.
s
The entry is an AF_UNIX address family socket.
-
The entry is an ordinary file.
答案2
您可以info
通过执行以下操作在页面中找到该信息info coreutils 'ls invocation'
。在我的系统上,它包含以下摘录:
The file type is one of the following characters:
`-'
regular file
`b'
block special file
`c'
character special file
`C'
high performance ("contiguous data") file
`d'
directory
`D'
door (Solaris 2.5 and up)
`l'
symbolic link
`M'
off-line ("migrated") file (Cray DMF)
`n'
network special file (HP-UX)
`p'
FIFO (named pipe)
`P'
port (Solaris 10 and up)
`s'
socket
`?'
some other file type