What does the first dash mean in an ls -l output?

18

2

From the bash man pages about viewing permissions with ls:

User    ls output
Owner   -rwx------
Group   ----rwx---
Other   -------rwx

That makes sense, but what is the first - used for then? It's always blank in all the user contexts.

David says Reinstate Monica

Posted 2016-08-30T14:57:37.123

Reputation: 952

6

Pedantically speaking, the vast majority of http://ss64.com/bash/ has absolutely nothing to do with Bash. Most of those are external programs accessible from any shell or even from exec()-type calls from programming languages such as C or Python. Practically, one might think of them as "Bash commands", but it's useful and important to understand the difference, especially when writing scripts, for example, that might be run on systems other than Linux or even among different distributions of Linux.

– Paused until further notice. – 2016-08-30T16:26:45.353

Answers

35

The first dash - indicates that the file is a regular file.

GNU Coreutils: 10.1.2 What information is listed

These options affect the information that ls displays. By default, only file names are shown.

...

‘-l’
‘--format=long’
‘--format=verbose’

In addition to the name of each file, print the file type, file mode bits, number of hard links, owner name, group name, size, and timestamp (see Formatting file timestamps), normally the modification time. Print question marks for information that cannot be determined.

...

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

Steven

Posted 2016-08-30T14:57:37.123

Reputation: 24 804

2When I first saw the documentation for a Door file on Solaris, I immediately set about creating a Door! – Mark Stewart – 2016-08-31T02:33:09.110

2Were you successful? – Steven – 2016-08-31T03:10:31.457

7Yes, but I didn't know how to use it! But at least I saw the D – Mark Stewart – 2016-08-31T05:02:31.753

12

It'll be a d for a directory, l for a symbolic link, c for a character device, b for a block device, p for a FIFO (first-in first-out special file), s for a socket.

Nicole Hamilton

Posted 2016-08-30T14:57:37.123

Reputation: 8 987