Ls
|
From Linuxconfig.org
.. back to the list of Linux Commands
Name
ls - list directory contents
Synopsis - man page
ls [OPTION]... [FILE]...
Frequently used options
-l use a long listing format
-a, --all
do not ignore entries starting with
-t sort by modification time
-r, --reverse
reverse order while sorting
-h, --human-readable
with -l, print sizes in human readable format (e.g., 1K 234M 2G)
Examples
ls command without any options displays content of the current directory:
ls
To see all files and directories including hidden files and directories the "-a" option can be used:
ls -a
Please note that "." is current directory and ".." is parent directory.
Sometimes we want to also see size, who is an owner and what are permissions for given files and directories. To do that we can use "-l" option:
ls -l
ls -l .file1
Its also possible to combine options together. So if we would like to see long listing format and also include hidden files and directories we would issue a command:
ls -al
ls command is also able to sort output by time of creation.
ls -lt
In the example above the newest files/directories is on the top and the oldest files/directories are on the bottom of ls output. We can reverse this output with "-r" option:
ls -ltr
Last very useful option is -h. This option shows size of the file in human readable format however it can be used only with the combination of "-l" option:
ls -lh file3





















