For command ls
-F, --classify
append indicator (one of */=>@|) to entries
Wikipedia says *
represents executable and /
dir.
Regular files are not followed by any of the above symbols.
But *
follows text file and pdf file too. Are they executables?
Do the -F
indicators always mean same as the first field in -rwxrwx---
?
It seems like there is no difference between hardlinks and the files in either the -F
indicators or the first field in -rwxrwx---
. How do you distinguish them?
Thanks.
Best Answer
ls -F
will:GNU ls includes additional signals:
=
is also present in the major BSDs (FreeBSD, OpenBSD, NetBSD, OS X). All of those but OpenBSD also include%
for whiteouts. Most of the commercial Unices include=
, but it is non-standard.A
*
will appear after a file if it is marked as executable — that is, if the executable bit is set. It doesn't necessarily mean you could actually run the file. You can unset the executable bit withchmod -x
; generally you won't want text files and PDFs to be executable, so you could do that. Executable files will also have thex
inls -l
output.For the others:
/
indicates a directory, which is pretty straightforward.|
indicates a FIFO, which is a named pipe made withmkfifo
(data can be written into it, and read back exactly once).@
indicates a symbolic link made withln -s
, which is an alias for another path.=
indicates a socket, a special file for communicating with other processes.>
for doors is another inter-process communication feature from some systems.%
for whiteouts indicates a special file used to mark deletions made in upper layers of a union filesystem stack.A "regular file" is what you'd conventionally think of as a file, one that you can write data into and read it back later. Alternatively, you can think of it as anything that isn't in one of the above categories.
Hard links are not distinguished from other files at all, either in
ls -F
output or otherwise. In fact, you can think of every file as a hard link to itself. You can look at the number of links to a given file in thels -l
output. The second field is the number of links:This file has three links. None of them is the "main" link, and you can't tell which one is the original in any way. If you delete one, the count will go down, but the others will still refer to the same file.
All of the
-F
indicators other than*
do map onto one of the values of the first field of the mode output inls -l
, but there are additional values that can appear there as well, notablyb
for block devices,c
for character devices, and other system-specific indicators.