How can I create files in my home directory without root?
To add a user with his home directory automatically, adduser
is the correct command, while it creates user, home directory, allows you to set password in that moment & let you set more info about the user (full name, address, phone, etc). I recommend you to remove the user, remove the created dir and run this command of course as root.
# userdel 'user'
# rm -rf /home/user_dir
# adduser 'user' (follow instructions)
# ls -ltr /home
drwxr-xr-x user user size date user_dir
Or you could also change owner to your created dir
# chown -R user:user user_dir
NOTE: -R to change all inside dirs/files owner -R = recursive
UPDATE: This works specifically in Ubuntu
![Elephant454](https://i.stack.imgur.com/Y6fDy.jpg?s=256&g=1)
Elephant454
Updated on September 18, 2022Comments
-
Elephant454 almost 2 years
I created a user, then using root I created a folder for him. The folder has the same name as the user.
When I am logged in as the user, I cannot create files or edit existing ones without using sudo. I used the command
useradd elephant
then created a password for him usingpasswd elephant
.I'm running a fresh install of Arch Linux. Is there anything obvious that I am forgetting?
-
Adelina Dimachi about 10 yearsDid you
chown
the folder over to the new user? -
Elephant454 about 10 years@ewhac that was the obvious sort of thing that I was looking for. Looks like I still have a bit to learn... Well, practice makes perfect. Sorry for wasting your time. Thanks a bunch! One last question, how do I mark this as solved?
-
jasonwryan about 10 yearsYou accept the correct answer by upvoting it and clicking the green arrow underneath it...
-