Tạo user mới trên LINUX CentOS 7

bởi | CentOS 7, LPI

Home » LPI » Tạo user mới trên LINUX CentOS 7

Thêm người dùng

User “cent” làm ví dụ bên dưới
[root@dlp ~]# useradd cent
[root@dlp ~]# passwd cent
Changing password for user cent.
New UNIX password: # set password
Retype new UNIX password: # confirm
passwd: all authentication tokens updated successfully.
[root@dlp ~]# exit # logout

Đổi Pass 1 user:
[root@thanhdd ~]# passwd cent

Thử chuyển đổi người dùng đã được thêm ở trên.

dlp login: cent # input user name
password: # password
[cent@dlp ~]$ su - # switch to root
Password: # root password
[root@dlp ~]# # just switched to root

Làm cho người dùng có thể (su) chuyển sang root với tư cách là người dùng quản trị

vì group user wheel mặc định có quyền root nên cần add user vào groud wheel để có đặc quyền root

[root@dlp ~]# usermod -aG wheel cent
[root@dlp ~]# vi /etc/pam.d/su
….
# 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

Để chuyển tiếp email cho người dùng root tới user khác

Hãy thiết lập như sau. (nó là ‘cent’ trong ví dụ này)
[root@dlp ~]# vi /etc/aliases
# Person who should get root’s mail
# last line: uncomment and change to a user
root: cent
[root@dlp ~]# newaliases # reload

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

# xóa một user [cent] (chỉ tài khoản người dùng đã bị xóa)
[root@localhost ~]# userdel cent
# xóa một user [cent] ( xóa cả tài khoản user và cả thư mục chính của user ấy)
[root@localhost ~]# userdel -r cent