ls command in linux| List Files And Directories

Hello everyone In this Article we are going to learn how we can List Files And Directories in Linux in a very simple and easy step-by-step approach

ls command

ls command in linux

The ls command is use to list the files & directories in Linux

Before Jumping on the command we should know the syntax of the ls command

ls [Option]..[File]…

1) How to list the files & directory

To list the Files and Directories we can execute the below command.

Black color indicates that the data is a file and blue color indicates that the data is a directory.

$ ls 
Screenshot 1 31

2) How to list hidden Files and Directories

 To list the Hidden Files & Directories then we can use ( -a )  option with ls command the hidden file in Linux is starting with ( . )

$ ls -a
Screenshot 3 29

3) How to list files & directories with the inode number

To list files and directories with their inode number then we can add the (– il ) option with the ls command

$ ls -il 
Screenshot 4 29

4 ) How to list Files & Directories with their permission  

To list files and directories with their permissions then we have to add the ( –l ) option with the ls command.

$ ls -l 
Screenshot 5 29

5) How to view the size of Files & Directories 

To list files and directories with their size then we can add an ( -h ) option with the ls command.

Where -h option is to show the size in a human-readable format

$ ls -lh
Screenshot 6 28

6) How to view the Content Inside the Directory  

To list content inside directories then we can add the ( –R ) option with the ls command.

$ ls -R directory
Screenshot 7 23

7)- How to find the UserId and GroupId

 To list the UID (User Id ) and GID (Group Id ) of the files and directories then we can use the ( –) option in ls command

$ ls -ln 
Screenshot 8 22

8) How to List files & directory that is recently created  

To list the file and directory as recently created then we can use ( -t  ) with ls command

$ ls -t
Screenshot 9 22

9) How to check version Of the ls command 

To check what is the version of the ls command then we can execute the below command

$ ls --version
Screenshot 10 21

10) How to View the Most useful Options in the ls command 

To know the most useful options with the ls command then we can execute the below command.

$ ls --help
Screenshot 11 22

Conclusion

If you want to learn Linux in the most simple language then please click on this link.

If you want to see the man page of ls command online then click on this link

This is the complete knowledge of how we can list files & Directories in the Linux kernel using the rm command if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on the DevOps post.

Leave a Comment