ubuntu add, delete users, modify user name, modify host name

Add user

The operation of adding a user in ubuntu is as follows:

sudo adduser test

It will automatically create a group with the same name, create /home/test/, copy files from etc/skel/, and set a password and related initial identity information

delete users

The ubuntu delete user operation is as follows:

sudo userdel test
cd /home/
sudo rm -r test

ubuntu modify user name

Enter Ubuntu, open the terminal, enter sudo su to migrate to the root user. Note that you must migrate to the root user first.
ubuntu modify the user name user to robot, please modify in order

1. Modify the sudoer file

sudo gedit /etc/sudoers

insert image description here
2. Modify the shadow file

The format of the login-related content stored in this file is as follows:

username: passwd: lastchg: min: max: warn: inactive: expire: flag

Login Name: Encrypted Password: Last Modified Time: Min Interval: Max Interval: Warning Time: Inactive Time: Expiration Time: Flag

sudo gedit /etc/shadow

Modify the login name
insert image description here3, modify the start directory

cd /home/
sudo mv test robot

4. Modify the password file

sudo gedit /etc/passwd

In /etc/passwd, find which line after the original user name, you need to modify three fields
insert image description here

5. Modify the user group
If you need to modify the user group, change the user in /etc/group to robot.
Your user name should be found in many groups and must be modified! ! ! !

6. Finally, enter the /etc/sudoer file again and delete the username user

insert image description here7. Restart, log in again, the user name is changed successfully

ubuntu modify the host name

1. Modify the hostname file
and change it to robot-home

sudo gedit /etc/hostname

insert image description here

2. Modify the hosts file

sudo gedit /etc/hosts

insert image description here

3. Restart, log in again, and the host name is successfully modified

ubuntu change password

[Tip] When changing the password and user name, please change the password first, restart, then change the user name, and restart. If you change your password after changing your username, you may not be able to log into Ubuntu.
insert image description here

Guess you like

Origin blog.csdn.net/qq_44333320/article/details/126332264