Listing files and directories
The command ls will list the names of files and directories in your current
directory. There are several options in this command. Commonly used ones are as follows.
- ls -l will provide a long listing of the contents of the
current directory. This listing includes the file type, permissions,
owner and group associated with the file, the time of last modification,
size of the file and the file name.
- ls -l -h same as above except the size is shown in human
readable units like KB, MB, GB etc.
- ls -F will mark all files that are executable with a star (*)
and all directories with a slash (/).
- ls -color will show a colored listing of files. The default
is to show directories in blue, executables in green. See
Section 5.1.5 for more details. This is the default on
Linux.
- ls -t will list files in time order, most recent first.
- ls -a will show all files in the current directory, including
the special “dot” files.
- ls -R will list all files recursively in a directory, that is, all files and
subdirectories inside it and then inside those subdirectories recursively all the way to all
files and subdirectories contain in that directory.
Use ls --help
to see the other options of the ls command.