Linux user information modification tutorial
Linux system is a powerful operating system with a wealth of command line tools that can help users easily perform various operations. In Linux, user information includes user name, user ID, user group ID, home directory, default Shell, etc. This information can be modified through the command line. This article will introduce how to modify user information in a Linux system, and provide specific code examples to help readers get started quickly.
First of all, we need to understand several common commands to operate user information:
useradd
: used to create new user accounts. usermod
: Used to modify the attributes of existing user accounts. userdel
: Used to delete user accounts. passwd
: Used to modify user password. chsh
: Used to modify the user's default Shell. Next, we will use specific examples to demonstrate how to modify user information.
To create a new user, you can use the following command:
sudo useradd -m -s /bin/bash newuser
In the above command, the -m
parameter means that at the same time Create the user's home directory. The -s
parameter specifies the new user's default Shell as /bin/bash
. After executing this command, a new user named newuser
will be created.
If you need to modify the information of an existing user, you can use the usermod
command. For example, to change the home directory of user newuser
to /home/newdir
, you can execute the following command:
sudo usermod -d /home/newdir newuser
To change the user's password, you can use the passwd
command. For example, to change the password of user newuser
, you can execute the following command:
sudo passwd newuser
The system will prompt you to enter the new password twice to confirm the change.
If you need to modify the user's default Shell, you can use the chsh
command. For example, to change the default Shell of user newuser
to /bin/zsh
, you can execute the following command:
sudo chsh -s /bin/zsh newuser
To delete a user, you can use the userdel
command. For example, to delete user newuser
, you can execute the following command:
sudo userdel -r newuser
In the above command, the -r
parameter indicates that the user's home directory will also be deleted.
Through the above examples, we can see the specific operation method of how to modify user information in the Linux system. Users can choose the appropriate command to complete the corresponding operation according to the actual situation. I hope this tutorial can help readers better understand the modification of user information in Linux systems.
The above is the detailed content of Teach you how to modify Linux user information. For more information, please follow other related articles on the PHP Chinese website!