Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

find(1)



          ls(1)                INTERACTIVE UNIX System                ls(1)



          NAME
               ls, lc - list contents of directory

          SYNOPSIS
               ls [-RadCxmlnogrtucpFbqisf] [ names ]
               lc [-RadxmlnogrtucpFbqisf] [ names ]

          DESCRIPTION
               For each directory argument, ls lists the contents of the
               directory; for each file argument, ls repeats its name and
               any other information requested.  The output is sorted
               alphabetically by default.  When no argument is given, the
               current directory is listed.  When several arguments are
               given, the arguments are first sorted appropriately, but
               file arguments appear before directories and their contents.

               lc is a synonym for ls with the -C option set.  There are
               three major listing formats.  The default format is to list
               one entry per line, the -C and -x options enable multi-
               column formats, and the -m option enables stream output for-
               mat.  In order to determine output formats for the -C, -x,
               and -m options, ls uses an environment variable, COLUMNS, to
               determine the number of character positions available on one
               output line.  If this variable is not set, the terminfo(4)
               data base is used to determine the number of columns, based
               on the environment variable TERM.  If this information can-
               not be obtained, 80 columns are assumed.

               The ls command has the following options:

               -R   Recursively list subdirectories encountered.

               -a   List all entries, including those that begin with a dot
                    (.), which are normally not listed.

               -d   If an argument is a directory, list only its name (not
                    its contents); often used with -l to get the status of
                    a directory.

               -C   Multi-column output with entries sorted down the
                    columns (default setting for lc ).

               -x   Multi-column output with entries sorted across rather
                    than down the page.

               -m   Stream output format; files are listed across the page,
                    separated by commas.

               -l   List in long format, giving mode, number of links,
                    owner, group, size in bytes, and time of last modifica-
                    tion for each file (see below).  If the file is a spe-
                    cial file, the size field will instead contain the
                    major and minor device numbers rather than a size.


          Rev. 1.2                                                   Page 1





          ls(1)                INTERACTIVE UNIX System                ls(1)



               -n   The same as -l, except that the owner's UID and group's
                    GID numbers are printed, rather than the associated
                    character strings.

               -o   The same as -l, except that the group is not printed.

               -g   The same as -l, except that the owner is not printed.

               -r   Reverse the order of sort to get reverse alphabetic or
                    oldest first as appropriate.

               -t   Sort by time stamp (latest first) instead of by name.
                    The default is the last modification time.  (See -n and
                    -c.)

               -u   Use time of last access instead of last modification
                    for sorting (with the -t option) or printing (with the
                    -l option).

               -c   Use time of last modification of the inode (file
                    created, mode changed, etc.) for sorting (-t) or print-
                    ing (-l).

               -p   Put a slash (/) after each file name if that file is a
                    directory.

               -F   Put a slash (/) after each file name if that file is a
                    directory and put an asterisk (*) after each file name
                    if that file is executable.

               -b   Force printing of non-printable characters to be in the
                    octal \ddd notation.

               -q   Force printing of non-printable characters in file
                    names as the character question mark (?).

               -i   For each file, print the i-number in the first column
                    of the report.

               -s   Give size in blocks, including indirect blocks, for
                    each entry.

               -f   Force each argument to be interpreted as a directory
                    and list the name found in each slot.  This option
                    turns off -l, -t, -s, and -r, and turns on -a; the
                    order is the order in which entries appear in the
                    directory.

               The mode printed under the -l option consists of ten charac-
               ters.  The first character may be one of the following:

                    d   the entry is a directory;
                    b   the entry is a block special file;


          Rev. 1.2                                                   Page 2





          ls(1)                INTERACTIVE UNIX System                ls(1)



                    c   the entry is a character special file;
                    m   the entry is a XENIX shred data (memory) file;
                    p   the entry is a fifo (a.k.a. "named pipe") special
                        file;
                    s   the entry is a XENIX semaphore;
                    -   the entry is an ordinary file.

               The next 9 characters are interpreted as three sets of three
               bits each.  The first set refers to the owner's permissions;
               the next to permissions of others in the user-group of the
               file; and the last to all others.  Within each set, the
               three characters indicate permission to read, to write, and
               to execute the file as a program, respectively.  For a
               directory, "execute" permission is interpreted to mean per-
               mission to search the directory for a specified file.

               ls -l (the long list) prints its output as follows:

                   -rwxrwxrwx  1 smith  dev    10876  May 16 9:42 part2

               This horizontal configuration provides a good deal of infor-
               mation.  Reading from right to left, you see that the
               current directory holds one file, named "part2."  Next, the
               last time that file's contents were modified was 9:42 A.M.
               on May 16.  The file is moderately sized, containing 10,876
               characters, or bytes.  The owner of the file, or the user,
               belongs to the group "dev" (perhaps indicating "develop-
               ment"), and his or her login name is "smith."  The number,
               in this case "1," indicates the number of links to file
               "part2."  Finally, the row of dash and letters tell you that
               user, group, and others have permissions to read, write,
               execute "part2."

               The execute (x) symbol here occupies the third position of
               the three-character sequence.  A - in the third position
               would have indicated a denial of execution permissions.

               The permissions are indicated as follows:

                    r   the file is readable
                    w   the file is writable
                    x   the file is executable
                    -   the indicated permission is not granted
                    l   mandatory locking will occur during access (the
                        set-group-ID bit is on and the group execution bit
                        is off)
                    s   the set-user-ID or set-group-ID bit is on, and the
                        corresponding user or group execution bit is also
                        on
                    S   undefined bit-state (the set-user-ID bit is on and
                        the user execution bit is off)
                    t   the 1000 (octal) bit, or sticky bit, is on [see
                        chmod(1)], and execution is on


          Rev. 1.2                                                   Page 3





          ls(1)                INTERACTIVE UNIX System                ls(1)



                    T   the 1000 bit is turned on, and execution is off
                        (undefined bit-state)

               For user and group permissions, the third position is some-
               times occupied by a character other than x or -.  s also may
               occupy this position, referring to the state of the set-ID
               bit, whether it be the user's or the group's.  The ability
               to assume the same ID as the user during execution is, for
               example, used during login when you begin as root but need
               to assume the identity of the user stated at "login."

               In the case of the sequence of group permissions, l may
               occupy the third position.  l refers to mandatory file and
               record locking.  This permission describes a file's ability
               to allow other files to lock its reading or writing permis-
               sions during access.


               For others permissions, the third position may be occupied
               by t or T.  These refer to the state of the sticky bit and
               execution permissions.

          EXAMPLES
               An example of a file's permissions is:

                    -rwxr--r--

               This describes a file that is readable, writable, and exe-
               cutable by the user and readable by the group and others.

               Another example of a file's permissions is:

                    -rwsr-xr-x

               This describes a file that is readable, writable, and exe-
               cutable by the user, readable and executable by the group
               and others, and allows its user-ID to be assumed, during
               execution, by the user presently executing it.

               Another example of a file's permissions is:

                    -rw-rwl---

               This describes a file that is readable and writable only by
               the user and the group and can be locked during access.

               An example of a command line:

                    ls -a

               This command will print the names of all files in the
               current directory, including those that begin with a dot
               (.), which normally do not print.


          Rev. 1.2                                                   Page 4





          ls(1)                INTERACTIVE UNIX System                ls(1)



               Another example of a command line:

                    ls -aisn

               This command will provide you with quite a bit of informa-
               tion including all files, including non-printing ones (a),
               the i-number-the memory address of the inode associated with
               the file-printed in the left-hand column (i); the size (in
               blocks) of the files, printed in the column to the right of
               the i-numbers (s); finally, the report is displayed in the
               numeric version of the long list, printing the UID (instead
               of user name) and GID (instead of group name) numbers asso-
               ciated with the files.

               When the sizes of the files in a directory are listed, a
               total count of blocks, including indirect blocks, is
               printed.

          FILES
               /etc/passwd              user IDs for ls -l and ls -o
               /etc/group               group IDs for ls -l and ls -g
               /usr/lib/terminfo/?/*    terminal information database

          SEE ALSO
               chmod(1), find(1).

          BUGS
               Unprintable characters in file names may confuse the colum-
               nar output options.


























          Rev. 1.2                                                   Page 5



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026