usermod
The usermod command is a command line tool used in Unix-like operating systems, including Linux. It is primarily used for modifying user account attributes. It allows administrators to make changes to existing user accounts without having to delete and recreate them.
Some common uses of the usermod command include adding or removing users from specific groups, changing the user's home directory, updating the user's default shell, and modifying the account expiration date.
To use usermod, you need administrative privileges since it requires access and modification rights to the user’s account information stored in system files, such as /etc/passwd.
The usermod command follows a specific syntax, including specifying options and arguments such as the username or UID (User ID), then specifying the modification to be made.
It is important to be cautious when using the usermod command as any incorrect modifications may cause disruptions or prevent users from accessing their accounts. Therefore, it is recommended to double-check the changes before executing the command.
Overall, the usermod command is a powerful tool for system administrators to manage and modify user accounts efficiently and safely within a command line environment.
List of commands for usermod:
-
usermod:tldr:13b44 usermod: Change a username.$ sudo usermod --login ${new_username} ${username}try on your machineexplain this command
-
usermod:tldr:22350 usermod: Change a user home directory.$ sudo usermod --move-home --home ${path-to-new_home} ${username}try on your machineexplain this command
-
usermod:tldr:4876a usermod: Change a user id.$ sudo usermod --uid ${id} ${username}try on your machineexplain this command
-
usermod:tldr:873e4 usermod: Add a user to supplementary groups (mind the lack of whitespace).$ sudo usermod --append --groups ${group1,group2,---} ${username}try on your machineexplain this command
-
usermod:tldr:c0554 usermod: Change a user shell.$ sudo usermod --shell ${path-to-shell} ${username}try on your machineexplain this command