Create a user in centos 7 and a user in centos 7
Create a new user
Create a user named xiaoming:
[Root @ 192 ~] # Adduser xiaoming
When initializing a password for this user, linux determines the password complexity, but you can forcibly ignore it:
[Root @ 192 ~] # Passwd xiaoming
Change the password of xiaoming.
New password:
Invalid password: the password must be less than 8 characters long
Re-enter the new password:
Passwd: All authentication tokens have been successfully updated.
Authorize the newly created user
The permissions of an individual user can only be granted full permissions under the home. Other directories must be authorized by others. The root user's permissions are often required. In this case, sudo can operate as root. Sudo creates a file, and then finds that there is no read/write permission, because the viewing permission is created by root.
A newly created user cannot use the sudo command and must be authorized.
Sudo command authorization management is in the sudoers file. You can see sudoers:
[Root @ 192 ~] # Sudoers
-Bash: sudoers: Command not found
[Root @ 192 ~] # Whereis sudoers
Sudoers:/etc/sudoers. d/usr/share/man/man5/sudoers.5.gz
View the directory permissions of the file:
[Root @ 192 ~] # Ls-l/etc/sudoers
-R -- r -----. 1 root 3938 June 7 2017/etc/sudoers
Only the read-only permission is required. If you want to modify the permission, you must first add the w permission:
[Root @ 192 ~] # Chmod-v u + w/etc/sudoers
Mode of "/etc/sudoers" changed from 0440 (r -- r -----) to 0640 (rw-r -----)
Then add the content and append the new user in the following line:
Vi/etc/sudoers
# Allow root to run any commands anywhere root ALL = (ALL) ALL xiaoming ALL = (ALL) ALL # This is a new user
Then, revoke the permissions of/etc/sudoers:
[Root @ 192 ~] # Chmod-v u-w/etc/sudoers
Mode of "/etc/sudoers" changed from 0640 (rw-r -----) to 0440 (r -- r -----)
Finally, log on to the user you just created:
[Root @ 192 ~] # Su-xiaoming