coreutils: What information is listed
10.1.2 What information is listed
---------------------------------
These options affect the information that ‘ls’ displays. By default,
only file names are shown.
‘--author’
List each file’s author when producing long format directory
listings. In GNU/Hurd, file authors can differ from their owners,
but in other operating systems the two are the same.
‘-D’
‘--dired’
With the long listing (‘-l’) format, print an additional line after
the main output:
//DIRED// BEG1 END1 BEG2 END2 ...
The BEGN and ENDN are unsigned integers that record the byte
position of the beginning and end of each file name in the output.
This makes it easy for Emacs to find the names, even when they
contain unusual characters such as space or newline, without fancy
searching.
If directories are being listed recursively (‘-R’), output a
similar line with offsets for each subdirectory name:
//SUBDIRED// BEG1 END1 ...
Finally, output a line of the form:
//DIRED-OPTIONS// --quoting-style=WORD
where WORD is the quoting style (⇒Formatting the file
names).
Here is an actual example:
$ mkdir -p a/sub/deeper a/sub2
$ touch a/f1 a/f2
$ touch a/sub/deeper/file
$ ls -gloRF --dired a
a:
total 8
-rw-r--r-- 1 0 Jun 10 12:27 f1
-rw-r--r-- 1 0 Jun 10 12:27 f2
drwxr-xr-x 3 4096 Jun 10 12:27 sub/
drwxr-xr-x 2 4096 Jun 10 12:27 sub2/
a/sub:
total 4
drwxr-xr-x 2 4096 Jun 10 12:27 deeper/
a/sub/deeper:
total 0
-rw-r--r-- 1 0 Jun 10 12:27 file
a/sub2:
total 0
//DIRED// 48 50 84 86 120 123 158 162 217 223 282 286
//SUBDIRED// 2 3 167 172 228 240 290 296
//DIRED-OPTIONS// --quoting-style=literal
Note that the pairs of offsets on the ‘//DIRED//’ line above
delimit these names: ‘f1’, ‘f2’, ‘sub’, ‘sub2’, ‘deeper’, ‘file’.
The offsets on the ‘//SUBDIRED//’ line delimit the following
directory names: ‘a’, ‘a/sub’, ‘a/sub/deeper’, ‘a/sub2’.
Here is an example of how to extract the fifth entry name,
‘deeper’, corresponding to the pair of offsets, 222 and 228:
$ ls -gloRF --dired a > out
$ dd bs=1 skip=222 count=6 < out 2>/dev/null; echo
deeper
Note that although the listing above includes a trailing slash for
the ‘deeper’ entry, the offsets select the name without the
trailing slash. However, if you invoke ‘ls’ with ‘--dired’ along
with an option like ‘--escape’ (aka ‘-b’) and operate on a file
whose name contains special characters, notice that the backslash
_is_ included:
$ touch 'a b'
$ ls -blog --dired 'a b'
-rw-r--r-- 1 0 Jun 10 12:28 a\ b
//DIRED// 30 34
//DIRED-OPTIONS// --quoting-style=escape
If you use a quoting style that adds quote marks (e.g.,
‘--quoting-style=c’), then the offsets include the quote marks. So
beware that the user may select the quoting style via the
environment variable ‘QUOTING_STYLE’. Hence, applications using
‘--dired’ should either specify an explicit
‘--quoting-style=literal’ option (aka ‘-N’ or ‘--literal’) on the
command line, or else be prepared to parse the escaped names.
‘--full-time’
Produce long format directory listings, and list times in full. It
is equivalent to using ‘--format=long’ with ‘--time-style=full-iso’
(⇒Formatting file timestamps).
‘-g’
Produce long format directory listings, but don’t display owner
information.
‘-G’
‘--no-group’
Inhibit display of group information in a long format directory
listing. (This is the default in some non-GNU versions of ‘ls’, so
we provide this option for compatibility.)
‘-h’
‘--human-readable’
Append a size letter to each size, such as ‘M’ for mebibytes.
Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes.
This option is equivalent to ‘--block-size=human-readable’. Use
the ‘--si’ option if you prefer powers of 1000.
‘-i’
‘--inode’
Print the inode number (also called the file serial number and
index number) of each file to the left of the file name. (This
number uniquely identifies each file within a particular file
system.)
‘-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 (⇒Formatting file timestamps), normally the
modification timestamp (the mtime, ⇒File timestamps). If
the owner or group name cannot be determined, print the owner or
group ID instead, right-justified as a cue that it is a number
rather than a textual name. Print question marks for other
information that cannot be determined.
Normally the size is printed as a byte count without punctuation,
but this can be overridden (⇒Block size). For example, ‘-h’
prints an abbreviated, human-readable count, and
‘--block-size="'1"’ prints a byte count with the thousands
separator of the current locale.
For each directory that is listed, preface the files with a line
‘total BLOCKS’, where BLOCKS is the total disk allocation for all
files in that directory. The block size currently defaults to 1024
bytes, but this can be overridden (⇒Block size). The BLOCKS
computed counts each hard link separately; this is arguably a
deficiency.
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
The file mode bits listed are similar to symbolic mode
specifications (⇒Symbolic Modes). But ‘ls’ combines
multiple bits into the third character of each set of permissions
as follows:
‘s’
If the set-user-ID or set-group-ID bit and the corresponding
executable bit are both set.
‘S’
If the set-user-ID or set-group-ID bit is set but the
corresponding executable bit is not set.
‘t’
If the restricted deletion flag or sticky bit, and the
other-executable bit, are both set. The restricted deletion
flag is another name for the sticky bit. ⇒Mode
Structure.
‘T’
If the restricted deletion flag or sticky bit is set but the
other-executable bit is not set.
‘x’
If the executable bit is set and none of the above apply.
‘-’
Otherwise.
Following the file mode bits is a single character that specifies
whether an alternate access method such as an access control list
applies to the file. When the character following the file mode
bits is a space, there is no alternate access method. When it is a
printing character, then there is such a method.
GNU ‘ls’ uses a ‘.’ character to indicate a file with a security
context, but no other alternate access method.
A file with any other combination of alternate access methods is
marked with a ‘+’ character.
‘-n’
‘--numeric-uid-gid’
Produce long format directory listings, but display right-justified
numeric user and group IDs instead of left-justified owner and
group names.
‘-o’
Produce long format directory listings, but don’t display group
information. It is equivalent to using ‘--format=long’ with
‘--no-group’ .
‘-s’
‘--size’
Print the disk allocation of each file to the left of the file
name. This is the amount of disk space used by the file, which is
usually a bit more than the file’s size, but it can be less if the
file has holes.
Normally the disk allocation is printed in units of 1024 bytes, but
this can be overridden (⇒Block size).
For files that are NFS-mounted from an HP-UX system to a BSD
system, this option reports sizes that are half the correct values.
On HP-UX systems, it reports sizes that are twice the correct
values for files that are NFS-mounted from BSD systems. This is
due to a flaw in HP-UX; it also affects the HP-UX ‘ls’ program.
‘--si’
Append an SI-style abbreviation to each size, such as ‘M’ for
megabytes. Powers of 1000 are used, not 1024; ‘M’ stands for
1,000,000 bytes. This option is equivalent to ‘--block-size=si’.
Use the ‘-h’ or ‘--human-readable’ option if you prefer powers of
1024.
‘-Z’
‘--context’
Display the SELinux security context or ‘?’ if none is found. When
used with the ‘-l’ option, print the security context to the left
of the size column.