Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Let's say I have a user called panos and he has his home directory located at /home/panos. Then, I create a another user called Tom:

adduser Tom

It creates a user Tom who has home dir: /home/Tom

The question is: what if I would like to create a new user and give him as home dir the home dir of another user. For example, let's create the user Jerry and pass him as his home dir the home dir of user Panos:

adduser -d /home/panos Jerry

but there's an error saying:

adduser: warning: the home directory already exists.
Not copying any file from skel directory into it.

However, if you take a look at the /etc/passwd file:

tail -n 3 /etc/passwd
anthony:x:501:501::/home/anthony:/bin/bash
panos:x:502:502::/home/panos:/bin/bash
Jerry:x:503:503::/home/panos:/bin/bash

it seems it worked. But when I tried to log in as Jerry:

[root@LinuxAcademy ~]# su Jerry
bash-4.1$ bash: /home/panos/.bashrc: Permission denied
bash-4.1$ 

it prevents me from loggin in as Jerry and it also changes my prompt (the PS1).

So, how can I do this? Is it possible?

share|improve this question
1  
Do you intend for Jerry and panos to share a home directory? Or will you be disabling/deleting the panos account? –  steeldriver Jun 14 at 19:49
    
yes I indent for Jeery and panos to share the same home directory. I don't want to delete/disable any of them. –  drpaneas Jun 14 at 21:05
    
You should note that this means that any changes either of them applies to their environment (editor preferences, desktop wallpaper, startup applications, .bashrc,...) will affect the other user as well. –  Joseph R. Jun 14 at 21:57
    
of course, I have no problem with it. –  drpaneas Jun 14 at 22:16

2 Answers 2

up vote 0 down vote accepted

You did create a directory with a home directory that already exists.

adduser: warning: the home directory already exists.
Not copying any file from skel directory into it.

This isn't an error, it's a warning. Usually, the reason not to create a home directory is for a user whose home directory isn't supposed to exist. Here, it does, which has a high chance of being an error by the system administrator (e.g. a bad copy-paste or a buggy script). Since you really meant to use an existing home directory, ignore this warning.

[root@LinuxAcademy ~]# su Jerry
bash-4.1$ bash: /home/panos/.bashrc: Permission denied
bash-4.1$ 

You did log in as Jerry. That bash 4.1 is running as Jerry. Jerry doesn't have the permission to read his ~/.bashrc, either because the file .bashrc is only readable to panos (and perhaps to a group that Jerry doesn't belong to), or because the directory /home/panos itself is not accessible (x permission) to Jerry. So bash tells you that it can't read its startup file, and it displays its default prompt.

Having multiple users with the same home directory is very unusual (excluding system accounts whose home directory doesn't matter). What you should do about permissions depends what you're trying to achieve by this. You probably do want to at least allow all these users to read their home directory.

share|improve this answer

Well, of course. It's trying to read and execute /home/panos/.bashrc. That file belongs to user panos, and presumably is set to -rwx------ or something like that. So Jerry tries to read it and can't. Permission denied, just as it says.

It's possible that Jerry actually is logged in. Try whoami.

So, put them in the same group and make it group-rx, or make it world-rx, or something like that. And do the same for the home directory (executable, for a directory, means searchable).

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.