Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to create a new user and give him possibility to use git. So, I've installed git:

sudo apt-get install git

After that I've created a user:

sudo useradd -d /home/developer -s /bin/bash -g sudo -m developer

And now I have a problem. When I switch to a new user and try to do something like this:

git clone <<here is a path>>

I get this error message:

fatal: unable to access '/home/roman/.config/git/config': Permission denied

I can't get why environment variables points to another user folders and what is the good way to fix it. I also believe that I didn't specify something properly during creation of a new user (that is why environment variables have not proper values).

The same problem appears when I try for instance to run mc... I get this:

Cannot create /home/roman/.config/mc directory

For more information have this

cat /etc/passwd | grep developer

developer:x:1001:27::/home/developer:/bin/bash

So, can somebody explain me how to solve my problems?

share|improve this question
    
The result of whoami is developer. And result of cat /etc/passwd | grep developer is developer:x:1001:27::/home/developer:/bin/bash. –  Roman Dryndik Oct 27 '13 at 1:08
    
Ok, I've changed my question. –  Roman Dryndik Oct 27 '13 at 1:16
    
how did you switch to a new user? you should log in as the new user. your problem is likely that you used sudo and the environmental variables were preserved –  bodhi.zazen Oct 27 '13 at 4:05
    
How did I switch to another user? kh-kh... su developer. And yes I used sudo when ran useradd, because otherwise I will get useradd: cannot lock /etc/passwd; try again later. –  Roman Dryndik Oct 27 '13 at 8:19
    
log out and log back in as developer, or use check the man pages for sudo and environmental variables such as $HOME –  bodhi.zazen Oct 27 '13 at 15:14
add comment

1 Answer

When you use sudo and/or sudo to switch users, Environmental variables so not necessarily change. It depends on what command you use, options, and configuration.

Example:

 sudo -u children echo $HOME
 /home/bodhi

Check the man pages for details and/or post your command for help.

Setting the PATH so it applies to all users, including root/sudo

http://manpages.ubuntu.com/manpages/oneiric/man1/su.1.html

http://manpages.ubuntu.com/manpages/oneiric/en/man8/sudo.8.html

share|improve this answer
add comment

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.