ls command in linux

ls command: This command is use to list the file and directory .

Some useful example of ls command:

#ls
anaconda-ks.cfg  Desktop                      Documents     install.log          nagios    public_html.tar     
command          epel-release-5-4.noarch.rpm  hi2    install.log.syslog   oldsutff  public_html.tar.gz 

Show hidden file and directory
#ls -a    (if you find . symbol  before  file and directory that means these are hidden)

List the size of file and  directory
# ls -s                  (-s = size)
12 anaconda-ks.cfg                   4 hi                        4 nagios                  44 shadow.sh

List the size of  file and directory in human readable
# ls -sh         (-h= human readable )
total 750M
 12K anaconda-ks.cfg              4.0K hi                   4.0K nagios               44K shadow.sh

List file and directory in long format
#ls -l                    (-l = long list file and directory )
-rw------- 1 root   root        4597 Jun 14  2013 anaconda-ks.cfg
-rw-r--r-- 1 root   root        2320 Jul  4  2015 command
-rw-r--r-- 1 root   root        5659 Jul  4  2015 delete
drwxr-xr-x 2 root   root        4096 Jun 14  2013 Desktop

List  specific file in long format
# ls -l anaconda-ks.cfg  ( -l option with filename, list only file)

List  specific directory in long format
#ls -ld Desktop         (always use -d option for listing the directories )
drwxr-xr-x 2 root root 4096 Jun 14  2013 Desktop

List size of  file and directory in short order + human readable
# ls -Slh          (-S = Size in sort order )
-rwxr-xr-x 1 root   root   566M Nov  9  2012 zcs-7.2.1_GA_2790.RHEL5.20120815212042.tgz
-rw-r--r-- 1 root   root   183M Jul  2  2015 public_html.tar.gz
-rw-r--r-- 1 root   root   304K Jul  2  2015 public_html.tar
-rw-r--r-- 1 root   root    61K Jun 14  2013 install.log
-rwxrwxrwx 1 zimbra zimbra  42K Jun 14  2013 shadow.sh

List file and directory in reverse order
# ls -r        
zcs-7.2.1_GA_2790.RHEL5.20120815212042.tgz  shadow2zm.pl  hi.sh  file.txt   delete

List file and directory in reverse order which has been modified last
# ls -ltr
drwxr-xr-x 3 root   root        4096 Jan 26  2016 nagios
-rw-r--r-- 1 root   root         147 Oct 31 22:08 hi

Note: here hi file has modified last .

List file with inode no
#ls -i                   (-i = inode no)
138117130 anaconda-ks.cfg              102793217 hi                   206700575 nagios