New users and students looking for ways to learn how to use and manage Linux systems, the easiest place to start might be on Ubuntu Linux OS. Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices.
The same way you use your mouse and keyboard to make basic user accounts changes or perform others simple tasks on Microsoft Windows OS, Ubuntu also makes it easy for you. Just like how easy it is to work on Windows computers, Ubuntu desktop is that easy as well and great for beginners.
However, when you’re learning to use and understand Ubuntu Linux, you’ll also want to learn the comnands behind the graphics and mouse-clicking. and how to use them. This tutorial is going to show you how..
This post shows new users and students what the usermod command is used for and how to use it.
When you’re ready to learn how to use the usermod commands, follow the guide below:
About usermod command:
The usermod command is used by system adminstrators to change users’ account settings similar to the passwd command. Like using your mouse and keyboard to change account settings in the GUI. the usermod is the way to do it on the command line.
The syntax is the rule and format of how the usermod command can be used. the systax’s options can be reordered. but straight format must be followed.,.
Below is an example syntax of how to use the usermod comamnd.
usermod [OPTION]. LOGIN.
The command line options are switches or flags that determined how the commands are executed or controlled. they modify the behavior of the command. they are separated by spaces and followed after the commands options.
Below are some options of the usermod command:
|LOGIN.||Replace LOGIN .. with the name of the account you want to change its settings. If the account doesn’t already exist, the command will fail and not execute..|
|-c, –comment COMMENT||Use the -c or –command COMMENT option to set or change the user’s account comment field.|
|-d, –home HOME_DIR||Use the -d or –home HOME_DIR option to change or set a new home directory for the user account.|
|-f, –inactive INACTIVE||Use the -f or –inactive INACTIVE option to set password inactive after expiration to INACTIVE|
|-g, –gid GROUP||Use the -g or –gid GROUP option to force use GROUP as new primary group|
|-G, –groups GROUPS||Use the -G or –groups GROUP option to set new list of supplementary GROUPS|
|-a, –append||Use the -a or –append option to append the user to the supplemental GROUPS|
|-l, –login NEW_LOGIN||Use the -l or –login NEW_LOGIN option to create new value of the login name|
|-h, –help||Display help message and exit.|
|-L, –lock||Use the -L or –lock option to lock the user account|
Below are some examples of how to run and use the usermod on Ubuntu Linux.
If you want to add an account name John to the sudo group, run the commands below.
usermod -a -G sudo john
If you wish to change John’s account Full Name or comment field, run the usermod command and specify John’s account name. in this case, it’s called john..
usermod -c "John Doe" john
If you’re not logged in as a root account, you may have to use the sudo command it it.
sudo usermod -c "John Doe" john
To change John’s account login name to paul, run the commands below.
sudo usermod -l paul john
To unlock John’s account, run the command below
sudo usermod -U john
To lock John’s account, run the commands below.
sudo usermod -L john
To change John’s home directory, run the commands below
sudo usermod -d /home/newHomeDir -m johnNewHome
When you run usermod with the –help option, you’ll see the help text below:
Usage: usermod [options] LOGIN Options: -c, --comment COMMENT new value of the GECOS field -d, --home HOME_DIR new home directory for the user account -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE -f, --inactive INACTIVE set password inactive after expiration to INACTIVE -g, --gid GROUP force use GROUP as new primary group -G, --groups GROUPS new list of supplementary GROUPS -a, --append append the user to the supplemental GROUPS mentioned by the -G option without removing him/her from other groups -h, --help display this help message and exit -l, --login NEW_LOGIN new value of the login name -L, --lock lock the user account -m, --move-home move contents of the home directory to the new location (use only with -d) -o, --non-unique allow using duplicate (non-unique) UID -p, --password PASSWORD use encrypted password for the new password -R, --root CHROOT_DIR directory to chroot into -s, --shell SHELL new login shell for the user account -u, --uid UID new UID for the user account -U, --unlock unlock the user account -v, --add-subuids FIRST-LAST add range of subordinate uids -V, --del-subuids FIRST-LAST remove range of subordinate uids -w, --add-subgids FIRST-LAST add range of subordinate gids -W, --del-subgids FIRST-LAST remove range of subordinate gids -Z, --selinux-user SEUSER new SELinux user mapping for the user account
Hope you like it and please come back soon for more Ubuntu Linux command!
You may also like the commands below: