The ls -l command in Linux is used to list files and directories in a detailed format. The -l option stands for "long listing format," which provides more information about each file or directory compared to the standard ls command.
Output Format
When you run ls -l, the output typically includes the following columns:
File Type and Permissions: The first character indicates the file type (e.g.,
-for a regular file,dfor a directory) followed by the permissions for the owner, group, and others (e.g.,rwxr-xr--).Number of Links: The second column shows the number of hard links to the file.
Owner: The third column displays the username of the file's owner.
Group: The fourth column shows the group name associated with the file.
File Size: The fifth column indicates the size of the file in bytes.
Modification Date and Time: The sixth column shows the last modification date and time of the file.
File/Directory Name: The final column displays the name of the file or directory.
Example Command
ls -l
Example Output
-rw-r--r-- 1 user group 1234 Mar 1 12:34 example.txt
drwxr-xr-x 2 user group 4096 Mar 1 12:34 my_directory
In this example:
- The first line shows a regular file (
-) namedexample.txtwith read and write permissions for the owner, and read permissions for the group and others. - The second line shows a directory (
d) namedmy_directorywith read, write, and execute permissions for the owner, and read and execute permissions for the group and others.
Using ls -l is helpful for understanding file permissions, ownership, and other attributes in a directory.
