How to create a new username and password under centos

WJ
Release: 2020-06-02 16:20:13
Original
18866 people have browsed it

How to create a new username and password under centos

How to create a new username and password under centos?

1. Create a new user

1. Create a new user: prefma

[root@localhost ~]# adduser prefma
Copy after login

2. Create an initialization password for the new user

[root@localhost~]# passwd prefma
Changing password for user prefma.
New password:             # 输入密码
Retype new password:      # 再次输入密码
passwd: all authentication tokens updated successfully.
Copy after login

2. Authorization

Individual users can only have full permissions under this home. Other directories require authorization from others. Root user permissions are often required and can be granted by modifying the sudoers file.

The newly created user cannot use the sudo command, and authorization needs to be added to him.

1. Find the sudoers file path and grant permissions

1 [root@localhost~]# whereis sudoers                     # 查找sudoers文件路径
2 sudoers: /etc/sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz
3 [root@localhost~]# ls -l /etc/sudoers                  # 查看权限
4 -r--r----- 1 root root 3938 Sep  6  2017 /etc/sudoers  # 只有读权限
5 [root@localhost~]# chmod -v u+w /etc/sudoers           # 赋予读写权限
6 mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----)
Copy after login

2. Modify the sudoers file

Enter the command vim /etc/sudoers Modify the sudoers file. Add new user information:

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
prefma ALL=(ALL) ALL #这个是新用户
Copy after login

Then enter the command wq! to save the changes.

3. Withdraw permissions

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

4. New user login

Create a new connection, log in with the newly created user, and verify, for example:

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

Related reference: centOS tutorial

The above is the detailed content of How to create a new username and password under centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!