Per https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04 I created a new user with sudo privileges who can successully ssh in:
root@dev: adduser tom
root@dev: # Give him sudo privileges
root@dev: usermod -aG sudo tom
root@dev: # Copy keys to this account
root@dev:$ rsync --archive --chown=tom:tom ~/.ssh /home/tom
Then I exit to my local OS, and ssh back in as the new user, tom.
The only other thing I did was install Golang:
tom@dev: cd ~
tom@dev: curl -O https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz
tom@dev: sudo tar -xvf go1.12.1.linux-amd64.tar.gz -C /usr/local
tom@dev: sudo chown -R root:root /usr/local/go
tom@dev: # Must have used sudo on these but not sure???
tom@dev: mkdir -p $HOME/go/{bin,src}
tom@dev: nano ~/.profile
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
tom@dev: # Reload profile
tom@dev: . ~/.profile
When I go to create a new directory for a project in Go I get Permission denied
:
tom@dev: mkdir ~/go/src/foo
mkdir: cannot create directory ‘foo’: Permission denied
I can do it with sudo
but that’s tiring and doesn’t work right anyhow–if I try to nano main.go
in the new directory I can’t save because I don’t have privileges.
What did I do wrong that my new user has sudo privileges but can’t even create file or directory without it?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
@tomcampbell
I created a new droplet and replayed all of your commands without any errors to make sure you can create directories as normal user do this command
To make sure tom is the owner of your home directory and all of its sub directories
Hope this helps
THAT DID IT!!! Thank you, @Mohsen47! Obviously the problem line was where I gave root, which I didn’t really understand was a user and not a privilege level, permissions–not tom.
What a huge relief!
Wait, but now I have another question. What is the difference between these two commands? Is that giving the user tom sudo privileges has NOTHING to do with the $HOME directory? I would assume that sudo privileges would just naturally be granted to that directory, but I’m beginning to suspect that’s nothing close to the truth.