Output of ls command in linux can list content of a directory. It can provide all the files present in the directory as well as all the sub-directories. In Linux everything is represented as a file. A sample output of ls -lh is given below. In this we can see there are total 4 files and various information about the files is given. In case there is some sub-directory then it will shown with file type as ‘d’.
Sample output of ls command in a linux machine:
In the below section we will explain about the output of the command. Natively the command is ls, if we use additional parameter like -lh , l will show the output in list format and h will enable the output in human readable format. There are other parameter which we can use in ls which will help in showing output differently.
Total: show total size of the folder.
File type: First field in the output is file type. If the there is a – it means it is a plain file. If there is d it means it is a directory, c represents a character device , b represents a block device.
Owner: This field provide info about the creator of the file.
Group: This filed provide info about who all can access the file.
File size: This field provide info about the file size. By default the ls -l command give output in bytes.
Other field are self explanatory.
Now permission can be divided into three parts: Owner, Group, Other
r: read permission
w: write permission
x: execute permission
Octal values are used to represent permissions.
4 -> read permission
2 -> write permission
1 -> execute permission
Example: If a file have 764 permission it means owner can do all operation on file, group can do read and write operation on file and other can read only the file