Tips Linux Training - HOW TO Create Users and Groups in Linux

hodiep735

New member
## Cách tạo người dùng và nhóm trong Linux

**Tổng quan**

Trong hướng dẫn này, bạn sẽ học cách tạo người dùng và nhóm trong Linux.Bạn sẽ tìm hiểu cách tạo tài khoản người dùng mới, đặt mật khẩu cho người dùng và gán người dùng cho một nhóm.Bạn cũng sẽ học cách xóa tài khoản người dùng và xóa một nhóm.

** Điều kiện tiên quyết **

Để làm theo hướng dẫn này, bạn sẽ cần những điều sau đây:

* Một hệ thống Linux
* Một cửa sổ đầu cuối
* Các lệnh sau:
* `userAdd`
* `passwd`
* `userDel`
* `GroupAdd`
* `GroupDel`

** Tạo tài khoản người dùng mới **

Để tạo tài khoản người dùng mới, hãy sử dụng lệnh sau:

`` `
userAdd <usName>
`` `

Trong đó `<SuserName>` là tên của tài khoản người dùng mới.

Ví dụ: để tạo một tài khoản người dùng mới có tên là `John`, bạn sẽ sử dụng lệnh sau:

`` `
useradd John
`` `

** Đặt mật khẩu cho người dùng **

Khi bạn đã tạo một tài khoản người dùng mới, bạn cần đặt mật khẩu cho người dùng.Để làm điều này, hãy sử dụng lệnh sau:

`` `
passwd <Susername>
`` `

Trong đó `<Susername>` là tên của tài khoản người dùng.

Ví dụ: để đặt mật khẩu cho tài khoản người dùng có tên `John`, bạn sẽ sử dụng lệnh sau:

`` `
Passwd John
`` `

** Gán người dùng cho một nhóm **

Theo mặc định, tất cả các tài khoản người dùng mới được gán cho nhóm `người dùng`.Tuy nhiên, bạn có thể gán người dùng cho một nhóm khác bằng lệnh sau:

`` `
usermod -Ag <Srogname> <Username>
`` `

Trong đó `<SrognName>` là tên của nhóm và `<Username>` là tên của tài khoản người dùng.

Ví dụ: để gán tài khoản người dùng có tên `John` cho nhóm` sudo`, bạn sẽ sử dụng lệnh sau:

`` `
usermod -ag sudo john
`` `

** Xóa tài khoản người dùng **

Để xóa tài khoản người dùng, hãy sử dụng lệnh sau:

`` `
UserDel <Username>
`` `

Trong đó `<Susername>` là tên của tài khoản người dùng.

Ví dụ: để xóa tài khoản người dùng có tên `John`, bạn sẽ sử dụng lệnh sau:

`` `
Người dùng John
`` `

** Xóa một nhóm **

Để xóa một nhóm, hãy sử dụng lệnh sau:

`` `
GroupDel <GroupName>
`` `

Trong đó `<SrognName>` là tên của nhóm.

Ví dụ: để xóa nhóm có tên `sudo`, bạn sẽ sử dụng lệnh sau:

`` `
GroupDel sudo
`` `

** Tài nguyên bổ sung **

* [Dự án tài liệu Linux: Quản lý người dùng] (https://www.tldp.org/howto/user-man quản lý-howto/)
* [Dòng lệnh Linux: Quản lý người dùng] (https://linuxcommand.org/lcp/050-user-man quản lý.html)

## hashtags

* #linux
* #Users
* #các nhóm
* #Userman Quản lý
* #LinuxCommandLine
=======================================
## How to Create Users and Groups in Linux

**Overview**

In this tutorial, you will learn how to create users and groups in Linux. You will learn how to create a new user account, set a password for the user, and assign the user to a group. You will also learn how to delete a user account and delete a group.

**Prerequisites**

To follow this tutorial, you will need the following:

* A Linux system
* A terminal window
* The following commands:
* `useradd`
* `passwd`
* `userdel`
* `groupadd`
* `groupdel`

**Creating a New User Account**

To create a new user account, use the following command:

```
useradd <username>
```

Where `<username>` is the name of the new user account.

For example, to create a new user account named `john`, you would use the following command:

```
useradd john
```

**Setting a Password for the User**

Once you have created a new user account, you need to set a password for the user. To do this, use the following command:

```
passwd <username>
```

Where `<username>` is the name of the user account.

For example, to set a password for the user account named `john`, you would use the following command:

```
passwd john
```

**Assigning the User to a Group**

By default, all new user accounts are assigned to the `users` group. However, you can assign a user to a different group using the following command:

```
usermod -aG <groupname> <username>
```

Where `<groupname>` is the name of the group and `<username>` is the name of the user account.

For example, to assign the user account named `john` to the `sudo` group, you would use the following command:

```
usermod -aG sudo john
```

**Deleting a User Account**

To delete a user account, use the following command:

```
userdel <username>
```

Where `<username>` is the name of the user account.

For example, to delete the user account named `john`, you would use the following command:

```
userdel john
```

**Deleting a Group**

To delete a group, use the following command:

```
groupdel <groupname>
```

Where `<groupname>` is the name of the group.

For example, to delete the group named `sudo`, you would use the following command:

```
groupdel sudo
```

**Additional Resources**

* [The Linux Documentation Project: User Management](https://www.tldp.org/HOWTO/User-Management-HOWTO/)
* [The Linux Command Line: User Management](https://linuxcommand.org/lcp/050-user-management.html)

## Hashtags

* #linux
* #Users
* #groups
* #usermanagement
* #LinuxCommandLine
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock