How Linux servers set directory permissions so that development can only be developed in the test directory, not on the online directory

Source: Internet
Author: User

When a server, both a test environment, also has a generated environment, development needs to be tested online, if the development of the production environment, then the development of the error-prone operation

The requirements are as follows:

(1) Production environment Code, must have a dedicated account login to manage

(2) Develop test environment Code, development can access, but cannot access production environment directory

For this purpose, operate as follows

(1) Change the user group and owner of the production environment to www

Modify User

Chown-r Www/product-folder

Modify Group

Chgrp-r Www/product-folder

(2) Set the permission of the production environment is 775, that is, only the owner, the same group of people can have permission to read and write, others can only read

chmod 775-r/product-folder

(3) All development is within a group, the newly developed group

Groupadd Dev

(4) Create development UESR1 User2 and add to group Dev

Usradd user1-d/home/user1

Change Password

passwd user1

User added to group

Gpasswd–a User1 Dev

(5) Assuming that the test directory is/test-folder, keep/test-folder Apache permissions

Keep/test-folder's Apache permissions         

Chown-r Www/test-folder

chmod 775-r/test-folder

assigning groups of test catalogs to development

Chgrp-r Dev/test-folder

Here, User1,user2 can only access Test-folder cannot access Product-folder

The following is a list of the actions of users and Groups on Linux


1linux Modifying the user and group to which the file belongs

Use the Chown command to modify the user to which the file or directory belongs:

Command: Chown user directory or file name

For example: Chown qq/home/qq (the owner of the QQ directory under the home directory is changed to QQ users)

Use the CHGRP command to modify the group to which the file or directory belongs:

Command: CHGRP group directory or file name

For example: Chgrp qq/home/qq (the home directory of the QQ directory belongs to the group to QQ Group)

One, create User:

Example: Useradd user1--create user user1
useradd–e 12/30/2009 user2--Create user2, specify expiration 2009-12-30 expires
The default UID of the user is increased from 500 to the back order, 500 the following as the system reserved account, you can specify the UID,
Example: Useradd–u user3

2, use the passwd command to set a password for the new user
Example: passwd user1
Note: Users who do not have a password set cannot use it.


Example: change user user1 's login name to U1,
Usermod–l U1 user1
Example: Adding user user1 to the Users group,
Usermod–g users user1

Example: change user user1 directory to/users/us1
Usermod–d/users/us1 user1

4. Use the command Userdel to delete the user account
Example: Deleting a user User2
Userdel User2
Example: Deleting a user user3 and deleting his working directory
Userdel–r User3

5. View user Information
ID command to view the UID and GID of a user, for example: View user4 ID
ID user4
Finger command--can view the user's home directory, boot shell, user name, address, telephone and other information
Example: Finger user4


Second, the user group:
6. Command Groupadd Create user group
Groupadd–g 888 Users
Create a group of users whose GID is 888

7. Command GPASSWD add a user to a group
Only root and Group admins can change the members of a group:
Example: Adding User1 to the Users group
Gpasswd–a User1 users
Example: Exit the Users group with User1
Gpasswd–d User1 users
8. Command Groupmod Modify Group
Groupmod–n User users modify group name user to users

9. Groupdel Delete Group
Groupdel Users Delete Group users

How Linux servers set directory permissions so that development can only be developed in the test directory, not on the online directory

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.