LS Command – How Many Possible File Types in LS -L Output?

file-typesls

usually, the possible file types in the output ls -l command are d and -, which represent directory and regular file respectively.

besides above, I saw another type l in the output on 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 -> /

So, How many possible file types in the output ls -l command?

Best Answer

The filetypes reported by ls depends on the capabilities of the underlying filesystem, the operating system, and on the specific implementation of ls.

The l type is the common symbolic link file type.

This is (ought to be) documented in your ls manual.

On OpenBSD (macOS and AIX has the same list, but in another order):

-     regular file
b     block special file
c     character special file
d     directory
l     symbolic link
p     FIFO
s     socket link

On NetBSD (FreeBSD has the same without a and 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.

From info ls (i.e. the GNU ls manual):

‘-’
     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

On 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.
Related Question