Linux study note _ 3_common Linux commands _ 2 _ permission management commands

Source: Internet
Author: User

Permission management command:

1. chmod [changethe permissions mode of a file]:/bin/chmod

Syntax: chmod [{ugo} {+-=}{ rwx}] [file or directory name] // intuitive

E.g. chmodu + wx filename

Chmodo-x filename

Chmodg = rwx filename

Or: chmod [mode = 421] [file or directory] // recommended

Number of the permission pair:

R-4

W-2

X-1

E. g. rwxr-xr -- 754

Rw-r-x -- x 651.

752rwxr-x-w-

Chmod777 dir1 // set the directory dir1 to have all permissions for all users

Appendix: su-username: users that can be switched // experiment content

Return: exit

Expansion:

2. chown [changefile ownership]/bin/chown

Change file owner

Chown [user] [file name or directory name]

E. g. chown nobody file1 changes the owner of file file1 to nobody, and the nobody is the default user.

Appendix: Add User: 1) useraddafang

2) passwd afang // set a password for the passwd

3. chgrp [change file group ownership]/bin/chgrp

Change the group of a file or directory

Chgrp [user group] [file or directory]

Change the group of the file file1 to adm. adm is an existing group in the system.

Why do I need to change the user group? How do I use the group? Let's study ^_^ later.

4. umask/bin/umask

Display and set default file permissions

Umask [-S]

E. g. umask // view the default permissions.

Display-Special Permission bit, 022-user permission bit [u, o], representing the mask value;

Calculation: 777 -- 022 = 755 // This is the default permission for creating a directory

644 // It is the default permission for creating files, none of which are x

Note: The-S option is not available in many UNIX systems, so it can only be calculated based on the above!

Umask-S //-S displays the default permissions of new files or directories in the form of rwx, which is more intuitive.

* 4.1 change the default permission Value

Umask [mask value] // The Mask value must be calculated first, but do not change it!

Appendix: Linux permission rules: default file creation. executable permissions cannot be granted! X

The advantage is that it shields many attacks and viruses.

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.