Question

Nothing working for non-root user

Posted April 10, 2016 2.9k views
Linux Basics Ubuntu DigitalOcean Configuration Management Deployment

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
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.

Submit an Answer