list command (ls) in linux explained in detail

by Jay

To view a directory’s contents, use the ‘ls’ command. Running the “ls” command without any additional options will list the contents of your current working directory, which is just a technical term for the directory that your terminal is currently in.

$ ls
afs  boot  etc   init  lib64       media  opt   root  sbin  sys  usr
bin  dev   home  lib   lost+found  mnt    proc  run   srv   tmp  var

Here is the breakdown of the output of ls -l and ls -ld <directory name> commands, as well as the stat <file name/directory name> command:

To see the long listing of the files and directories:

# ls -l
-rwxrwxrwx . 4 root root 644432 Dec 22 06:49 File name

Below are the brief descriptions of ls -l command output

- -> Type of file, in this case, it's a directory. rwx -> Owner permissions, which means the owner of the file has read (r), write (w), and execute (x) permissions. rwx -> Group permissions, which means the group owner of the file has read (r), write (w), and execute (x) permissions. rwx -> Others permissions, which means others (users not in the owner group or group owner) have read (r), write (w), and execute (x) permissions. . -> No ACL (Access Control List) permissions applied. 4 -> The number of links to the file or directory. root -> Owner of the file. root -> Group ownership of the file. 644432 -> Size of the file. Dec 22 06:49 -> Date and Time of the creation or modification of the file. File name -> Name of the file.

How to see the long listing of the directories.

#ls -ld <directory name>
 
 d rwx rwx rwx . 2 root root 6 Dec 17 18:00 Directory name

Below are the brief descriptions of ls -ld command output

d -> Type of file, in this case, it's a directory. rwx -> Owner permissions, which means the owner of the file has read (r), write (w), and execute (x) permissions. rwx -> Group permissions, which means the group owner of the file has read (r), write (w), and execute (x) permissions. rwx -> Others permissions, which means others (users not in the owner group or group owner) have read (r), write (w), and execute (x) permissions. . -> No ACL (Access Control List) permissions applied. 2 -> The number of links to the file or directory. root -> Owner of the file. root -> Group ownership of the file. 6 -> Size of the file. Dec 17 18:00 -> Date and Time of the creation or modification of the file. File name -> Name of the file.

How to see the statistics of the file or directory: stat command

stat <file name/directory name>
File: <file name/directory name>
Size: 6              Blocks: 8          IO Block: 4096   <file type>
Device: fd02h/64770d    Inode: 2634200     Links: 2
Access: (0777/drwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-12-17 18:00:00.000000000 +0000  <creation or modification time>
Modify: 2021-12-17 18:00:00.000000000 +0000  <modification time>
Change: 2021-12-17 18:00:00.000000000 +0000  <change time>
 Birth: -

Related Posts

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.