Change Default Directory for User on a Linux System

You can use the usermod command to change the default home directory for a user.

usermod -d /path/to/dir username

What this command does is edit the file /etc/passwd. Opening /etc/passwd you will find there is a line for every user, including system users (mysql, posftix, etc), with seven fields per line denoted by colons.

The first field is our user and the last two fields are the starting directory and the shell. For example, the following line will login user mattdamon to /var/www/html/mattdamon.

mattdamon:x:0:0:root:/var/www/html/mattdamon:/bin/bash


Was this article helpful?

mood_bad Dislike 53
mood Like 45
visibility Views: 130488