Tạo một User trên CentOS 7/8
Ví dụ : tạo User tên centos
[root@localhost ~]# useradd centos
[root@localhost ~]# passwd centos
Changing password for user centos.
New UNIX password: # nhập password
Retype new UNIX password: # confirm password
passwd: all authentication tokens updated successfully.
Chuyển User trên CentOS 7/8
Ví dụ : chuyển User root qua centos
localhost login: centos # login username
password: # nhập password
[centos@localhost ~]$ su - # swicth to root
Password: # nhập password của root
[root@localhost ~]# # just switched to root
Giới hạn người dùng chạy lện su trên CentOS 7/8
Ví dụ: chỉ cho user [wheel] group chạy được lệnh [su]
[root@localhost ~]# usermod -G wheel centos
[root@localhost ~]# 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
[redhat@localhost ~]$ su -
Password:
su: Permission denied # denied normally
Xóa một User trong CentOS 7/8
# remove a user [centos] (only removed user account)
[root@localhost ~]# userdel centos
# remove a user [centos] (removed user account and his home directory both)
[root@localhost ~]# userdel -r centos