0

I have a single user system and I want to set my home directory not to /home/username, but to /home. How can I do it so nothing would blow up?

It would be fine, if the solution would avoid something like linking /home/username to /home.

Any ideas?

1
  • 4
    I'm the only user of my Kubuntu laptop and my Debian router; still I use /home/kamil. IMO changing the default is not worth the hassle, unless you have a good reason (but then compare XY problem). Let's suppose you did the change and everything works. Then you install a program that uses /home/$USER where it should use $HOME. Or it adds a non-system user for whatever reason and takes a subdirectory of /home over. Or you want to create another user to test something. My point is the idea may backfire in the future. Maintenance burden. Commented Feb 13, 2020 at 6:21

2 Answers 2

2

See the usermod command:

-d, --home HOME_DIR
The user's new login directory. If the -m option is given, the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist.

Otheriwse, I agree with Kamil's comment, you are probably shooting yourself in the foot, and if you want to avoid a directory level, /username would probably be a better idea since that leaves /home available.

1
  1. Warning: one problem with setting /home as a main_user1's HOME is that such user may trample over the content of /home/other_user2/ and /home/other_user3/

  2. Adding to the answer form @xenoid, it is likely necessary to identify and update the ~/.bashrc and other scripts that may set the value of $HOME environment variable.

  3. The reason for your desire to set a non-conventional directory would be useful for a possibly better alternative.

I would likely create a link /myhome -> /home/my_userid

And invoke some programs like this:

HOME=/myhome XYZ_program

Which exports the desired variable and value only to the program being spawn.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .