ls : Terminal Command Of the day

To list all the files and directories present, we use ls command. ls stands for list files.

Will list all the files and directory present in PWD (present working directory)[ pwd is also a command. Just type pwd to see the full path of the current directory you are in]

By default, hidden/system files are not displayed. In Linux / Unix hidden files and directories start with “.”.

There are various options that we can use in ls
ls- l
Will give detailed display of all files and directories.
ls -l
ls -l

If you want to know the type of file (either directory (/), executables files (*) or regular file)
ls –F

To show hidden files use
ls –a

To recursively lists subdirectories. (Display even the files inside the directories)
ls -R
ls -R
ls -R

ls –d
Shows information about symbolic link. (will cover it in upcoming posts) It will point the link to the original file also.

sort the list of files by modification time.
ls -t
sort the list of files by file size.
ls -S
 sort alphabetically by extension
ls - X

print file sizes in human readable format. (e.g., 7K, 450M, 7G, etc.)
ls -lh
ls -lh
ls -lh

In some terminals –color is supported which will list the files in colors based on their file type.
ls --color

To know more options read the manual,
man ls

About This Blog

There is something for everyone. !! A tech blog on various topics. Let it be devops, programming etc; we have it all covered here in layman terms :)

Total Pageviews

Back to TOP