Top 8 use of Linux ls command

ls command is most basic command of Linux. This guide provides you with some basic use of Linux ls command. This command lists files in specified directory. Once you are into terminal mode, it is the first command you need to be familiar with.


Use of Linux ls command

  1. ls without any options

ls when used alone simply displays list of files , directories  and links.

ls

ls

  1. ls with option – l

ls -l uses a long listing format showing

  • type of file file type – for normal file , d for directory, s for socket file and l for link file
  • permission – is given in 9 character first three for user, second three for group, last three for others
  • owner – provides owner user name
  • group – provides owner group name
  • size
  • creation date , time
  • file name.

if you use ls -l on directory it will list details about directory content rather than directory itself. To view properties of directory itself use ls -ld

ls -l

ls -l

  1. ls -ld

ls -ld will list details of directory itself rather than its contents.

ls -ld

ls -ld

  1. ls with option – lh

h is human readable format. The files size is mentioned in K, M and G.

ls -lh

ls -lh

  1. ls with option –a

-a option will show hidden files. In list generated all files starting with .(Dot) are hidden.

ls -a

ls -a

  1. ls with option -lt

-lt option will display order of their modified time. Order will be last modified file on top.

ls-lt

ls-lt

  1. . ls with option -ltr

-ltr option will display list of files in reverse modified time order i.e. file modified last will be at bottom of list.

ls -ltr

ls -ltr

  1. ls with option -R

-R option will show files recursively showing content of directory.

ls -R

ls -R

Other articles which may interest you

  1. How to create directories with mkdir command in Linux
  2. How to use of tar command in  Linux – compressing and archiving files
  3. Top 6 use of gzip command in Linux