Learn 7 ls command in linux | Easy Guide

In this article, we will learn about the ls command in Linux, which professionals often use. Most ordinary people use Windows, a GUI-based operating system, but being a Linux administrator, you need to perform most of the tasks with the terminal. LS is one of the essential commands to know. ls command is used for listing files and directories in the location. It has many features and options that make this command extremely powerful and easy to work with. Also, we will be covering many examples of the ls command. LET’S GO!

Learn ls Command In Linux


  • ls -l

This command will help you list all the files and directories presented at the location. Also, it gives you the details of the files, directories such as owner, group, last modified date, links, and, most importantly, the permission of the directory or file.

Permission – drwxr-xr-x
Group – root
User – root
Last Modified Date – Apr 3
Last Modified Time – 16:03

ls-l


  • ls -a 

In the Linux operating systems, many dot files or directories are available, like .htaccess, .well-known, etc., which are not visible with the help of the ls or ls -l command. To check those files, we need to add a -a argument in the ls command. Dotfiles are also known as hidden files.

dot-files-ls-al


  • ls -F

This is a beneficial argument of the ls command. With the help of ls -F, you can reveal the file. Like is that file is a directory or link or any executable file. Each type of file has its notation to display,

/ – Directory
@ –
Link
* – 
Executable

ls-command-hidden-file-show

Also Learn – 301 Redirects & Redirections rules with .htaccess?


  • ls -t

I think developers always use this command to check the latest modified file with time. This command will display the files that are modified according to the time. Let’s see an example,

ls-t-command


  • ls -r

By default, if we run the ls -l command, then this will display all the items according to the alphabet. Suppose you want to check all the files reverse, i.e., from Z – A, then this command will work for you. Check out the example,

ls-r-cmd


  • ls -latr

This is my favourite command which I often use. This command will do the following details for you,

Long listing (-l) + showing hidden files / dotfiles (-a) + listing with last modified files according to time (-t) + with reverse order (-r)

Check out the example for a better understanding.

ls-latr-cmd

Also, Learn – How to increase session timeout in php? #1


  • ls -R

If you want to check what’s inside the directories, then using the ls -R command makes your work far more straightforward. This command will display recursive output. This command works exactly like the “tree command” Have a look at an example –

ls-Re-cmd


  • ls -l (filename/directory)

Suppose you have 100+ files within your folder and specifically want to very the permission of a single file, then you can use ls -l to specify the file name.

ls-l-filename-cmd


Conclusion :

We have learned about the ls command in Linux and its usage. If you like this article, do not forget to join my newsletter for more such articles, or if you have any suggestions/feedback feel free to drop a comment below. Thank you!