Files
freeCodeCamp/guide/chinese/linux/user-management-on-linux/index.md
2018-10-16 21:32:40 +05:30

81 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: User management on Linux
localeTitle: Linux上的用户管理
---
#### 注意:要以`sudo`身份运行命令您必须具有sudo用户帐户管理员
## 如何创建用户
#### 使用`adduser`或`useradd`命令将新用户添加到系统中。
```
$ sudo adduser username
```
请务必将`username`替换为您要创建的用户。
#### 使用`passwd`命令更新新用户的密码。
```
$ sudo passwd username
```
强烈建议使用强密码!
## 如何创建Sudo用户
要创建`sudo`用户,您需要首先使用上面的命令创建常规用户,然后使用`usermod`命令将此用户添加到`sudoers`组。
##### 在Debian系统Ubuntu / LinuxMint / ElementryOS `sudo`组的成员具有sudo权限。
```
$ sudo usermod -aG sudo username
```
##### 在基于RHEL的syatemsFedora / CentOs `wheel`组的成员有sudo privilages。
```
$ sudo usermod -aG wheel username
```
## 如何删除用户
##### 对于DebianUbuntu
```
$ sudo deluser username
```
##### 对于RHELFedora / CentOS
```
$ sudo userdel username
```
##### 创建组并添加用户
```
$ sudo groupadd editorial
$ sudo usermod -a -G editorial username
```
#### 注意:以`root`命令可以在没有sudo的情况下执行以上命令
切换到root在Ubuntu上运行`su -i`随后登录的用户的密码命令提示符更改为`#`的insted的`$`
##### 在Debian系统Ubuntu / LinuxMint / ElementryOS `sudo`组的成员具有sudo权限。
```
$ sudo usermod -aG sudo username
```
## 如何创建组
要创建组,请使用命令`groupadd`
```
$ sudo groupadd groupname
```
## 如何删除组
要删除组,请使用命令'groupdel'
`` ` $ sudo groupdel grouname``
#### 参考
[Debian的Ubuntu的](https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-ubuntu-16-04)
[RHELCentOS / Fedora](https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-a-centos-7-server)