2

This question already has an answer here:

I created a new non-root user and did the following:

useradd -m newusername 
passwd newusername 
usermod -a -G sudo newusername 
chsh -s /bin/bash newusername 

I need to install software as a non-root user, but when I'm logged in as that user,

cd Downloads

does nothing. The directory doesn't exist. Did I do something wrong when creating the user, or am I missing something?

cd /home/newusername/Downloads

does not work either.

marked as duplicate by chaskes, Videonauth, user323419, Eric Carvalho, Mark Kirby Jun 7 '16 at 17:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @JonasCz I'm going to try that post you mentioned. I think I made a mistake when making my home directory. Thanks for sharing that. – IRGeekSauce Jun 4 '16 at 17:13
  • @JonasCz That didn't work. I did the exact commands, but when I try to login (su - newusername), all I get is a '$'. – IRGeekSauce Jun 4 '16 at 17:29
  • I don't know what could be wrong in that case. Although since you say you made a mistake, you could just delete the user and start over, or perhaps use the graphical user management / administration utility ? – JonasCz Jun 4 '16 at 17:32
  • You usually use the friendlier adduser instead of useradd. – guntbert Jun 5 '16 at 11:34
  • When you type cd /home/newusername/Downloads what makes you think it didn't work? What is the output of pwd after you did cd /home/newusername/Downloads? – MadMike Jun 6 '16 at 6:03
1

Downloads, Desktop, Music, and the other directories are not part of /etc/skel, and they are not created by useradd (or adduser, for that matter). These directories, collectively known as the XDG user directories can be created using the xdg-user-dirs-update command, run as that user:

sudo -iu <user> xdg-user-dirs-update

For example:

# useradd -m foo
# getent passwd foo
foo:x:1001:1003::/home/foo:/bin/bash
# ls /home/foo/ -l
total 0
# sudo -iu foo xdg-user-dirs-update
# ls /home/foo/ -l                 
total 32
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Desktop
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Documents
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Downloads
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Music
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Pictures
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Public
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Templates
drwxr-xr-x 2 foo foo 4096 Jun  7 14:43 Videos
0

I believe I figured it out. I deleted that user and started over.

useradd -m newusername
passwd newusername 
usermod -a -G sudo newusername 
chsh -s /bin/bash newusername 

Then

su - newusername

And I get

newusername@kali:~$

And I'm able to

cd Downloads

:-)

  • Nevermind. It only lasts for that session. If I shutdown it's back to the same problem. This is getting frustrating and I can't seem to find a similar question anywhere. – IRGeekSauce Jun 4 '16 at 20:54

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