1

I am totally new to the Linux world. If I create a new user, does it have read and write permission to its own home directory by default?

Logically, it should, but I'm not sure.

1 Answer 1

2

Creating a new user means just adding a new entry to a relevant "database". In a most basic (e.g. home) setup the "database" is just text in /etc/passwd file. See man 5 passwd.

One can add an entry manually, a relatively safe way is sudo vipw. "Relatively", because you really shouldn't do this manually, especially if you're "totally new in Linux world". Still it's totally possible.

Simply adding an entry to the file does not create a home directory, does not alter existing directories, does not change their mode (permissions) or ownership. It's possible to specify a nonexistent directory. In my Debian there's nobody user with /noexistent home directory. This path does not exist. Still I (having root privileges) can start a process as nobody, the user is valid.

"Real" users, who want to log in interactively, almost always need and want respective home directories with read and write permissions. Your intuition is quite right: usually they should have them.

Basically it's the admin's job to create a setup that works for OS and its users.

Here come programs that automate the task of creating users, at least to some degree. E.g. in Debian there is adduser. It can create a new user, create a home directory for the user, copy skeletal files to the directory, set sane ownership and permissions up. Desktop environment (if any) may provide a way to add users via GUI (graphical user interface, i.e. not in a text console) and also set additional things up. If available, such specialized program or functionality is usually the right way to add a new user. In general there may be ways to configure the program to skip some steps, but the default configuration should not surprise you much.

To summarize:

If I create a new user, does it have read and write permission to its own home directory by default?

  • In general, by default – no, not necessarily, maybe by chance (e.g. if you specify a directory readable and writable for everyone) or if you (the admin) take care of this.
  • In a common distro, by using a user-friendly tool designed to manage users and to create home directories anew – yes (unless explicitly (miss)configured otherwise).
5
  • thanks a lot for your informations! could you write an example, which I can create a user and has read and write permission to its own home directory, please? Sep 5, 2020 at 13:15
  • @NaseerAkbari What Linux distribution are you using? Sep 5, 2020 at 13:20
  • I use, Fedora 32 and Ubuntu! Sep 5, 2020 at 16:16
  • @NaseerAkbari I don't know Fedora. Ubuntu is based on Debian, there is adduser in it. See man 8 adduser and where it says "adduser will create a home directory …". Both distros should support useradd which does not create a home directory. adduser is deliberately designed to do more than useradd. An example command is sudo adduser joe. Sep 5, 2020 at 17:03
  • thanks a lot for your support! Sep 5, 2020 at 18:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .