Tạo người dùng User trên CentOS 8
1. Để thêm tài khoản người dùng phổ biến trên Máy chủ CentOS 8, Hãy đặt như sau.
Dùng lệnh:
useradd centos passwd centos
[[email protected] ~]# useradd centos [[email protected] ~]# passwd centos Changing password for user centos. New UNIX password: # input any password you'd like to set Retype new UNIX password: # confirm passwd: all authentication tokens updated successfully.
2. Nếu bạn muốn chuyển sang tài khoản người dùng root từ một người dùng thông thường, hãy sử dụng lệnh [su] để làm như vậy.
localhost login: centos # login username password: # input user password [[email protected] ~]$ su - # swicth to root Password: # input root password [[email protected] ~]# # just switched to root
3. Nếu bạn muốn giới hạn người dùng chạy lệnh [su], hãy đặt như sau.
Trong ví dụ bên dưới, chỉ người dùng trong nhóm [wheel] mới có thể chạy lệnh [su].
usermod -G wheel centos vi /etc/pam.d/su
[email protected] ~]# usermod -G wheel centos [[email protected] ~]# vi /etc/pam.d/su #%PAM-1.0 auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. #auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "wheel" group. # uncomment the following line auth required pam_wheel.so use_uid auth substack system-auth auth include postlogin account sufficient pam_succeed_if.so uid = 0 use_uid quiet account include system-auth password include system-auth session include system-auth session include postlogin session optional pam_xauth.so # verify settings with a user that is not in allowed group [[email protected] ~]$ su - Password: su: Permission denied # denied normally
Xóa người dùng User trên CentOS 8
Nếu bạn muốn xóa tài khoản người dùng, hãy đặt như sau.
userdel centos serdel -r centos
# remove a user [centos] (only removed user account) [[email protected] ~]# userdel centos # remove a user [centos] (removed user account and his home directory both) [[email protected] ~]# userdel -r centos
Chúc các bạn thành công! Mọi thắc mắc, cần hỗ trợ hãy bình luận bên dưới hoặc qua Fanpage Facebook, form liên hệ.