Linux and Unix ls command tutorial with examples

ls command list all the file and directory name present in the current directory.

Print the name of all the directory and file available in the current directory.

Above command display four file and directory name.

Check availability of file or directory: We can check whether a particular file or directory is present in the current directory or not. To know we just specify a file name with ls command.

If Employee Record file is not available, the system will clearly say:

Details of file and directory (-l option): We can check the details of the file with (-l) option

First character ā€œ-ā€œ or ā€œdā€: The first character represents the type of file. The symbol “-“represents a regular file and “d” denotes a directory.
Next Nine Character: Next 9 character (for example rwxr-xr– )represent the file or directory permission permissions.
The first group of 3 characters(for example rwxr-xr–) represent permissions for owner means the owner has a permission to read, write and execute.
The second group of 3 characters(for example rwxr-xr–) represent permissions for members of the file group means the group has a permission only to read and execute.
The third group of 3 characters (for example rwxr-xr–) represent permissions for others means others have a permission only to read a file.

Second column: Represent the of the number of links to that file.
Third column: Represent the owner of the file.
Fourth Column: Represent the group of the file.
Fifth Column: Represent the size of the file. Here file size for the file 2.txt is 13 bytes.
Sixth Column: Represent the last modified date and time of the file or directory.
Seventh column: Tells the name of the file or directory in current directory.

Options of ls command

[table id=7 /]