[Linux] new users and authorized

First, create a new user

1, create a new user: laofan

 [root@localhost ~]# adduser laofan

2. Create a password for the new user to initialize

[root @ localhost ~] # passwd laofan 
Changing password for the User laofan. 
New password: # Enter the password 
Retype new password: # Enter the password again 
passwd: all authentication tokens updated successfully.

 

Second, the authorization

Individual user permissions can only have full rights in this home, others need to authorize other directories. Often requires root privileges can be given permission by modifying the sudoers file.

The newly created user does not use the sudo command, you need to add to his authorization.

1. Find sudoers file path and give permission

1 [root @ localhost ~] # whereis sudoers # sudoers lookup file path 
2 sudoers: / etc / sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz 
. 3 [the root @ localhost ~] # ls -l / etc / sudoers # viewing rights 
4 -r - r ----- 1 root root 3938 Sep 6 2017 / etc / sudoers # read access only 
5 [root @ localhost ~] # chmod -v u + w / etc / sudoers # imparting write permissions 
6 mode of '/ etc / sudoers ' changed from 0440 (r - r -----) to 0640 (rw-r -----)

 

2. Modify sudoers file

Enter the command  vim / etc / sudoers modify sudoers file, add new user information:

The Allow root to the any RUN ## Commands Anywhere 
root ALL = (ALL) ALL
laofan  ALL = (ALL) ALL # This is a new user

Press esc, and then enter the command  wq! To save the changes.

3, withdraw permission

[root@localhost~]# chmod -v u-w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0640 (rw-r-----) to 0440 (r--r-----)

4, a new user logs

New Connection, log in using the newly created user, and to verify, for example:

[prefma@localhost~]$ pwd
/home/laofan
[prefma@localhost~]$ ls -l /etc/sudoers
-r--r----- 1 root root 3995 Oct 16 22:42 /etc/sudoers

 

 

Note: After logging in a new user. Upload time. Overwrite files without permission will be reported. You need to operate it

chown -R laofan    /www/wwwroot/myfile/*

If the process of implementation. Have given the wrong information is as follows: 

chown: changing ownership of ‘/www/wwwroot/myfile/.user.ini’: Operation not permitted

Solution:

 

The first step: first re-opened this file:  

chattr -i  /www/wwwroot/myfile/.user.ini 

Step two: the authorization to execute our command

chown -R laofan    /www/wwwroot/myfile/*

The third step: to continue to lock this file

chattr +i  /www/wwwroot/myfile/.user.ini 

 

Guess you like

Origin www.cnblogs.com/richerdyoung/p/11119192.html