Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a new user and authorize it in centos7

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to add a new user and authorize a new user in centos7. The article is very detailed and has certain reference value. Interested friends must read it!

Create a new user

Create a user name as: zhangbiao

[root@localhost ~] # adduser zhangbiao

When initializing a password for this user, linux determines the password complexity, but you can forcibly ignore it:

[root@localhost ~] # passwd zhangbiao changes the password of the user zhangbiao. New password: invalid password: password failed dictionary check-oversimplified / systematic re-entry of the new password: passwd: all authentication tokens have been successfully updated.

Authorization

The permissions of individual users can only be fully authorized under this home, and other directories should be authorized by others. The permission of the root user is often required, so the sudo can be operated as a root. I remember that I once created the file by sudo and found that I didn't have read and write permission because the view permission was created by root.

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

The authorization management of the sudo command is in the sudoers file.

Take a look at sudoers:

[root@localhost ~] # sudoersbash: sudoers: command not found. [root@localhost ~] # whereis sudoerssudoers: / etc/sudoers / etc/sudoers.d / usr/libexec/sudoers.so / usr/share/man/man5/sudoers.5.gz

Check the permissions after finding the location of the file:

[root@localhost] # ls-l / etc/sudoers-r--r- 1 root root 4251 September 25 15:08 / etc/sudoers

Yes, there is only read-only permission. If you want to modify it, you need to add w permission first:

[root@localhost ~] # chmod-v UCPW / etc/sudoersmode of "/ etc/sudoers" changed from 0440 (rMurmurr -) to 0640 (rw-r-)

Then you can add content, adding new users under the following line:

[root@localhost ~] # vim / etc/sudoers## Allow root to run any commands anywher root ALL= (ALL) ALL zhangbiao ALL= (ALL) ALL # this is a new user

When wq saves and exits, remember to withdraw the write permission:

[root@localhost] # chmod-v Umurw / etc/sudoersmode of "/ etc/sudoers" changed from 0640 (rw-r-) to 0440 (RMurray r -)

At this point, log in with the new user and use sudo:

[zhangbiao@localhost] $sudo cat / etc/passwd [sudo] password 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 time you use it, it will remind you that you have become Superman and responsible. And you need to enter a password before you can take the next step. What if you don't want to enter a password? change the last ALL to NOPASSWD: ALL.

The above is all the content of the article "how to add a new user to centos7 and authorize it". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report