List directory contents (POSIX)
ls [-1CFRacdilqrstu] [-DLSbfghnopv] [file...]
QNX Neutrino, Microsoft Windows
||||FIFOs (named pipes)|
|#||Named special files (QNX Neutrino extension)|
|@||Symbolic links (QNX Neutrino extension)|
drwxrwxrwx 7 0 0 22528 Jan 17 15:38 Csrc -rw-rw-rw- 1 0 0 22 Feb 14 13:41 barney -rwxrwxrwx 1 0 0 22 Feb 14 13:41 exec -rw-rw-rw- 1 0 0 22 Feb 14 13:41 fred drwxrwxrwx 2 0 0 23040 Feb 12 10:56 libtests drwxrwxrwx 2 0 0 2048 Sep 28 06:39 util
To see a header above the columns, use the -h option.
Note that the 10-character field (e.g. “drwxrwxrwx”) describes the filetype and permissions (see below).
|QNX Neutrino currently supports only the POSIX (i.e. C) locale.|
|If you're using Qnet, doing something like ls -R /net can take a very long time because it recursively lists all the directories on all the machines on your network.|
For each file you name that isn't a directory, ls displays the file's name as well as any information requested on the file.
For each directory you name, ls displays the names of files contained within that directory, as well as any information requested on the files. The -d option overrides this behavior and makes ls display information on the directory itself, rather than on its contents.
If you specify more than one file, ls displays files that aren't directories first. Directories and nondirectories are sorted separately.
If you don't specify a file, ls displays the contents of the current directory.
Specifying more than one of the -C, -l (“el”), and -1 (“one”) options isn't considered an error. The last option specified determines the output format.
In many environments, the ls command is “aliased” to either ls -C or ls -CF, the two most common ls display formats. Unless the POSIX_STRICT environment variable is set, ls defaults to the multi-column output (-C option).
The -p option is useful for passing a list of all nondirectory filenames, one filename per line, to other programs. The filenames include the full pathnames.
When displaying a timestamp for a file, ls displays the date and time, unless the file is older or newer than the current date by six months (a “month” is defined as 30 days). Otherwise, ls displays the date and year.
If you use the -l (“el”) or -s option — or the -n, -g, or -o options, which imply them — and you list a directory, the output includes the total number of 512-byte blocks that the directory occupies. This total doesn't include the space occupied by any subdirectories. For example:
$ ls -l /etc/rc.d total 28 -rwxrwxr-x 1 root root 1515 Apr 30 2001 rc.devices -rwxrwxr-x 1 root root 354 Apr 08 14:37 rc.local -rwxrwxr-x 1 root root 321 Dec 23 2004 rc.local~ -rwxrwxr-x 1 root root 6767 May 31 2001 rc.setup-info -rwxrwxr-x 1 root root 2993 May 07 2002 rc.setup-once -rwxrwxr-x 1 root root 1271 Apr 21 2002 rc.sysinit
In the long format (-l option), the 10-character field (e.g.“drwxrwxrwx”) describes the filetype and permissions. The first character represents the filetype; the rest of the characters represent the read/write/executable permissions for the owner, group, and other classes.
In the first position, the following characters are used to indicate the filetype:
|b||Block special file|
|c||Character special file|
|n||Named special file|
|s||Unix domain socket|
The remaining nine characters represent the owner, group, and other permissions; each class has a three-character field. For each class, the characters and the first two positions are as follows:
|First||r or -||The file is readable or not|
|Second||w or -||The file is writable or not|
For the third position, several characters are possible:
|S||If a file, it isn't executable and is setuid (if
in the owner field) or setgid (if in the
If a directory, it isn't searchable. All files within that directory inherit the permissions of the directory, not of the creator of the files.
|s||The file is executable or the directory is searchable. The user/group ID modes are set, and the directory-driven inheritance is as with S.|
|T||Sticky bit is set and x isn't set.|
|t||Sticky bit is set and x is set.|
|x||The file is executable or the directory is searchable.|
|-||None of the attributes (S, s, T, t, or x) applies.|
chmod, find, which
Working with Files in the Neutrino User's Guide