7

I have been using Linux & Unix for a long time. The first time I learned Unix is in a computer classroom with many students, where the instructor told us that you can use ssh to log in to remote workstations provided by the university I was studying in.

In that context, I immediately know that Unix is a multi-user operating system because there were more students than workstations. (Pigeonhole principle.)

Somehow after many years of use, I know basically what the umask (default to 002) is and that the default permission of a user (and a new user) is 755 for folders, 644 for files.

But after thinking a little deeper about it, it seems that the default permission setting is insecure in such a multi-user operating system. Although it makes sharing data easier, I still feel strange when you can easily list & copy other users' files within their home directory.

So is why the default umask 002 in many Unix systems? Is there any historical reason that traditional Unix chose this design?

(One possible reason I can think of is that, during 1970 ~ 1980 computers are used mostly in scientific research and the computing power is very limited. So when the early version of Unix comes out, they decided that the default permission should be for easy sharing instead of privacy protection.)

closed as primarily opinion-based by Serge, HalosGhost, G-Man, countermode, Satō Katsura Oct 14 '16 at 5:43

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Actually, 002 is fairly recent (probably a side effect of using group-per-user). – Thomas Dickey Oct 8 '16 at 12:04
  • @ThomasDickey so 022 is more common ? – Bossliaw Oct 8 '16 at 14:59
  • 3
    It depends (there are a lot of Ubuntu and Fedora end-users). By "recently", I see in the change history for my rc-files that I noticed Debian doing this in 2001. That's only about a third of the time span since Unix began. In paid work, 022 is common (or 077). – Thomas Dickey Oct 8 '16 at 15:07
  • @roaima I am not the one who votes for the re-open, maybe the voter is interested in this question and wants to see more possible answers or explanations – Bossliaw Jan 30 '18 at 6:31
10

Unix was originally and for a long time used in a professional environment. In a professional environment, it is very common to work on the same topic as colleagues. Some files are confidential; for example every email program I've ever seen creates files that are only readable to the owner (mode 600). But it makes sense to have files be publicly readable by default: most files are not confidential.

On a private machine, the issue is moot since there is only one user.

Some systems which are expected to have multiple users who don't collaborate much use 077 as the umask. It's up to the system administrator to decide.

These days, version control systems with a central repository accessed over a network protocol and multiple working copies (CVS, subversion, git, mercurial, …) are very common, so it's less common for users to directly access the same files. Until the 1990s, this was less common, and users forgetting to give read permissions to files that others were supposed to work on was a common problem.

To ensure that files will always be private even if you forget to run chmod, put them under a private directory, e.g.

mkdir ~/private
chmod 700 ~/private

Nobody else (except root, of course) can access files under ~/private, no matter what their permissions are.

  • 2
    Re last point on macOS: it is relevant that ~/Desktop/, ~/Documents/, etc., (except ~/Public/) all have mode 700 (i.e. "drwx------"), i.e. they are private directories by default. – Drux Dec 17 '17 at 8:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.