Linux Command - ls

ls - one of the most common commands in Linux. This command lists directory contents. It can also list permissions, owner, size etc. It sorts the file alphabetically by default.

Syntax

1
ls [Options] [Directory]...

Options

Option Description
-l long format list(permissions, ownership, size and modification date)
-a show all entries in the directory including hidden files
-r, --reverse reverse order while sorting
-R, --recursive list subdirectories recursively
-t sort by modification time, newest first
-h, --human-readable prints human readable sizes(e.g. 1k 2M 1G). used with -k and or -s
-F, append indicator(*/=>@) to entries
-1 list one file per line

Example

list files in current directory

1
ls

list file names in one file per line

1
ls -1

list files start with ‘a’

1
ls -l a*

list files start with ‘a’ including hidden files

1
ls -l a*

list the last 5 files that is modified

1
ls -lt | head

long format list with human readable units for /var directory

1
ls -lh /var

ll

In many system, ll is the alias of ls -l. In Ubuntu, it is alias to ls -alF. use type ll to check the alias.

1
ll

Reference