| 1 | .TH LS 1 |
| 2 | .SH NAME |
| 3 | ls \- list contents of directory |
| 4 | .SH SYNOPSIS |
| 5 | .B ls |
| 6 | [ |
| 7 | .B \-ltasdrucifg |
| 8 | ] name ... |
| 9 | .SH DESCRIPTION |
| 10 | For each directory argument, |
| 11 | .I ls |
| 12 | lists the contents of the directory; |
| 13 | for each file argument, |
| 14 | .I ls |
| 15 | repeats its name and any other information requested. |
| 16 | The output is sorted alphabetically by default. |
| 17 | When no argument is given, the current directory is listed. |
| 18 | When several arguments are given, |
| 19 | the arguments are first sorted appropriately, |
| 20 | but file arguments appear |
| 21 | before directories and their contents. |
| 22 | There are several options: |
| 23 | .TP |
| 24 | .B \-l |
| 25 | List in long format, giving mode, number of links, owner, |
| 26 | size in bytes, and time of last modification |
| 27 | for each file. |
| 28 | (See below.) |
| 29 | If the file is a special file the size field will instead contain |
| 30 | the major and minor device numbers. |
| 31 | .TP |
| 32 | .B \-t |
| 33 | Sort by time modified (latest first) instead of |
| 34 | by name, as is normal. |
| 35 | .TP |
| 36 | .B \-a |
| 37 | List all entries; usually |
| 38 | .RB ` . ' |
| 39 | and |
| 40 | .RB ` .. ' |
| 41 | are suppressed. |
| 42 | .TP |
| 43 | .B \-s |
| 44 | Give size in blocks, |
| 45 | including indirect blocks, for each entry. |
| 46 | .TP |
| 47 | .B \-d |
| 48 | If argument is a directory, list only its name, not |
| 49 | its contents (mostly used with |
| 50 | .B \-l |
| 51 | to get status |
| 52 | on directory). |
| 53 | .TP |
| 54 | .B \-r |
| 55 | Reverse the order of sort to get reverse alphabetic |
| 56 | or oldest first as appropriate. |
| 57 | .TP |
| 58 | .B \-u |
| 59 | Use time of last access instead of last |
| 60 | modification for sorting |
| 61 | .RB ( \-t ) |
| 62 | or printing |
| 63 | .RB ( \-l ). |
| 64 | .TP |
| 65 | .B \-c |
| 66 | Use time of last modification to inode (mode, etc.) |
| 67 | instead of last modification to file for sorting |
| 68 | .RB ( \-t ) |
| 69 | or printing |
| 70 | .RB ( \-l ). |
| 71 | .TP |
| 72 | .B \-i |
| 73 | Print i-number in first column |
| 74 | of the report for each file listed. |
| 75 | .TP |
| 76 | .B \-f |
| 77 | Force each argument to be interpreted as a directory |
| 78 | and list the name found in each slot. |
| 79 | This option turns off |
| 80 | .B "\-l, \-t, \-s," |
| 81 | and |
| 82 | .B \-r, |
| 83 | and |
| 84 | turns on |
| 85 | .B \-a; |
| 86 | the order is the order in which entries |
| 87 | appear in the directory. |
| 88 | .TP |
| 89 | .B \-g |
| 90 | Give group ID instead of owner ID in long listing. |
| 91 | .PP |
| 92 | The mode printed under the |
| 93 | .B \-l |
| 94 | option contains 11 characters |
| 95 | which are interpreted |
| 96 | as follows: |
| 97 | the first character is |
| 98 | .TP 3 |
| 99 | .B d |
| 100 | if the entry is a directory; |
| 101 | .br |
| 102 | .ns |
| 103 | .TP 3 |
| 104 | .B b |
| 105 | if the entry is a block-type special file; |
| 106 | .br |
| 107 | .ns |
| 108 | .TP 3 |
| 109 | .B c |
| 110 | if the entry is a character-type special file; |
| 111 | .br |
| 112 | .ns |
| 113 | .TP 3 |
| 114 | .B \- |
| 115 | if the entry is a plain file. |
| 116 | .PP |
| 117 | The next 9 characters are interpreted |
| 118 | as three sets of three bits each. |
| 119 | The first set refers to owner permissions; |
| 120 | the next to permissions to others in the same user-group; |
| 121 | and the last to all others. |
| 122 | Within each set the three characters indicate |
| 123 | permission respectively to read, to write, or to |
| 124 | execute the file as a program. |
| 125 | For a directory, `execute' permission is interpreted |
| 126 | to mean permission to search the directory |
| 127 | for a specified file. |
| 128 | The permissions are indicated as follows: |
| 129 | .TP 3 |
| 130 | .B r |
| 131 | if the file is readable; |
| 132 | .br |
| 133 | .ns |
| 134 | .TP 3 |
| 135 | .B w |
| 136 | if the file is writable; |
| 137 | .br |
| 138 | .ns |
| 139 | .TP 3 |
| 140 | .B x |
| 141 | if the file is executable; |
| 142 | .br |
| 143 | .ns |
| 144 | .TP 3 |
| 145 | .B \- |
| 146 | if the indicated permission is not granted. |
| 147 | .PP |
| 148 | The group-execute permission character is given |
| 149 | as |
| 150 | .B s |
| 151 | if the file has set-group-ID mode; |
| 152 | likewise the user-execute permission character is given |
| 153 | as |
| 154 | .B s |
| 155 | if the file has set-user-ID mode. |
| 156 | .PP |
| 157 | The last character of the mode (normally `x' or `\-') is |
| 158 | .B t |
| 159 | if the 1000 bit of the mode is on. |
| 160 | See |
| 161 | .IR chmod (1) |
| 162 | for the meaning of this mode. |
| 163 | .PP |
| 164 | When the sizes of the files in a directory |
| 165 | are listed, a total count of blocks, |
| 166 | including indirect blocks is printed. |
| 167 | .SH FILES |
| 168 | /etc/passwd to get user ID's for |
| 169 | `ls \-l'. |
| 170 | .br |
| 171 | /etc/group to get group ID's for |
| 172 | `ls \-g'. |