How to Create, List, Add, Edit, Assign and change user groups, and Delete Users and Groups in Linux
Commands used:
1. list users
– show current user
#users
– list all users
#cat /etc/passwd -or- #getent passwd
2. list groups
– show groups for current user
#groups
– show groups for a user
#groups username
– list all groups
#cat /etc/group -or- #getent group
3. Create a New User
– Create a New User
#useradd username
this command will create user and a group will also created for the new user with the same name
– Create a New User and Assign a Group in one command
#useradd -G groupname username
-or-
#useradd -G group1,group2,group3 username
4. change user password or set password for the new user
– #passwd username
5. add new group
– #groupadd newgroup
6. Add existing User to a Group
– add a User to a Group
#usermod -a -G group username
– add a User to Multiple Groups
#usermod -a -G group1,group2,group3 username
7. Removing user from group
– #gpasswd -d username group
8. Change User Primary Group
– #usermod -g group user
Note: -g lowercase to assign user primary group
9. delete groups
– #groupdel groupname
10. delete user
– #userdel username
– #userdel -r username
Note: -r option to remove user’s home directory and the user’s mail spool
Nguồn: https://codeigniterbrasil.com
Xem thêm bài viết khác: https://codeigniterbrasil.com/lap-trinh-linux/
Xem thêm Bài Viết:
- Hướng dẫn sử dụng hệ điều hành linux siêu tốc – bài 25 Xem cấu hình hệ thống (cpu, ram, hdd)
- Linux cat command summary with examples
- Cài nhiều hệ điều hành Windows và Linux trên một máy tính
- Hướng dẫn tạo USB Boot DLC2019 (NTFS / UEFI) Trên windows 10 ( sử dụng USB 32 GB )
- Hướng dẫn gỡ bỏ Ubuntu sạch sẽ nhất bằng lệnh trên Windows theo chuẩn UEFI-GPT
Bilal Heuser
May 16, 2020I think this guy must be deaf or mute because he (or she) never says anything! 😐