LINUX2.4CHOMD, Chown, umask

Source: Internet
Author: User

File or directory Permissions chmod

Each file or directory has its own permissions. If starting from the second column nine permission bits, divided into three segments. R=4 w=2 x=1, respectively, can be expressed in numbers. Rwx=7 rw-=6--x=1 rw-r--r--=644

[Email protected] tmp]# ls-l 1.txt-rw-r--r--. 1 root root 0 October 06:08 1.txt[[email protected] tmp]# rw-r--r--=600^c[[email protected] tmp]# chmod 666 1.txt[[email PR Otected] tmp]#!lls-l 1.txt-rw-rw-rw-. 1 root root 0 October 06:08 1.txt

We can see that there is a point behind the nine permission bits. Note that this file is subject to SELinux, and if SELinux is turned on, the file created has such a point.

[[email protected] tmp]# Getenforcedisabled[[email protected] tmp]# touch 3.txt[[email protected] tmp]# ls-l 3.txt-rw-r-- r--1 root root 0 October 06:15 3.txt

When SELinux is closed, it is not identified by this dot.

Bulk Modify Permissions-R

[Email protected] tmp]# chmod 777 chy         #修改目录权限 [[email protected] tmp]# ls-l./chy/1.txt           #  The file permissions within the directory have not been modified-rw-r--r--1 root root 0 October 06:18/chy/1.txt[[email protected] tmp]# ls-ld chy/                   #目录权限变化drwxrwxrwx 2 Root root 18 October 06:18 chy/[[email protected] tmp]# chmod-r 770 chy         #-r Bulk Modify the directory and all of the following permissions [[email protected] tmp]# ls -L chy/Total dosage 0-rwxrwx---1 root root 0 October 06:18 1.txt[[email protected] tmp]# ls-ld chy/drwxrwx---2 root root 18 October 2 5 06:18 chy/

U g o A, you can + = with a minus sign should be noted, must have this permission bit, such as rw--X this is not standard.

[[email protected] tmp]# chmod u+x,g+w,o=r chy[[email protected] tmp]# chmod a+x chy[[email protected] tmp]# chmod a-x chy
Change owner and owning group Chown
[Email protected] tmp]# ls-l 1.txt-rw-rw-rw-. 1 root root 0 October 06:08 1.txt[[email protected] tmp]# chown chy002 1.txt          #更改所有者 [[email protected] tmp]# ls-l 1.txt -rw-rw-rw-. 1 chy002 Root 0 October 06:08 1.txt[[email protected] tmp]# chgrp chy002 1.txt            #更改所属组 [[email protected] tmp]#!lls-l 1 . txt-rw-rw-rw-. 1 chy002 chy002 0 October 06:08 1.txt

Where chown can also change the owning group.

[[email protected] tmp]# chown chy002:user chy/[[email protected] tmp]# ls-ld chy/drw-rw-r--2 chy002 user 18 October 25 06:1 8 chy/

-R can modify the relationship of all files under the file

[[email protected] tmp]# chown-r user:chy002/tmp/chy/[[email protected] tmp]# ls-ld chydrw-rw-r--2 user chy002 18 October 06:18 Chy[[email protected] tmp]# ls-ls chy/1.txt0-rwxrwx---1 user chy002 0 October 06:18 chy/1.txt
Umask

By default, directory permissions are 755, and normal file permissions are 644. This value is determined by umask. If you do not have X permissions, the directory is not able to open browsing.

[[email protected] tmp]# mkdir chy2[[email protected] tmp]# touch Chy2.txt[[email protected] tmp]# ls-lst Total usage 40-rw-r--r- -  1 root   root     0 October 06:45 chy2.txt0 drwxr-xr-x  2 root   root     6 October 06:45 chy2

If the user is created as a normal file, the default is no executable permission. Only RW has two permissions, up to a maximum of 666.

If the user is set up as a directory, the maximum permission is 777.

Don't use numbers to directly reduce umask. What if Umask is 003?

rwxrwxrwx--------WX = rwxrwxr--vacancy minus x is still empty.

Umask can go to config file/ETC/BASHRC modify

LINUX2.4CHOMD, Chown, umask

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.