Listing (ls) Files With Linux

ls Linux Command

The 'ls' command is one which gets used quite frequently. The 'ls' command is used to display files. There are many ways for which you can display files; such as ls, ls -l , ls -a, ls a* and ls -lt.

ls (lists one file for each row)

root# ls 
file1 .file2

ls -l (lists a long output with file permissions, date and file size)

root# ls -l -rw-r--r--  1 root root   38473 Feb 22  2012 memcached-2.0.0b2.tgz -rw-r--r--  1 root root   38473 Feb 22  2012 memcached-2.0.0b2.tgz.1

ls -a (lists all files including hidden files)

root# ls -a 
file1 .file2

ls -a (lists all files beginning with a)

root# ls a* 
afile .afile

ls -lt (lists all files with long output ordered by date desc)

 root# ls -lt drwxr-x--- 15 root root    4096 Dec 24 22:28 ./ -rw-------  1 root root   17386 Dec 24 09:14 .bash_history