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.

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
  • 207,228
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

:-)