
Để thêm user trong vps của bạn, bạn có thể thực hiện theo cách đơn giản sau đây:
Kết nối với VPS qua SSH bằng Putty trên windows hoặc Terminal trên Ubuntu/Mac bằng tài khoản root.
Giả sử bạn cần thêm người dùng hostingaz ta sẽ thực hiện như sau:
Thêm/xóa user trên VPS Ubuntu
root@test1:~# sudo adduser hostingaz Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for newuser Enter the new value, or press ENTER for the default Full Name []: nguyen van a Room Number []: 122 Work Phone []: 123456789 Home Phone []: 123456789 Other []: khong co gi them Is the information correct? [Y/n] y
Thiết lập quyền cho user hostingaz
sudo /usr/sbin/visudo
tìm đến dòng
# User privilege specification root ALL=(ALL:ALL) ALL
thêm vào dưới nó dòng sau:
hostingaz ALL=(ALL:ALL) ALL
Ta lưu lại thiết lập bằng cách nhấn Ctrl + X sau đó điền Y và enter
Xóa user hostingaz khỏi vps
ta dùng lệnh
sudo rm -rf /home/hostingaz
Thêm/xóa user trên VPS Centos
[root@vultr ~]# sudo adduser hostingaz [root@test2 ~]# sudo passwd hostingaz Changing password for user hostingaz. New password: Retype new password: passwd: all authentication tokens updated successfully.
Tiếp theo ta thiết lập quyền cho user hostingaz
sudo /usr/sbin/visudo
Tìm đến dòng:
## Allow root to run any commands anywhere root ALL=(ALL) ALL
điền thêm vào dưới nó:
hostingaz ALL=(ALL) ALL
Sau đó lưu lại thiết lập bằng cách nhấn Shift + Z + Z
Xóa user hostingaz ra khỏi hệ thống VPS centos
ta dùng lệnh sau:
sudo userdel hostingaz
nếu bạn muốn xóa triệt để tất cả dữ liệu liên quan tới hostingaz ta dùng lệnh
sudo userdel -r hostingaz