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?

Luiz Berti
  • 155
  • 1
  • 2
  • 5

2 Answers2

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.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • 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 '14 at 00: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. – Giacomo1968 Dec 15 '20 at 16:05
-3

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

Giacomo1968
  • 3,542
  • 27
  • 38
Michael Martinez
  • 2,645
  • 3
  • 24
  • 35
  • usermod is the way to change user settings. – Florin Asăvoaie Apr 11 '14 at 00:27
  • usermod just modifies /etc/passwd – Michael Martinez Apr 11 '14 at 00:34
  • [Here](http://linux.die.net/man/8/usermod): 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. – Florin Asăvoaie Apr 11 '14 at 00: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. – Michael Martinez Apr 11 '14 at 17:01