ls
From NetBSD Wiki
The ls(1) command shows the contents of a directory, or the current directory if the directory argument is missing.
Example:
$ mkdir foo $ cd foo $ touch bar $ ls bar $ cd .. $ ls foo bar
There are many options that the command accepts. The most important ones are listed here:
- -F to show the "type" of a file appended to the name:
| Symbol | Meaning |
|---|---|
| / | File is a directory |
| * | File has executable bit set (can be executed, is a program or shellscript) |
| @ | File is a symlink to another file (use ls -l to see where to) |
| | | File is a FIFO (see mkfifo) |
| = | File is a whiteout (see unionfs), only shown when using -W |
| = | File is a socket |
- -l to show "long format". This shows us detailed information on the permissions, number of hardlinks (see ln), owner, group, size, date and time of last modification and the name of the file, in that order.
- -a to show all files. By default, ls does not show files that start with a dot.
- -A does the same as -a, but it omits '.' and '..' (current directory and parent directory).
- -h shows filesizes in human-readable format (using 'k' for kilobytes and 'M' for megabytes as suffix). By default, the sizes are shown in "blocks" (one block is 512 bytes)
- -R recurses down subdirectories, showing a complete listing of everything that is inside a directory.
- -r Reverse the order of the sort to get oldest entries first.
- -t Sort by time modified, most recently modified first.
Example: Show modified files in reverse order, beginning with the oldest and ending with the latest.
% ls -ltr
