Sathish Kumar
Posted on April 10, 2021
Welcome back..
In previous article, I have posted about Linux File hierarchy structure Link , please check if you haven't visited.
ls is one of basic commands which lists files/directories that one should know when working with Linux. It is used on daily basis even though we may not aware and never use of all the ls options that are available.
In this article, we will be seeing purpose and different ways of using ls commands with options in Linux.
1.List files using ls with no option
ls with no options lists all the files and directories in a bare format with no other details like file size, owner, permissions, date and time.
2.List files using ls with option -l
ls -l will lists the available files and directories with details like file/directory name size, owner, permissions, date and time.
3.View hidden files
ls -a will lists hidden files available
4.List Files in Human Readable Format with option -lh
You know ls -l will list files/directories along with size and other details. By adding h(Human Readable Format) to it, ls -lh will lists files/directory size in human readable format like bytes, Kb, Gb
5.List Directories adding / at the end with option -F
ls -F will list files and add "/" at the end of directories
6.List Files/Directories in reverse order
ls -r will list files/directories in reverse order
7.Recursively lists Sub-directories
ls -R list all files that are available inside the sub-directories
8.Listing latest updated files/directories
ls -ltr will lists files and directories in reverse order with latest modification as last
9.Sorting files by file size
ls -lS will lists the file size in order, by displaying big size first
10.Display Inode number of File or Directory
Inode number is unique identification number that are assigned when new file/directory is created.
ls -i will display the inode number of a file/directory
11.ls version
ls --version will return the version of ls
12.Show help page
ls --help will display the help page
13.List directory information
ls -l /Dir_name will lists all the files/directories inside the defined directory
14.Display UID and GID of Files
ls -n will display the UserID and GroupID of files/directories
Hope the above information is useful. :)
Posted on April 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.