Methods of payment Abuse

The usermod command in Linux

27.03.2023, 02:44
The usermod command in Linux is used to change user account settings, such as username, home directory, groups.

The usermod command in Linux

usermod in Linux is used to change the properties of a user account. It can be useful in the following situations:
  1. Changing the home directory: If you want to change the user's home directory, you can use the usermod command to change the path to the new directory.
  2. Changing the username: If you want to change the username using the usermod command, you can change its name while saving all the data and settings.
  3. Changing the group to which the user belongs: If you want to change the group to which the user belongs, you can use the usermod command.
  4. Changing the user's UID: The UID (User Identifier) is a unique user identifier in a Linux system. If you want to change the user's UID, use the usermod command.
  5. Changing the type of user shell: A shell is a program that provides a user interface for working with a Linux system. If you want to change the user shell type, use the usermod command.
It can also be used to change various properties of a user account, but administrator rights (root) are required to use it.

Syntax

The syntax looks like this:
usermod [options] LOGIN
Here LOGIN is the name of the user for whom you want to change the settings.
 
Some of the most common options of the usermod command include:
-l: change user name
-d: change the user's home directory
-aG: add user to group
-g: change user group
Examples of using the usermod command:
 
To change the username "oldusername" to "newusername", run the following command:
sudo usermod -l newusername oldusername
To add the user "username" to the "newgroup" group, run the following command:
sudo usermod -aG newgroup username
Examples of using the command
 
The usermod command in Linux is used to change the properties of a user account. Using this command, you can change the user name, home directory, shell type, user ID (UID), and the group to which the user belongs.
 
Changing the user's home directory:
usermod -d /new/home/dir username
Changing the user name:
usermod -l newusername oldusername
Changing the group the user belongs to:
usermod -g newgroupname username
Changing the user's UID:
usermod -u newuid username
Changing the user shell type:
usermod -s /bin/bash username
Note: To use the usermod command, you need administrator rights (root).