Usermod in Linux: Managing users
Introduction
The usermod command in Linux is used to change user account settings, such as the username, home directory, groups. It is an important system administration tool that lets you manage user accounts flexibly.
Main capabilities
- Changing the home directory: Allows you to change the location of the user's home directory using the
usermodcommand. - Changing the username: Gives you the ability to change the user's login while keeping all their data and settings.
- Managing groups: Allows you to change the group the user belongs to.
- Changing the UID: Allows you to modify the user's unique identifier (User Identifier) in a Linux system.
- Configuring the shell: Gives you the ability to change the user's shell type for working with the system.
WARNING
Using the usermod command requires administrator (root) privileges.
Syntax
Basic command syntax:
bash
usermod [options] LOGINMain options:
-l: change the username-d: change the user's home directory-aG: add the user to a group-g: change the user's group
Usage examples
Changing the home directory:
bash
usermod -d /new/home/dir usernameChanging the username:
bash
usermod -l newusername oldusernameAdding to a group:
bash
usermod -g newgroupname usernameChanging the user's UID:
bash
usermod -u newuid usernameChanging the user's shell:
bash
usermod -s /bin/bash usernameINFO
All changes are applied immediately, but may require restarting the user's session.
Additional resources
WARNING
When working with the usermod command, be careful, as incorrect use can lead to problems with accessing the system.
Our resources
Telegram channel: https://t.me/
F3 Cloud: https://f3cloud.com