How To's

Change Default Directory for User on a Linux System

140,918 views · 47 found this helpful · 55 did not

Was this helpful?

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

  • Updated

← All articles

Still stuck?

Our engineers answer tickets directly, 24/7.