Monday, December 29, 2014

linux file permissions

Leave a Comment
Linux file permissions, the after you log-in with username and password to gain access to a linux system. All access to resources in linux system the user and password have to required permission.

what does Ownership mean

when you create a file or directory, that user's name and primary group become the owner and group owner of the file or directory.

Note: Only two user on linux system can modify or change permissions on file or directory: The owner of the file or directory and root user.

what does mode mean

Every file and directory on linux filesystem contains information permissions in inode. The section of inode that store information permissions called mode. Mode divided into three section as picture below in linux file permissions:
linux file permissions

To use ls command with option -l to display the linux file permissions.
[root@localhost test]# ls -l
total 4
drwxr-xr-x 2 root root 4096 Dec 30 10:24 folder
-rw-r--r-- 1 root root    0 Dec 30 10:24 test01
-rw-r--r-- 1 root root    0 Dec 30 10:24 test02
As comment atop, test01 file permissions -rw-r--r--  user: read, write group: read and other: read
Note:

  • Read: Allow a user to open and read the file
  • Write: Allow a user to open, read and edit the file
  • Execute: Allow a user to execute the file in memory

To view current user name: the use whoami command
[root@localhost ~]# whoami
root
To view group memberships and primary group: the use groups command.
[root@localhost ~]# groups
root bin daemon sys adm disk wheel
To change the owner of the file or directory use chown command.
Syntax: two arguments at minimum
chown [option] [new owner] [file/directories]
For example no option:
[root@localhost test]# chown apache test01
[root@localhost test]# ls -l
total 4
drwxr-xr-x 2 root   root 4096 Dec 30 10:24 folder
-rw-r--r-- 1 apache root    0 Dec 30 10:24 test01
-rw-r--r-- 1 root   root    0 Dec 30 10:24 test02

To change the group owner of the file or directory use chgrp command
Syntax: two arguments at minimum
chgrp [option] [new owner] [file/directories]
For example no option:
[root@localhost test]# chgrp apache test01
[root@localhost test]# ls -l
total 4
drwxr-xr-x 2 root   root   4096 Dec 30 10:24 folder
-rw-r--r-- 1 apache apache    0 Dec 30 10:24 test01
-rw-r--r-- 1 root   root      0 Dec 30 10:24 test02

To change the owner and the group owner at them same time using chown command
For example no option:
[root@localhost test]# chown nginx.nginx test01
[root@localhost test]# ls -l
total 4
drwxr-xr-x 2 root  root  4096 Dec 30 10:24 folder
-rw-r--r-- 1 nginx nginx    0 Dec 30 10:24 test01
-rw-r--r-- 1 root  root     0 Dec 30 10:24 test02
Some examples the basic of linux file permissions as atop, i hope will this hope you!

Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4

0 comments:

Post a Comment