• Thông Tin Cần Biết
  • Hướng Dẫn
  • Câu Hỏi Thường Gặp
  • Thông Tin Cần Biết
  • Hướng Dẫn
  • Câu Hỏi Thường Gặp
Home/Hướng Dẫn/Linux/Ubuntu 22.04 – Add User

Ubuntu 22.04 – Add User

2 lượt xem 0

Sau khi cài đặt Ubuntu 22.04, chỉ có một người dùng được bạn cấu hình trong quá trình cài đặt. Và đây là administrative user. Nếu bạn muốn thêm nhiều tài khoản người dùng khác trên hệ thống, hãy cấu hình như sau.

Thêm mới user account

– Ví dụ: Thêm người dùng [bizmacvps].

ubuntu@localhost:~$ sudo adduser bizmacvps
[sudo] password for ubuntu: # mật khẩu của user hiện tại
Adding user `bizmacvps' ...
Adding new group `bizmacvps' (1001) ...
Adding new user `bizmacvps' (1001) with group `bizmacvps' ...
Creating home directory `/home/bizmacvps' ...
Copying files from `/etc/skel' ...
New password: # đặt mật khẩu của user mới
Retype new password: # comfirm mật khẩu của user mới
passwd: password updated successfully
Changing the user information for bizmacvps
Enter the new value, or press ENTER for the default # nhập thông tin user mới (để trống tất cả nếu bạn không cần)
Full Name []: bizmacvps
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
ubuntu@localhost:~$

– Nếu bạn muốn cấp đặc quyền cho người dùng mới, hãy cấu hình như sau.

ubuntu@localhost:~$ sudo usermod -aG sudo bizmacvps
ubuntu@localhost:~$ su - bizmacvps #chuyển sang user mới để test
Password:
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
bizmacvps@localhost:~$

# thử chạy một lệnh yêu cầu quyền root

thanhdd@localhost:~$ sudo ls -l /root
[sudo] password for bizmacvps:
total 4
drwx------ 3 root root 4096 Apr 24 08:23 snap

Xóa user account

– Nếu bạn muốn xóa tài khoản người dùng, hãy cấu hình như sau.
# xóa người dùng [thanhdd] (chỉ xóa tài khoản người dùng)

ubuntu@localhost:~$ sudo deluser bizmacvps

# xóa người dùng [bizmacvps] (đã xóa tài khoản người dùng và thư mục chính của anh ta)

ubuntu@localhost:~$ sudo deluser bizmacvps --remove-home

+ Nếu lỗi như sau

ubuntu@localhost:~$ sudo deluser bizmacvps
Removing user `bizmacvps' ...
Warning: group `bizmacvps' has no more members.
userdel: user bizmacvps is currently used by process 1881
/usr/sbin/deluser: `/sbin/userdel bizmacvps' returned error code 8. Exiting.
ubuntu@localhost:~$

# cần kill porcess gây lỗi này đi

ubuntu@localhost:~$ sudo kill -9 1881
Killed

+ Nếu xóa user [bizmacvps] rồi, cần xóa thêm foler chính của user này [/home/bizmacvps]

ubuntu@localhost:$ sudo rm -rf /home/bizmacvps

Kiểm tra User accounts

– Kiểm tra
+ Kiểm tra foler chứa thư mục chính của các user

ubuntu@localhost:~$ ls -l /home
total 4
drwxr-x--- 4 ubuntu ubuntu 4096 Apr 27 14:32 ubuntu

+ Kiểm tra file /etc/passwd xem còn user đã xóa không

ubuntu@localhost:~$ cat /etc/passwd

Chúc các bạn thành công!
Tags:Ubuntu 22.04

Bài viết này hữu ích không?

Yes  No
Bài viết liên quan
  • Ubuntu – Hướng dẫn mở rộng (Resize) dung lượng disk default
  • Ubuntu 22.04 – Enable root user
  • CentOS 8 – Fix lỗi Failed to download metadata for repo ‘AppStream’
  • CentOS 7 – Fix lỗi Not found trying other mirror
  • Tổng hợp lệnh RPM trên Linux
  • Xử lý lỗi full Inode trên server DirectAdmin

Không tìm thấy câu trả lời của bạn? Liên hệ

Linux
  • Ubuntu 22.04 – Add User
  • Reset password root trên CentOS 7
  • How to Install Debian 11
  • Tìm và xóa file Zero-Byte trong Linux
  • Cài đặt ConfigServer Security & Firewall (CSF) trên CentOS
  • Ubuntu 20.04 – Thiết lập địa chỉ IP tĩnh (Static IP Address)
  • Xử lý lỗi full Inode trên server DirectAdmin
  • Tổng hợp lệnh RPM trên Linux
  • CentOS 7 – Fix lỗi Not found trying other mirror
  • CentOS 8 – Fix lỗi Failed to download metadata for repo ‘AppStream’
  • Ubuntu 22.04 – Enable root user
  • Ubuntu – Hướng dẫn mở rộng (Resize) dung lượng disk default
All Categories
  • WordPress Website
  • Quản trị Website
  • Quản lý tài khoản
  • Tên miền
  • Chứng chỉ số SSL
  • Email Hosting Server
  • Web Hosting
  • VPS / Server
  • Plesk
  • DirectAdmin
  • Networking
  • Linux
  • Windows
© BizMaC | Rainbow E-Commerce