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
ls without any options
ls when used alone simply displays list of files , directories and links.
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
- 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 -ld will list details of directory itself rather than its contents.
ls with option – lh
h is human readable format. The files size is mentioned in K, M and G.
ls with option –a
-a option will show hidden files. In list generated all files starting with .(Dot) are hidden.
ls with option -lt
-lt option will display order of their modified time. Order will be last modified file on top.
. 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 with option -R
-R option will show files recursively showing content of directory.
Other articles which may interest you