Settings for Linux file and directory permissions

Source: Internet
Author: User

Linuxsettings for file and directory permissionsModify File Permissions

If you want to change the permissions of a file or directory, you can use the chmod command to change the permissions of a file or directory in two ways: mnemonic and octal.

• Mnemonic Method:

Grammar:


use u (user) g (group) o (Other) Span style= "font-family: ' The song Body '; >, a (All) Span style= "FONT-FAMILY:CALIBRI;" >+ - = means what permissions are set, using rwx represents permissions.

For example:

[email protected] tmp]# Touch test.txt

[email protected] tmp]# LL

Total 0

-rw-r--r--1 root root 0 Jul 8 19:51 test.txt

[Email protected] tmp]# chmod u+x test.txt

[email protected] tmp]# LL

Total 0

-rwxr--r--1 root root 0 Jul 8 19:51 test.txt

[Email protected] tmp]# chmod go-r test.txt

[email protected] tmp]# LL

Total 0

-rwx------1 root root 0 Jul 8 19:51 test.txt

# chmod u=rw-,go=r--test.txt

[email protected] tmp]# LL

Total 0

-rw-r--r--1 root root 0 Jul 8 19:51 test.txt

[Email protected] tmp]# chmod a=---test.txt

[email protected] tmp]# LL

Total 0

----------1 root root 0 Jul 8 19:51 test.txt

• Eight binary

Grammar:

convert chmod letters to octal filenames

Modify the owner of a file

Change the owner of the file, using the chown command

Syntax 1:

Chown [-r] User file

Example: Modifying the test.txt master to u100

[Email protected] tmp]# chown u100 test.txt

[email protected] tmp]# LL

Total 0

-rw-r--r--1 u100 Root 0 Jul 8 13:59 test.txt

Syntax 2:

Chown [-r] User.group file

Cases:

# chown U101.u100 A

2.3 Modifying the genus Group of a file

Change the genus group using the chgrp command

Grammar:

Chgrp GROUP FILE

Example: Modifying the genus Test.txt to u100

# chgrp U100 test.txt

[email protected] tmp]# LL

Total 0

-rw-r--r--1 u100 u100 0 Jul 8 13:59 test.txt

Controlling default Permissionsumask

The new file or directory has a default permission, which is changed by the standard concept of umask. In the system, each process, including the shell, uses a three-digit octal number to "cloak" the permissions of the newly created file or directory, and the octal number is called umask.

• Default permissions for files

Kernel 666 666

Umask 022 077

644 600

• Default permissions for directories

Kernel 777

Umask 022

755

• Querying the system for umask values

#umask

0022

• Modify umask

#umask 077

Special permissions

• Modify SUID:

#chmod u+s filename or chmod 4755 filename

• Modify SGID

#chmod g+s filename or chmod 2755 filename

• Sticky bits

# chmod o+s filename or chmod 1755 filename


This article is from the "8469270" blog, please be sure to keep this source http://8479270.blog.51cto.com/8469270/1436518

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.