Ls
輸出“ls -l”命令中有多少種可能的文件類型?
通常,輸出
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
命令中有多少種可能的文件類型?
報告的文件類型
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
andA
):- 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.