In day to day system administration, many times we work with users and group and have to change user attributes like, to change user's home directory, inactive password, change group or add supplementary group, lock or unlock user's password etc.
In Redhat Enterprise Linux 6 changing user's attributes can be done with "usermod" command. Usermod command can be helpful for system administration as well as in RHCSA exam, as user administration is one of RHCSA/RHCE exam. In this post we will discuss about usermod command to modify different user attributes.
1. To add user to a supplementary group use usermod -a command
# usermod –a group3 user1
|
2. To change users GECOS/comment field use usermod -c
# usermod –c “User for transfer files” transfer_user
# cat /etc/passwd |grep transfer_user
transfer_user:x:502:502:User for transfer
files:/home/transfer_user:/bin/bash
|
we can also use chfn command to change finger information.
3. To change user's home directory
# usermod –d /transhome transfer_user
# cat /etc/passwd |grep transfer_user
transfer_user:x:502:502:User for transfer
files:/transhome:/bin/bash
|
use -m option to copy all files from old home directory to new home directory.
4. To change user's primary group
# id transfer_user
uid=502(transfer_user) gid=502(transfer_user)
groups=502(transfer_user)
# groupadd file_transfer
# usermod -g file_transfer transfer_user
# id transfer_user
uid=502(transfer_user) gid=503(file_transfer)
groups=503(file_transfer)
|
The group must exist.
5. To add a supplementary group.
# usermod -G transfer_user transfer_user
# id transfer_user
uid=502(transfer_user)
gid=503(file_transfer) groups=503(file_transfer), 502(transfer_user)
|
6. Lock or unlock a user's password.
# passwd -l transfer_user
Locking password for user transfer_user.
passwd: Success
# passwd -u transfer_user
Unlocking password for user
transfer_user.
passwd: Success
|
Usermod command is very useful for system administrators to manage users and groups.
You can find some of above mentioned commands very useful in RHCSA and RHCE exams.
If you are preparing for the Certification exams, try to read man pages for commands, make it your habit so you can learn more easy ways to do tasks in examination and try to concentrate on command based administration.
No comments:
Post a Comment