Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are running an Ubuntu server and have several people in the company that need to have SSH access. This is a web server and the different sites reside in /home. When I create a new user on the server with adduser "username" then a new directory is automatically created in /home. As the sites also reside here, I'd like to re-structure this and actually create /home/users/ and manage all user-directories from there. However, with adduser I can not set the home directory, and I can not find a way to change this easily.

If I use useradd and the -m option, I can specify the home directory. However, my bash is different. It only shows "$" instead of the server name and current directory, as is default (user@server:/home/). Also, tabbing to get the full filename does not work anymore. This should have to do with bash settings, but I can not get this to work.

So, the question is:

  • Is there an easy way to change the home directory when using adduser? OR:
  • How can the bash configuration be fixed when using useradd?

Note: I compared .bashrc and .profile for the new user with useradd and adduser, and they are identical.

share|improve this question
    
You may be getting /bin/sh for the user's login shell which doesn't have tab completion and has a much simpler prompting capability. – Dennis Williamson Nov 29 '10 at 1:11
up vote 1 down vote accepted

If you look at the adduser man page you will see that there is a -d or --home command line option which allows you to specify a users home directory.

share|improve this answer
    
Excellent, thanks! This was extremely simple and I have no idea how I did not find this before. If somebody knows what happens to bash when you use useradd I am still interested, but at least the user adding problem is solved! – user60129 Nov 28 '10 at 23:46
    
In Red Hat / Fedora land, you can set HOME in /etc/default/useradd to change the default. Not sure if that's the same in Ubuntu. – mattdm Nov 28 '10 at 23:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.