Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod

ctab

find

environment

ls

PURPOSE

     Displays the contents of a directory.

SYNOPSIS
     ls [ -RadCxmlnogrtucpFbqisf ] [ names ]


DESCRIPTION

     The ls command writes to  standard output the contents of
     each specified  directory or  the name of  each specified
     file, along with  any other information you  ask for with
     the flags.  If you do not specify a file or directory, ls
     displays the contents of the current directory.

     By  default, ls  displays all  information in  alphabetic
     order by file name.  The collating sequence is determined
     by the  NLCTAB environment variable (see  "ctab").  Indi-
     vidual file names are listed before directory names.

     There are three main ways to format the output:

     o   List one entry per line.  This is the default format.
     o   List entries in multiple columns by specifying either
         the -C or -x flags.
     o   List entries  in a  comma-separated series  by speci-
         fying the -m flag.

     To  determine the  number of  character positions  in the
     output line,  ls uses  the environment  variable COLUMNS.
     If this variable is not  set, it reads the terminfo file.

     If ls cannot determine  the number of character positions
     by either  of these methods,  it uses a default  value of
     80.

     The mode  displayed with  the -l  flag is  interpreted as
     follows:

     If the first character is:

     d  The entry is a directory.
     b  The entry is a block special file.
     c  The entry is a character special file.
     p  The entry is a first-in first-out (FIFO) special file.
     -  The entry is an ordinary file.
     D  The entry is a remote directory.
     F  The entry is a remote ordinary file.
     B  The entry is a remote block special file.
     C  The entry is a remote character special file.
     P  The  entry  is  a  remote  first-in  first-out  (FIFO)
        special file.

     The next nine  characters are divided into  three sets of
     three characters  each.  The first three  characters show
     the owner's permission.  The next set of three characters
     show the permission of the other users in the group.  The
     last set of  three characters show the  permission of any
     one else with  access to the file.   The three characters
     in each  set show read,  write and execute  permission of
     the  file.  Execute  permission of  a directory  lets you
     search a directory for a specified file.

     Permissions are indicated as follows:

     r  You can read the file.
     w  You can edit (write) the file.
     x  You can search the file.
     -  You do not have permission to the file.

     The group-execute  permission character is s  if the file
     has set-group ID mode.  The user-execute permission char-
     acter is  s if the  file has set-user-ID mode.   The last
     character of the mode (normally x  or -) is t if the 1000
     (octal)  bit of  the mode  is  set; see  "chmod" for  the
     meaning of this mode.  The indications of set-ID and 1000
     bit of the mode are capitalized (S and T respectively) if
     the corresponding execute permission is not set.

     When the size of the files in a directory are listed, the
     ls command  displays a  total count of  blocks, including
     indirect blocks.

     The environment variables NLLDATE  and NLTIME control the
     format of  the date  and time.  The  environment variable
     NLSMONTH controls the short names of months.

FLAGS

     -a Lists  all  entries  in the  directory  including  the
        entries that begin with a . (dot).

     -b Displays  nonprintable  characters  in an  octal  \nnn
        notation.
     -c Uses the time of last modification of the i-node (file
        created, mode  changed, and  so on) for  sorting (when
        used with -t)  or for displaying (when  used with -l).
        This flag has  no effect when not used  with either -t
        or -l or both.
     -C Sorts output vertically in a multi-column format.
     -d Displays only the information for the directory named.
        This is useful with the -l flag to get the status of a
        directory.
     -f Lists the name in each  slot for each named directory.
        This flag turns  off -l, -t, -s, and -r,  and turns on
        -a; the order is the  order in which entries appear in
        the directory.
     -F Puts a / (slash) after each file name if the file is a
        directory and  an "*" (asterisk) after  each file name
        if the file can be executed.
     -g Displays the  same information as with  -l, except for
        the owner.
     -i Displays  the  i-number in  the  first  column of  the
        report for each file.
     -k Displays the  permission codes,  node ID,  remote UID,
        remote  GID,  time  of  last  modification,  size  (in
        bytes), and file name for remote entries.

        For remote files and  directories, the local owner and
        local  group are  obtained by  using inverse  IDs.  If
        there is no  inverse ID or if ls  cannot determine the
        inverse ID,  a - (minus  sign) displays in  the corre-
        sponding field.  If possible, remote nodes are identi-
        fied with  nicknames.  Otherwise, they  are identified
        by their NID displayed in hexadecimal.  (See "Distrib-
        uted Services Concepts" in  Managing the AIX Operating
        System.)

        For local  files and  directories that  do not  have a
        nickname defined  for the local  node ID, the  node ID
        field displays  as a -  (minus sign), and the  raw UID
        (GID) field contains the local owner UID (group GID).
     -l Displays the mode, number of links, owner, group, size
        (in  bytes), and  time of  last modification  for each
        file.  If the  file is a special file,  the size field
        will  instead  contain  the  major  and  minor  device
        numbers.
     -m Uses stream output format (a comma-separated series).
     -n Displays the same information  as with -l, except that
        it displays the user and  the group IDs instead of the
        user and group names.
     -o Displays the  same information as with  -l, except for
        the group.
     -p Puts a  slash after each file  name if that file  is a
        directory.  This is useful when you pipe the output of
        ls to the pr command as follows:

          ls -p | pr -5 -t -w80

     -q Displays nonprintable characters in  file names as the
        character ?.

     -r Reverses the order of  the sort, giving reverse alpha-
        betic or the oldest first, as appropriate.
     -R Lists all subdirectories recursively.
     -s Gives size  in blocks (including indirect  blocks) for
        each entry.
     -t Sorts  by time  of  last  modification (latest  first)
        instead of by name.
     -u Uses the  time of the  last access instead of  time of
        the last modification for  sorting (when used with -t)
        or for displaying (when used  with -l).  This flag has
        no effect when not used with either -t or -l or both.
     -x Sorts output horizontally in a multi-column format.

EXAMPLES

     1.  To list all files in the current directory:

           ls  -a

         This    lists   all    files,   including    . (dot),
         .. (dot-dot),  and other  files with  names beginning
         with a dot.
     2.  To display detailed information:

           ls  -l  chap1  .profile

         This displays  a long listing with  detailed informa-
         tion about "chap1" and .profile.
     3.  To display detailed information about a directory:

           ls  -d  -l  .  manual  manual/chap1

         This displays  a long  listing for the  directories .
         and  "manual",  and   for  the  file  "manual/chap1".
         Without the -d flag, this would list the files in "."
         and  "manual"  instead  of the  detailed  information
         about the directories themselves.
     4.  To list the files in order of modification time:

           ls  -l  -t

         This displays a  long listing of the  files that were
         modified most recently, followed by the older files.

FILES

     /etc/passwd             Contains user IDs.
     /etc/group              Contains group IDs.
     /usr/lib/terminfo/*     Contains terminal information.

RELATED INFORMATION

     The following commands:  "chmod,"  "ctab," and "find."

     The environment  miscellaneous facility in  AIX Operating
     System Technical Reference.

     "Overview of International Character Support" in Managing
     the AIX Operating System.

     "Distributed Services Concepts" in Managing the AIX Oper-
     ating System.

VOLUME 2

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