ls command in Linux with example

vinod kumar
4 min readDec 2, 2020

--

ls command in Linux use for list the files and directory, if you want to know name of the file and directory you can use the ls command in Linux, this command is very common in the Linux. In the Linux maximum command has flag in the Linux; these flag is very helpful for use the function of Linux. You can see in the below image the result of ls command.

1st, ls –a, This flag is very common and important flag in the Linux . we can check the hidden files with help of this flag . it will show all hidden files. In the below image you can see dot {.} this is hidden files

2nd ls — i , if you want to check the inode no of any process you use this flag , here in the image you can see the inode no of files and directory. This is very important command and most important question for the interview.

3rd , ls –li , with the help of this flag you can see the inode no and file and directory permission . Here is first is inode no in the example after that is permission you can see below.

4th , ls –l if you want long list of the files and want to check the permission of the files.

5th , ls –lh . this command use for check the size of file in the human readable format. This is very important flag in the Linux because Linux user commonly use the this command. You can check the file size if you receive the storage error in the Linux.

6th ls –ls , flag no 7th use for long list of the file and directory and show the file size

7th ls –r, this command use for show the file in the reverse order.

8th ls –s this flag use for show the size of the file and directory.

9th ls –S this flag use for short the size of the file and directory.

10th ls –t this flag use for sort the file and directory by date and time. You can use this flag to sort as per date and time but date and time will not show here.

11th ls — ltr . this command use for list the file and directory with date and time in the ascending order . You can see in the below image here is date and time in the ascending order.

12th , ls –lth , this command use for list the file and directory with date and time in descending order.

--

--

No responses yet