The usermod command has several flags that allow you to modify user account settings. Here are some commonly used flags:
-
-a: Append the user to the supplementary groups. Used with-G.- Example:
usermod -a -G groupname username
- Example:
-
-c: Change the comment field (usually the full name).- Example:
usermod -c "New Comment" username
- Example:
-
-e: Set the expiration date for the user account.- Example:
usermod -e YYYY-MM-DD username
- Example:
-
-g: Change the primary group of the user.- Example:
usermod -g groupname username
- Example:
-
-l: Change the username.- Example:
usermod -l newusername oldusername
- Example:
-
-s: Change the login shell for the user.- Example:
usermod -s /bin/bash username
- Example:
-
-u: Change the user ID (UID).- Example:
usermod -u newUID username
- Example:
-
-d: Change the home directory (as previously discussed).- Example:
usermod -d /new/home/directory username
- Example:
These flags can be combined as needed to modify user accounts effectively. If you have any more questions or need further details, feel free to ask!
