lslist file and directory names and attributes |
Command |
ls [-AabCcdFfgikLlmnopqRrstux1]
[-X attr] [pathname...]
ls lists files and directories. If the pathname is a
file, ls displays information on the file according to the
requested options. If the pathname is a directory, ls
displays information on the files and subdirectories therein. You may obtain
information on a directory itself using the -d option.
If you do not specify any options, ls displays only the file
name(s). When ls sends output to a pipe or a file, it writes
one name per line; when it sends output to the terminal, it uses the
-C (multi-column) format.
-Alists all entries including those starting with periods
(.), but excluding any . or ..
entries.
-alists all entries including those starting with a period
(.).
-bdisplays non-printable characters as octal bytes with the form \ooo.
-Cputs output into columns, sorted vertically; this is the default output format to the terminal.
-cuses the creation time of the file for sorting (-t)
or displaying (-l).
-ddoes not display the contents of named directories, but show information on the directories themselves.
-Fputs a / after each directory name, a * after
every executable file, a | after every FIFO file, a
@ after every symbolic link and a = after every
socket.
-fenables the -a option and disables the
-C, -g, -l,
-n, -o, -r,
-s, and -t options. For each
argument that is a directory, all directory entries are listed in the same
order they are retrieved from the system (POSIX-compliant and UNIX systems
only).
-gdisplays only the group ID numbers (POSIX-compliant and UNIX systems).
-idisplays inode numbers along with file names (only on systems that support inode numbers, such as POSIX-compliant and UNIX systems).
-kdisplays size in kilobytes instead of blocks when specified with the
-s option. If the -s option is not
specified, this option has no effect.
-Lfollows symbolic links (only on systems that support symbolic links) (POSIX-compliant and UNIX systems only).
-ldisplays permissions, links, owner, group, size, time, name; see Long Output Format.
-mdisplays names in single line, with commas separating names.
-ndisplays user ID and group IDs as numbers instead of names.
-odisplays only the user ID of owner (POSIX-compliant and UNIX systems only).
-pputs / after directory names.
-qdisplays non-printable characters as ?.
-Rlists subdirectories recursively.
-rsorts in reverse of usual order; you can combine this with other options that sort the list.
-sdisplays size in blocks (after the inode number, but before other
information). If the -k option is also specified, the
size is displayed in kilobytes instead.
-tsorts entries by time. By default, this option sorts the output by the
modification times of files. You can change this with the
-c and -u options.
-uuses the last access time for sorting (-t) or
displaying (-l).
-xputs output into columns sorted across the rows.
-1forces single column output.
When you specify options that are mutually exclusive (for example,
-c and -u), the option that
appears last on the command line is used.
ls -l summarizes all the
most important information about the file on one line. If the specified
pathname is a directory, ls displays information on
every file in that directory (one file per line). It precedes this list with a
status line that indicates the total number of file system blocks (512 byte
units) occupied by the files in that directory. Here is a sample of the output
along with an explanation.
The first character identifies the file type:-rw-rw-rw- 1 root dir 104 Dec 25 19:32 file
The next nine characters are in three groups of three; they describe the permissions on the file. The first group of three describes owner permissions; the second describes group permissions; the third describes other (or world) permissions. Characters that may appear are:- Regular file b Block special file c Character special file d Directory l Symbolic link n Network file p FIFO s Socket
You can change some permissions with ther Permission to read file w Permission to write to file x Permission to execute file a Archive bit is on (file has not been backed up) c Compressed file s System file h Hidden file t Temporary file
chmod command.
After the permissions comes the number of links to the file.
Next comes the name of the owner of the file or directory.
If the file has a SID associated with it, but
the name of the SID cannot be determined, then the value
of the SID is displayed.
(This can happen when the current user is not in the domain that
was used when the file was created.)
Then comes the name of the group that owns the file or directory.
Following this is the size of the file, expressed in bytes.
After this comes a date and time. For a file, this is the time that the file was
last changed; for a directory, it is the time that the directory was created.
The -c and -u options can change which
time value is used. If the date is more than six months old or if the date is in
the future, the year is shown instead of the time.
The last item on the line is the name of the file or directory.
COLUMNScontains the terminal width in columns. ls uses
this value to determine the number of output columns to write using the
-C option.
TZcontains the time zone to be used when displaying date and time strings.
0Successful completion.
1Failure due to any of the following:
2Failure due to an invalid command line option.
The requested file or directory does not exist.
To sort its output, ls needs to allocate memory;
this message says that there was not enough memory for the sorting
operation.
This message only appears when ls runs out of
dynamically allocated memory.
-A, -b, -f,
-g, -L, -m,
-n, -o, -p,
-s, and -x options are extensions to the
POSIX and XPG.4 standard.
stat