Describe usermod operation in linux with practical examples


Describe usermod operation in linux with practical examples

In this article we learn how to change user group , how to lock and unlock user account, how to change user shell , how to change user home directory and how to change the description of the user if need to change the comment.

After creating user if any modification is needed then we use “usermod” command.

How to change user group

When user is added then default primary group is created if there is any requirement to change we can change the primary group using usermod command and use ‘-g” switch to execute this change.

Lets take an example when we create test user by default “test” primary group is created . if we need to change the primary group  to “primary” we execute the below command.

#usermod –g primary test

Describe usermod operation in linux with practical examples
Describe usermod operation in linux with practical examples


If we need to change the secondary group we use “-G “ switch to do this job.

#usermod –G  secondary test

How to lock user account

Some time we need to lock user account for the security reason. To lock an user account we use “-L” switch .

#usermod –L test

How to unlock locked user account

To unlock a locked user account we “-U” switch.After executing thee below command we unlock the locked account.

#usermod –U test

How to change the default user shell

To change the default user shell we can use “usermod “ command along with “-s” switch. By default when user is created “/bin/bash” shell is created automatically. If we want to change it to nologin shell we execute the below command.

#usermod –s nologin test

How to change home directory of user

When user is created a home directory is automatically created for that user. To change the default home directory we use “-d” switch.

#usemod –d <path name>

How to change user description

In an organization when a user retired or transferred we need to change the description of the user .To do this we use “-c” switch.
#usermod –c “updated comment” test





Please Donate To Bitcoin Address: [[address]]
Donation of [[value]] BTC Received. Thank You.
[[error]]
SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment