centos 创建新用户_如何在CentOS中创建新用户?

本文详细介绍了如何在CentOS系统中创建新用户,包括列出当前用户、使用`useradd`添加新用户、将用户添加到Sudoers、列出Sudoers用户以及将Shell更改为新用户的方法。
摘要由CSDN通过智能技术生成
centos 创建新用户

centos 创建新用户

CentOS is enterprise level Linux distribution which is clone of the RedHat. User management like create, add, remove etc is important part of the daily Administration tasks. In this tutorial we will look how to add new user to the CentOS system.

CentOS是企业级Linux发行版,是RedHat的克隆。 用户管理(例如创建,添加,删除等)是日常管理任务的重要组成部分。 在本教程中,我们将研究如何将新用户添加到CentOS系统。

列出当前用户 (List Current Users)

Before creating new user we will list existing users. We can use different methods to list existing users but following is the most practical way to list existing users. We will cat user names with the cut command.

在创建新用户之前,我们将列出现有用户。 我们可以使用不同的方法来列出现有用户,但是以下是列出现有用户的最实用方法。 我们将使用cut命令来管理用户名。

$ cut -f 1 -d : /etc/passwd
List Current Users
List Current Users
列出当前用户

使用useradd添加新用户(Add New User with useradd)

Now we can add our new user. We have all ready checked the existing users but if we try to add existing user we will files. We will use useradd command by providing the user name. In this example the user name will be poftut .

现在,我们可以添加新用户。 我们已经准备好检查现有用户,但是如果我们尝试添加现有用户,我们将归档。 我们将通过提供用户名来使用useradd命令。 在此示例中,用户名将为poftut

$ useradd poftut

将用户添加到Sudoers (Add User To The Sudoers)

Newly added user will have its own group and will not added to the other groups. Sudoers is a special mechanism which group name is wheel . Sudoers can run commands with administrator or root privileges. We can add newly created user to the Sudoers with usermod command. We will add user poftut to the wheel group which is Sudoers group.

新添加的用户将拥有自己的组,并且不会添加到其他组。 Sudoers是一种特殊的机制,组名是wheel 。 Sudoers可以使用管理员或root特权运行命令。 我们可以使用usermod命令将新创建的用户添加到Sudoers中。 我们将增加用户poftutwheel组是sudoers文件组。

$ usermod -aG wheel poftut

列出Wheel Group或Sudoers用户 (List Wheel Group or Sudoers Users)

We can list current wheel group user members with the following command.

我们可以使用以下命令列出当前的wheel组用户成员。

$ cat /etc/group
List Wheel Group or Sudoers Users
List Wheel Group or Sudoers Users
列出Wheel Group或Sudoers用户

将Shell更改为新用户(Change Shell To New User)

We can practically change shell to the newly created user with the su command. In this example we will change to the user poftut like below.

实际上,我们可以使用su命令将shell更改为新创建的用户。 在此示例中,我们将如下所示更改为用户poftut

$ su - poftut
Change Shell To New User
Change Shell To New User
将Shell更改为新用户
LEARN MORE  How To Prevent Deleting Files Accidentally?
了解更多信息如何防止意外删除文件?

翻译自: https://www.poftut.com/create-new-user-centos/

centos 创建新用户

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值