How to Understand Linux File Permissions

How to Understand Linux File Permissions

1. Understand Linux Permissions

r: Read permission (octal number 4)

w: write permission (octal number 2)

x: Execute permission (octal number 1)

2. So we can change permission of file with character (r,w,x) or number(4,2,1)

To setup a file readable by anyone and writable by the owner only:

 

[root@localhost ~]# chmod 644 filepermission01
[root@localhost ~]# ls -lah filepermission01
-rw-r–r–. 1 root kevin 0 Dec 9 15:39 filepermission01
[root@localhost ~]#

Or

[root@localhost ~]# chmod u+rw,g+r,o+r filepermission01
[root@localhost ~]# ls -lah
total 28K
drwx——. 4 root kevin 4.0K Dec 9 15:39 .
drwxr-xr-x. 4 root root 4.0K Dec 9 15:14 ..
-rw-r–r–. 1 root kevin 18 May 10 2012 .bash_logout
-rw-r–r–. 1 root kevin 176 May 10 2012 .bash_profile
-rw-r–r–. 1 root kevin 124 May 10 2012 .bashrc
-rw-r–r–. 1 root kevin 0 Dec 9 15:39 filepermission01
drwxr-xr-x. 2 root kevin 4.0K Nov 11 2010 .gnome2
drwxr-xr-x. 4 root kevin 4.0K Dec 8 01:12 .mozilla
[root@localhost ~]#

That’s all. Thanks for using IThelpblog.com

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>