2

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.

DevOpsSauce
  • 213
  • 1
  • 3
  • 18
  • @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. – DevOpsSauce Jun 04 '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 '$'. – DevOpsSauce Jun 04 '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 ? – Jonas Czech Jun 04 '16 at 17:32
  • You usually use the friendlier adduser instead of useradd. – guntbert Jun 05 '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 06 '16 at 06:03

2 Answers2

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
muru
  • 197,895
  • 55
  • 485
  • 740
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

:-)

DevOpsSauce
  • 213
  • 1
  • 3
  • 18
  • 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. – DevOpsSauce Jun 04 '16 at 20:54