How can I create files in my home directory without root?

5,413

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

Share:
5,413
Elephant454
Author by

Elephant454

Updated on September 18, 2022

Comments

  • Elephant454
    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 using passwd elephant.

    I'm running a fresh install of Arch Linux. Is there anything obvious that I am forgetting?

    • Adelina Dimachi
      Adelina Dimachi about 10 years
      Did you chown the folder over to the new user?
    • Elephant454
      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
      jasonwryan about 10 years
      You accept the correct answer by upvoting it and clicking the green arrow underneath it...