Nothing working for non-root user

April 10, 2016 413 views
Linux Basics DigitalOcean Configuration Management Deployment Ubuntu

On a fresh droplet, I created a new user. I gave them sudo access as described here (I am running Ubuntu 15.10 but I assume it's all the same). My /etc/sudoers now contains

username ALL=(ALL:ALL) ALL

I then set up SSH access for the new user as described in this article.

When I first logged in as this new user, I could not do anything at all. Attempting to create a new directory in my user's own home folder gave me Permission denied errors. When I logged in two days later, this was no longer a problem, but I remain at a loss about what happened there. I documented this here.

Now as I carry on attempting to configure my application, this user seems to have major problems. I have added the following to the user's .bash_profile:

export PATH="$HOME/.rbenv/bin:$PATH"

Logging out and logging back in, this directive is not taking effect:

$ echo $PATH

When I try to source it from the command line, I get:

$ source ~/.bash_profile
-sh: 2: source: not found

And just for kicks:

$ sudo source ~/.bash_profile
sudo: source: command not found

I am at a complete loss. This behavior is unlike anything I am seeing described in any documentation. All tutorials and instructions I read take for granted that these commands will operate normally without any further steps.

Please help me understand what is happening here.

1 Answer

When you created the user, what was the exact command you used? It seems that your shell was set to /bin/sh, which would happen if you used useradd or adduser --shell /bin/sh instead of plain adduser. Your shell being sh instead of bash would explain why your .bash_profile isn't applied and why source isn't working (It's a Bash builtin; the equivalent in sh is .. Note that both forms are shell builtins rather than external commands, and so sudo source and sudo . will never work.) You can change your shell to Bash by running chsh -s /bin/bash and then logging out & back in.

  • Yes, that was the answer! The instructions I was following had me create the user with the command:

    useradd -d /home/username -m username

    I started over with a new droplet and just used:

    adduser username

    and I am no longer having the problems I mentioned.

Have another answer? Share your knowledge.