ls -l is very basic and useful command in Unix/Linux whenever we need to get list of files and directories along with all attributes. Here we need to understand about all attribute so that we could use them as per our requirement.
ls:- this command is used to get list of files and directories.
-l:- this gives attributes about file and directories of given by ls command.
Permission Link UserID GroupID Size FileCreatedDateTime FileName
drwxr-xr-x 5 bipin sbipin 75 Mar 17 2017 FileDir
-rwxr-xr-x 2 bipin sbipin 40 Jan 25 2017 a.txt
-rwxr-xr-x 2 bipin sbipin 40 Jul 15 01:40 b.txt
- Permission: – Here we have two thing
- We can know weather it’s file or directory. If it starts with “d” then it’s directory and if it starts with “-“ then it’s file. In above example “FileDir” is directory and and a.txt and b.txt are files.
- Second thing we can understand about permission that who can read, write and execute that file or directory.
- Link:- it tells about link. We can know that how many number of links file/directory have. Link in Unix/Linux is used to point any file or directory like pointer. A file can have many link with same content.
Example:- Suppose there is any file named theway.txt
We can create numbers of link for theway.txt file with below command.
ln:- command to create link
Syntax:- ln filename linkname
ln theway.txt theway_1.txt
ln theway.txt theway_2.txt
So here theway.txt have 3 link because 2 link has been created and one file itself.
UserID:- it tells user name who created file or directory.
GroupID:- It tells group name of user.
Size:- It tells about size of file/directory in bytes.
File Created Date Time:- It tells about file/directory created data and time. Here you need to know one basic thing which is related files a.txt and b.txt in above example.
a.txt file created date and time is Jan 25 2017 (Without time but with year) but b.txt file created date and time is Jul 15 01:40 it means b.txt is created in current year that is why it is not showing year and a.txt is created in past year so it is showing year instead of time.
File Name:- And last one is file/directory name.