I created a new user with useradd name
and forgot to use -d -m
to create their home directory. I tried making one, copying the contents of /etc/skel, and chown
ing everything to the new user.
Aliases don't work, such as ll
, and I just have a $
at the command prompt, instead of name@server ~$
.
Also, using the scroll wheel dumps garbage on the command line :(
How do I fix this, or is it easier to delete the user and start over?
You have
$
at the command prompt because you are using thesh
shell.The shell with
name@server
is based on thebash
shell.You have to change the default shell for the newly created user via :
usermod -s /bin/bash
.Usingusermod
again to add the user home directory if it wasn't present.usermod -d /home/username
If the user has no home directory specified in
/etc/passwd
:Run
mkhomedir_helper <username>
to create the home directory.mkhomedir_helper
will create the user home directory and copy the stuff in/etc/skel
as well.If the user already has a home directory specified in
/etc/passwd
:Such as via
usermod -d /some/directory
,mkhomedir_helper
will not work. The only way is to manually create the home directory for the affected user.If you forgot to use
-d -m
, the best and quick option is to runwith creates the home directory as if you would have provided the missing options.
Here's a quick bash script. Run as root with
sudo
. It takes any number of arguments, each being a username in need of a home directory. This makes a few assumptions: that your home directories are in/home
, and that your skeleton directory is/etc/skel
. These are the defaults on Ubuntu. You can download orwget
/curl
this script from gist.Take a look at the
xdg-user-dirs-update
command. It will create the default X windows directories: Desktop, Download, etc...A user without the the the default directories can run
xdg-user-dirs-update --force
to create the directories. I had to do this for one of my user accounts.I recommend reading the man page before running the
xdg-user-dirs-update
command. The man page forxdg-user-dir
adds a few more details.The "XDG Base Directory Specification" is part of the freedesktop.org specifications.
To change the default value of the new user's home directory, you can give
command. See useradd -D [options] from
I just ran into this (Ubuntu 12.04) and I solved it by creating a temp user, copying over the user directory, chowning it, and finally deleting the temp user.