DEV Community

Ayush Gupta
Ayush Gupta

Posted on

Linux - File Permissions

Hi Everyone,

Let's try to understand how to view, what all the files and directories present in a folder ?

we will use following command -

ls -l
Enter fullscreen mode Exit fullscreen mode

now when we press enter, let's consider there is a file with name hello.txt and a directory with name logs exist, so it will be shown to us as following -

But as you can see, we are also seeing some more information as well, along with name of file and name of directory.

Lets try to understand, what all this information is about ?

-rw-r--r-- 1 student student  0 Sep 14 07:45 hello.txt
Enter fullscreen mode Exit fullscreen mode
drwxr-xr-x 2 student student 4096 Sep 14 07:48 logs
Enter fullscreen mode Exit fullscreen mode

1.Permissions-

we can see the hello.txt is starting with a "-" which tells us its a file

similarly the logs directory is starting with a "d" which tells us its a directory

after this, we can see there are 3 letters which are used to fill 9 places right ?

r - read
w - write
x - execute
Enter fullscreen mode Exit fullscreen mode

for example -

lets see the permissions for the logs directory -

drwxr-xr-x
 123456789
Enter fullscreen mode Exit fullscreen mode
123 - Owner  rwx          Read, Write and Execute
456 - Group  r_x          Read and Execute
789 - Others r_x          Read and Execute
Enter fullscreen mode Exit fullscreen mode

Now by looking at "drwxr-xr-x", we can figure it out if its file or a directory and what permissions does owner, group and others have right ?

But how do we find who is the owner, group and others ?

2.owner, group and others -

for example -

lets see the information for the logs directory -

drwxr-xr-x 2 student student 4096 Sep 14 07:48 logs
                ^       ^
              Owner   Group
Enter fullscreen mode Exit fullscreen mode

Top comments (0)