Linux Four common command bodies handle specific explanations

Source: Internet
Author: User
Tags readable

The original blog. Reprint please indicate the source

Http://blog.csdn.net/hello_hwc?viewmode=contents

Permissions

For file
R readable
W Writable
X can be run
For folder
R to list the contents of a folder (LS)
W ability to create and delete files in a folder (TOUCH/RM)
x ability to enter folder (CD)


First, chmod
chmod to change permissions
Often used in the way
1. Change permissions with ugo+rwx or ugo-rwx or ugo=rwx
Here's Ugo
u user
G User Group
o Other persons
For example: Ug+x is to add operational permissions for users and groups of users
Example:
[[email protected] testforcsdn]# ls-l testfile-rw-r-----1 root root 0 Nov  1 22:14 testfile

Granting read and write access to other people
[Email protected] testforcsdn]# chmod o=rw testfile [[email protected] testforcsdn]# ls-l testfile-rw-r--rw-1 Root Roo T 0 Nov  1 22:14 testfile

Remove Write permissions for other people
[Email protected] testforcsdn]# chmod o-w testfile [[email protected] testforcsdn]# ls-l testfile-rw-r--r--1 root root 0 Nov  1 22:40 testfile

To add write permissions to a group of users
[Email protected] testforcsdn]# chmod g+w testfile [[email protected] testforcsdn]# ls-l testfile-rw-rw-r--1 root root 0 Nov  1 22:40 testfile

2. Change the permissions in a digital way
R corresponding 4
W corresponding 2
X corresponding 1
For example: 5=4+1 then 5 represents readable and operational permissions
Example
Create an empty file, and view the permissions to see that the current permission is rw-r--r--
Other words:
Yes, it's a rw-. Readable writable non-operational
r--is only writable for the owning group
For the rest of the r--, it's just written.
Example
Create a script. and give it all the permissions to run
[[email protected] testforcsdn]# Touch Test.script[[email protected] testforcsdn]# ls-l test.script-rw-r-----1 root Roo T 0 Nov  1 22:43 test.script[[email protected] testforcsdn]# chmod 744 test.script [[email protected] testforcsdn]# ls -L test.script-rwxr--r--1 root root 0 Nov  1 22:43 test.script

Second, Chown
Change the whole person
First join the user HWC
[Email protected] testforcsdn]# useradd hwc[[email protected] testforcsdn]# chown HWC test.script [[email protected] Test forcsdn]# ls-l test.script-rwxr--r--1 hwc root 0 Nov  1 22:43 test.script

Third, Chgrp
Change the owning group
First join user group Hwcgroup[[email protected] testforcsdn]# chgrp hwcgroup test.script [[email protected] testforcsdn]# ls-l Test.sc ript-rwxr--r--1 hwc hwcgroup 0 Nov  1 22:43 test.script

Iv. umask
Default permissions for file and folder creation
View default Permissions
[Email protected] ~]# umask0022
Explanation, the first 0 here is the special permission bit. Generally not considered
022 is the user permission bit, here is the mask value
For file
That is, the actual permission should be the full permission 777-022-111 = 644
It's rw-r--r--.
Change the default permission value
[Email protected] ~]# umask 027[[email protected] ~]# umask0027


Copyright notice: This article Bo Master original article, if you need to reprint please indicate the source

Linux Four common command bodies handle specific explanations

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.