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:To use ls command with option -l to display the linux file permissions.
[root@localhost test]# ls -lAs comment atop, test01 file permissions -rw-r--r-- user: read, write group: read and other: read
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
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 ~]# whoamiTo view group memberships and primary group: the use groups command.
root
[root@localhost ~]# groupsTo change the owner of the file or directory use chown command.
root bin daemon sys adm disk wheel
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
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
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