ls command
ls [option]... [file]...
ls prints the names of the files in a directory. With nothing after it, it lists the current directory. With a file name, it lists that one file; with a directory name, it lists what is inside.
Without options the names are sorted by character order and packed into columns. -l switches to one file per line and adds the type, the permissions, the owner, the size and the time. -a adds the names beginning with a dot, which are otherwise left out.
The order can be changed. -t sorts by time, -S by size, and -r reverses whichever order is in effect. These combine, so ls -lrt is one file per line, oldest first.
Options
-lOne file per line, with permissions, owner, size and time.-aInclude the names that begin with a dot.-hWith -l, print sizes as 1K, 234M, 2G.-tSort by time, newest first.-rReverse the order in effect.-RList the directories below as well.Examples
ls -lThe current directory, one file per line.ls -laThe same, with the dot files included.ls -lh /var/logAnother directory, with readable sizes.ls -lrtOldest first, so the newest file is at the bottom.GNU and BSD
GNU ls colours the names with --color=auto. The BSD ls on macOS does the same with -G, and takes --color=when as well.
The -l format carries the same fields on both, but the time column and the way sizes are written differ. Reading the output by column position is not safe across the two.