What Does ls -l Command Do in Linux?
One of the most convenient commands of Linux is the "ls" command, which lists the files and directories in the current directory. The "-l" option causes it to display the files and directories in an extended format, including the permissions, owner, group, size, and modification date of each file, along with the file's name or directory.
This guide unveils the function of the "ls -l" command and how to use it, and the following.
What is the Syntax and Explanation of the Output of the "ls -l" Command?
List the Information of Specific Files or Directory
Other Options that can be used with the ls -l option
Let's get started with the basics of the "ls -l".
What is the Syntax and Output of the "ls -l" Command?
Here's the syntax of the "ls -l" command, using which you can list the files and directories in the long format.
$ ls -l
Here's the explanation of the above output
The first line shows the number of blocks occupied by the files and directories listed. From the second line, There are five columns whose details are as follows.
The first column has the "drwxr-xr-x" as a set of file permissions in Linux. It specifies who has permission to read, execute, or write. The lines starting with a "d" represents a directory, and "– "there to mean a file,
The second column shows the file's owner, "itslinux" in this example.
The third column is for the user's group with whom the file/directory can be shared or granted access.
The fourth column is the size in bytes.
The fifth column mentions the creation date and time.
The blue color can distinguish the directories and files in the sixth column.
List the Information of Specific Files or Directories
The earlier command shows you the content of all the files and directories in the home directory. So, if you want to see the details of any specific file, then you can do that by typing the discussed command followed by the file name as shown below:
$ ls -l test.txt
Similarly, the same thing could be applied to the text files as well by following the same syntax as discussed:
$ ls -l Documents
Now, there are two sub-directories present in the Documents with the name of 'Doc 1' and 'Doc 2' and their details can be seen in the above image.
You can combine some different options as well with the 'ls -l', and some of them are listed below:
List all Hidden Content as Well
The 'ls -l' command only show you the content, which is visible and not hidden, so to list the hidden content as well you can add the '-a' option as shown below:
$ ls -la
List the Content by Sorting the Time They Modified
The -t option is used to sort the files and directories by the time they were last modified, with the most recently modified files or directories appearing first as shown below:
$ ls -lt
If you want to list the same information, but in reverse order, then you can add the '-r' option as shown below:
$ ls -ltr
This was all about the "ls -l" command.
The "ls -l" command of Linux lists the files and directories/folders present in the current directory in a more readable (long) format showing various aspects related to that file. This guide explains What the "ls -l" Command is used for in Linux, its output, and a few other flags that can be used with the "ls" command.
Sort "du" Command by Size
How to install Krita on Ubuntu 22.04
Installing PyCharm on Ubuntu 22.04 LTS
How to Install Laravel PHP framework with Nginx on Ubuntu 20.…
How to List PostgreSQL Databases and Tables Using psql?
How to Install and Use OneDrive on Ubuntu 22.04