The UNIX ls -l Command Explained
The UNIX ls -l command can provide you with detailed information about each file and subdirectory in the current folder. Using this function is equivalent to entering "dir /V" at the Windows command prompt. The ls -l UNIX command reveals seven facts about each item in a directory. Here is an example of its output:
$ ls -l
total 14
lrwxrwxrwx 1 lfl03b users 27 Aug 8 09:59 contacts_work -> datafiles/contacts_work.txt
drwxr-xr-x 2 lfl03b users 2048 Apr 9 15:04 datafiles
-rwxr-xr-x 1 lfl03b users 10130 Apr 9 15:02 demo_ksh_array_shell_script
drwxr-xr-x 2 lfl03b users 2048 Apr 10 09:29 perl5
The word "total" is followed by the number of file system blocks that the directory's files occupy. Each subsequent line supplies details on a single item. The first character specifies the folder or file type. It is a directory if the letter "d" appears. UNIX uses hyphens to identify standard files; various letters denote specialized data files and links.
This identifier is directly followed by a set of nine letters and hyphens. They disclose the item's security permissions. The first three permissions apply to the file's owner, and the next set pertains to members of the owner's group. The final three characters identify access permissions for all other users.
### PLEASE READ AN IMPORTANT MESSAGE FROM OUR FOUNDER ###
The time has come to END the social experiment known as Facebook.
It is breaking our world and is hurting people.
(1) People are dying as the result of genocide (ie. the Rohingya in Myanmar), bullying and mental health problems enabled by Facebook
(2) People's behavior, including yours if you use Facebook, is being manipulated by Facebook's subjective Newsfeed algorithm
(3) Families, communities and countries are becoming more divided, contrary to Facebook's stated mission of building community
READ MORE >>
A user or group is allowed to read an item if its permissions contain the letter "r." The letter "w" indicates that someone can modify the file by writing to it. An "x" means that users have permission to run the file if it's an executable program. Hyphens appear when permissions have not been granted.
The next item in each ls -l listing is the number of links. A file typically has one link, but there are more links if it has aliases. The count starts at two for folders because UNIX considers the parent and current directories to be links. This figure includes the number of subdirectories in a folder as well.
The UNIX ls -l command's listings also indicate the owner and group assigned to a file. You can use this data in conjunction with the permission flags to determine what access rights you have. The file size follows the group name; it is measured in bytes. Regardless of how many files it contains, the size of a directory is normally 2,048 bytes.
A calendar date appears after the file size. It may also include the year or a specific time. This is the date when the item was last modified; you will see the creation date if a file has never been changed. Finally, the name of a file or directory appears at the end of each line.
The fourth line of our sample reads "-rwxr-xr-x 1 lfl03b users 10130 Apr 9 15:02 demo_ksh_array_shell_script." This means that the file is part of the "users" group and owned by "lfl03b." It consists of 10,130 bytes and was modified on April 9. Everyone may read or execute this file, but the owner is the only user who can modify it.
There are many reasons to use the ls -l command in UNIX. For example, you might want to determine how long ago you updated a statistic on your website. It also comes in handy when you need to verify that a certain file will fit on an external storage device. This command is useful for reviewing UNIX security settings as well.
Do you need to learn UNIX or Linux, including how to read and write shell scripts? If you are ready to move past the basics, either of these online courses is a good place to start...
UNIX and Linux Operating System Fundamentals contains a very good "Introduction to UNIX Shell Scripting" module, and should be taken if you are new to the UNIX and Linux operating system environments or need a refresher on key concepts.
UNIX Shell Scripting is a good option if you are already comfortable with UNIX or Linux and just need to sharpen your knowledge about shell scripting and the UNIX shell in general.
Both courses include access to an Internet Lab system for completing the course's hands-on exercises, which are used to re-enforce the key concepts presented in the course. Any questions you may have while taking the course are answered by an experienced UNIX technologist.
Thanks for reading, and have a great day!!!
Has this article been helpful to you? Would it benefit others? If you answered "yes" to either question, kindly share the page.
MORE READERS = MORE FUTURE ARTICLES
Thank you for sharing.