Change Default User Home Directory While Adding A New User

By default, when we create or add users to Linux System, user’s default home directory is created to /home. To change default directory to /opt/, we need to change few settings as mentioned below:

STEP 1: Open /etc/default/useradd

# nano /etc/default/useradd

The default home directory defined by HOME variable, find line that read as follows:

HOME=/home replace to HOME=/opt/

Save and close the file. Now you can add user using regular useradd command:

# useradd uddika
# passwd -d uddika

Verify user information:

# finger uddika
Output:
Login: uddika Name: uddika
Directory: /opt/uddika Shell: /bin/bash
Never logged in.
No mail.
No Plan.

0 comments:

Post a Comment