In Unix all files/ directories are basically in tree form unlike in Windows which has drives. Typically File structure has a root directory with multiple sub directories. This article will give you a quick tour of a very command in unix called – ls.
How to access the files in Unix?
Unix runs on command. There are various flavors of the commands through which we can access the Unix files.I will run you through some of the quick options which will give a good heads up in the project and explain the usage in the diagram.
Well, to be frank, this is one of the key commands for unix users without which life is unimaginable. “ls” is the command which lists the files and directories in unix.
How to display the access permission of any file/ directory ?
Use “ls -l” provides all the details of the file restrictions and permissions.
The above diagram decodes the importance of the characters.
First Character – d signifies the type of the file. In the above example d signifies directory. Similarly hyphen (-) indicates that this is a standard file.
Following are the possible file type options in the 1st character of the ls -l output.
• “-“ standard file
• “d” directory
• “s” socket file
• “l” link file
The remaining character specifies file permissions. Each 3 character refers to the read, write and execute permissions for user, group and world.
In the above example first 3 characters “rwx” denotes read, write and execute permission for the user, read permission for the group and execute permission for others.
How to show the contents of the directories in Unix?
Simple. Just type
"ls <directory name>" and you get all the contents under the directory.
How to list all the files and sub-directories?
“ls -a” (Similar to ls as this does not give permissions and restrictions). In case you need to see all the file/ directory permission and restrictions details then use
How to get the sorted list based on time?
You can use
“ls –t” and if you want to see the restrictions, time and other details we can also fit in “l” along with “t” i.e.
And order files in reverse order.
If you want to know more about the other flavors of the “ls” command then uses the following command: