Linux usermod command is used to edit the user account . We can set user account expiry date ,change user login name, set the command for particular user, Add the user to the group
[root@program ~]# groupadd redhat
[root@program ~]# useradd rhel5
[root@program ~]# useradd rhel7
Add the user to the group -G option
Using -G option we can add the user rhel5 to the group Redhat
[root@program ~]# usermod -G redhat rhel5
[root@program ~]# usermod -G redhat rhel7
Edit the shell login -s option
Remove the shell login access for the user rhel7
[root@program ~]# usermod -s /sbin/nologin rhel7
[root@program ~]# su rhel7
This account is currently not available.
Set Expiry date -e option
[root@program ~]# su rhel5
Account has been login without any issue
set the expiry date for the user rhel5
[root@program ~]# usermod -e 2010-04-18 rhel5
After the date
$ su rhel5
Password:
Your account has expired; please contact your system administrator
Edit the comment or label for the user rhel5
[root@program ~]# usermod -c version5 rhel5
[root@program ~]# cat /etc/passwd | grep rhel5
rhel5:x:502:504:version5:/home/rhel5:/bin/bash
Change user login name -l option
[root@program ~]# usermod -l rhel55 rhel5
[root@program ~]# su rhel5
su: user rhel5 does not exist
[root@program ~]# su rhel55
Options:
-a, --append append the user to the supplemental GROUPS
(use only with -G)
-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
-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
-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
-Z, --selinux-user new selinux user mapping for the user account
How to edit modify delete the user account
0 comments:
Post a Comment