View files permissions in ubuntu

If you want to see the the permission of a file you can use ls -l /path/to/file command.

For example

ls -l testfilename
-rwxr-xr-x 1 10490 floppy 17242 May 8 2013 testfilename

What does this mean ?

First – represents a regular file. It gives you a hint of the type of object it is. It can have following values.

d (directory)
c (character device)
l (symlink)
p (named pipe)
s (socket)
b (block device)
D (door)
– (regular file)

r represents read permission.
w represents write permission and
x represents executable permission.

First combination of rwx represents permission for the owner .
Second combination of rwx represents permission for the group .
Third combination of rwx represents permission for the other of the file.

Octal notation

Permission of file can also be represented in octal notation.
In octal notation

Read or r is represented by 4,
Write or w is represented by 2
Execute x is represented by 1.

Sum of these three is use to represent the permission.

stat command can be used to view file permission in octal notation

stat -c “%a %n” /path/of/file
For example

stat -c “%a %n” testfilename
755 testfilename
Here you can see

For owner it is 4+2+1=7 (111 in binary)
For group it is 4+0+1=5 (101 in binary) and
For other it is 4+0+1=5 (101 in binary).

Ref:: https://askubuntu.com/questions/528411/how-do-you-view-file-permissions/528433#528433

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s