(go) Ubuntu Change folder and subfolder permissions

Source: Internet
Author: User
Tags file permissions

Linux system on how to modify documents and folders (including subfolders) permission, we look at.
An introduction:
You can use the chmod command to give permission for the file or directory. Linux / Unix file access permissions are divided into three levels: the file owner, group, others. Chmod can use so as to control how files are accessed by others
Two Detailed
1 This command is used in two ways, one is chmod followed by a number, followed by the file name
chmod abc file
Wherein a, b, c are each a number, respectively permissions User, Group, and the Other.
r = 4, w = 2, x = 1
To the property rwx 4 + 2 + 1 = 7;
To rw- property is 4 + 2 = 6;
To attribute the r-x 4 + 1 = 5.
-------------------------example------------------------ -----------
chmod a = rwx file
with 
chmod 777 file
The same effect
chmod ug = rwx, o = x file
with 
chmod 771 file
The same effect
If this program can use chmod 4755 filename have root privileges

-------------------------------------------------- --------------------------

2 Another chmod is behind the letters, followed by the file name

In summary, when you want to use the chmod command to change permissions, user identity documents are mainly the following categories:

u: user owns the file (owners);

g: the owner's group;

o: others (not the owner or the owner's group);

a: everyone or all (u, g, and o).

The user has access to the file types are as follows:

r: read right;

w: write access;

x: right of execution.

There are several types of file permission configuration behaviors:

+: Add permissions;

-: Delete permission;

=: Make it the sole authority.

-------------------------------------------------- ----example--------------------------------------------- ------

Use the chmod command to change permissions. The following example shows how to use the chmod command to change the permissions of the readme.txt file.

Assume the following are the initial permissions settings for the readme.txt file:

-rw-rw-r-- 1 winda winda 39 8 Yue 11 12:04 readme.txt

If you are the owner of this file or logged in as root, you can change the permissions of the owner, groups, and others. Initially, from the analysis above, it can be seen that the owner and group of this readme.txt file can read and write files (rw-), and anyone outside the group can only read the file (r-- ).

File permissions are a security measure. Whenever you allow others to read, write, or execute a file, you increase the risk that the file will be tampered with or deleted. As a basic principle, read and write permissions should only be given to those who really need these files.

In the example below, I want to give everyone permission to write to the readme.txt file, so they can read the file, comment on it, and save the file. This means that the "other people" part of the file permissions must be changed.

At this time, you need to enter at the shell or terminal prompt:

chmod o + w readme.txt

The o + w command parameter tells the system to write permissions to the file readme.txt for others. To see the results, list the details of the file again. At this point, the user access permissions for the file are as follows (an additional w in column 3):

-rw-rw-rw- 1 winda winda 39 3 Yue 11 12:04 readme.txt

Now everyone can read and write this file.

To remove read and write permissions for groups and others from readme.txt, use the chmod command to remove both read and write permissions.

The command is as follows:

chmod go -rw readme.txt

Enter the go-rw parameter to tell the system to delete the read and write permissions of the group and others in the file readme.txt. Again the results are listed by ls -1 command as follows:

-rw ------- 1 winda winda 39 3 Yue 11 12:04 readme.txt

The command to remove all permissions (including everyone's permissions) from the file readme.txt is as follows:

chmod a -rwx readme.txt

Now, can also be used to see if the cat readme.txt command to read the file, it returns the output should look like this:

cat: readme.txt: Permission denied

Deleting all permissions, including your own, will successfully lock the file. But since this file belongs to the user, you can change its permissions back at any time by using the following command. The command is as follows:

chmod u + rw readme.txt

Use the command cat readme.txt file to try as whether the owner is also able to read the file.

Here are a few common examples that can be used with the chmod command settings:

g + w: write access to the group is added;

o-rwx: Remove all permissions of others;

u + x: execute the file allows the file owner;

a + rw: allows everyone to read and write to the file;

ug + r: allow the owner of the group and to read the file;

g = rx: group only read and execute (not write).

Finally, tell us about the recovery of the rights group. Command is as follows:

chmod ug + x tigger

Now, if you check with the command ls -dl, you will find the only other person (others) were denied access to the tigger directory.

================================== gorgeous dividing line ============ ===================================
Ubuntu change the folder and sub-folder permissions
Open a terminal enter you need to modify directory
Then execute the following command
chmod 777 * -R
All subdirectory and file permissions to 777
View linux file permissions: ls -l file name
Linux permissions to view folders: ls -ld name of the folder (directory)
Modify file and folder permissions:
sudo chmod - (representative of the type) ××× (owner) ××× (group of users) ××× (other users)
Common modify permissions command:
sudo chmod 600 ××× (Only the owner has read and write access)
sudo chmod 644 ××× (owner has read and write access, read-only user group permissions)
sudo chmod 700 ××× (Only the owner has read and write, and execute permissions)
sudo chmod 666 ××× (everyone has permission to read and write)
sudo chmod 777 ××× (everyone has read and write, and execute permissions) 


(go) Ubuntu Change folder and subfolder permissions


Related Article

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.