4

Basically I created a new sudoer without a home directory (adduser --no-create-home), but now, everytime I login with it I get prompted with a "Could not chdir to home directory: No such file or directory".

Is there a file that dictates where the user session starts so I can change this?

2 Answers 2

6

You can set the user home directory with usermod -d _homedir_ username command.

For example:

usermod -d / sudouser

sets the homedir of sudouser to the root directory.

However, root directory is not a good choice here, especially if you login with the user to an interactive shell. Shells might create their own files when you are logging in, and any extra files in root level is not a good thing.

2
  • 1
    I found the answer by myself and was going to post it here but apparently my rep is too low. Thank you for the clarifications on the interactive shell part though!
    – Luiz Berti
    Apr 11, 2014 at 0:47
  • Late comment, but you can always post your own answer to your own question. So as it stands, this question has an answer but now doesn’t have the answer. If you are still around and reading this and remember what you did, please post your own answer to share with all. Dec 15, 2020 at 16:05
-3

/etc/passwd dictates a user's home directory. edit it with vipw

4
  • usermod is the way to change user settings. Apr 11, 2014 at 0:27
  • usermod just modifies /etc/passwd Apr 11, 2014 at 0:34
  • Here: You must make certain that the named user is not executing any processes when this command is being executed if the user's numerical user ID, the user's name, or the user's home directory is being changed. usermod checks this on Linux, but only check if the user is logged in according to utmp on other architectures. Apr 11, 2014 at 0:43
  • 1
    Not a concern. You edit /etc/passwd and change the home directory, this only affects new processes launched for that user. Existing processes continue to use the old $HOME until they exit. Apr 11, 2014 at 17:01

You must log in to answer this question.

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