Create a user in centos 7 and a user in centos 7

Source: Internet
Author: User

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

 

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.