Add a new user to CENTOS7 and authorize

Source: Internet
Author: User

Reference Address: http://www.cnblogs.com/woshimrf/p/5906084.html

Create a new user

Create a user named: Zhangbiao

[Email protected] ~]# AddUser Zhangbiao

To initialize the password for this user, Linux determines the complexity of the password, but can be forcibly ignored:

passwd-simplistic/ systematic re-entering the new password:passwd: All authentication tokens have been successfully updated.
Authorized

The individual user's permission can only have the full permission under this home, other directories must see others authorization. The root user's privileges are often required, and sudo can be manipulated as root. I remember that I used sudo to create the file and then found that I did not have read and write permissions because the view permission was created by Root.

The newly created user cannot use the sudo command and need to add authorization to him.

The administration of the sudo command is in the sudoers file. Can look at sudoers:

[Email protected] ~whereis/etc/sudoers/etc/sudoers.d/usr/libexec/sudoers.so/usr/ Share/man/man5/sudoers. 5. gz

Locate the file location and then view the permissions:

ls -l/etc/sudoers14251 September  :/etc/ Sudoers

Yes, only read-only permissions, and if you want to modify it, you need to add the W permission first:

chmod -v u+w /etc/"/etc/sudoers"04400640 ( Rw-r-----)

You can then add the content and append the new user to the following line:

[Email protected] ~]# vim/etc/sudoers
any commands anywher  root    ALL=(ALL)       ALL  zhangbiao  ALL=(ALL) ALL #这个是新增的用户

Wq Save exit, this time remember to write permission to recover:

chmod -V U-w /etc/"/etc/sudoers"06400440 ( R--r-----)

Log in with a new user at this time using sudo:

sudo cat /etc/passwd[sudo for Zhangbiao:we Trust you have received the Usual lecture from the local systemadministrator. It usually boils down to these three things:    #1) Respect the privacy of others.    #2) Think before you type.    #3) with great power comes great responsibility.

The first use will prompt you, you have become Superman, body responsible. And you need to enter a password to get to the next step. If you do not want to enter a password, the last one will be ALL modified NOPASSWD: ALL .

# allow Root to run any commands anywher  root    all =(All)       all  Zhangbiao  all = (all )    Nopasswd:all  #这个是新增的用户

Add a new user to CENTOS7 and authorize

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.