Linux default Permissions

NuclearFusi0n

Diamond Member
Jul 2, 2001
7,028
0
0
$ touch text.txt
$ ls -l text.txt
-rw-r--r-- 1 nuclearfusi0n users 0 Aug 25 23:18 text.txt
$

Why are the default permissions 644 as opposed to 600?
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Technically: because your umask is 022 and not 066 or 077. That's usually set in the shell startup scripts somewhere. If you want, you can change by doing umask 077 and/or adding that your .bashrc or equivalent file.

Philosophically: because if you don't want other people generally reading over your stuff, you can chmod your home dir permissions to 700. If you create files outside your home dir, like in /tmp, they'll be world readable by default. Which kinda makes sense, because otherwise you wouldn't put them in a system-readable location.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Just Because.

What's wrong with letting people read your files? got something to hide?

(just kidding)

Actually default permissions are 666. The sign of the devil. Linux is of satan so we try to hide that fact using the umask utility.

Umask is set at the default of 0022. The first zero is for special stuff like sticky bit's for suid'ing files thru weird commands like chmod 7755 whatever, so we don't worry about it usually. So we pretend it's just 022.

Default permissions 666, Umask 022. So when we make a file it's 666 - 022 = 644.

Of course if you don't like that behavior you simply type: umask 066.

that changes it the default permissions to 600, or -rw-------

:)
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: cleverhandle
Technically: because your umask is 022 and not 066 or 077. That's usually set in the shell startup scripts somewhere. If you want, you can change by doing umask 077 and/or adding that your .bashrc or equivalent file.

Ah ya beat me too it. :(

 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
% grep umask ~/.bashrc ~/.bash_profile
/home/death/.bash_profile:umask 022
% touch foo
% ls -l foo
-rw-r--r-- 1 death death 0 Aug 26 01:47 foo
% umask 077
% touch bar
% ls -l bar
-rw------- 1 death death 0 Aug 26 01:47 bar
%
 

NuclearFusi0n

Diamond Member
Jul 2, 2001
7,028
0
0
death :cool:

Anyways, thanks guys, I remember seeing the umask command in /etc/profile and wondering what it did....:D:beer:

# 077 would be more secure, but 022 is generally quite realistic
umask 022
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: NuclearFusi0n
death :cool:

Funny story actually, I think everyone thinks it's real serious, like "oooh, I'm....DEATH." I actually couldn't think of a username the first time I used linux, finally I got so angry at my horrible name-inventing skills that I just said "who cares" and put in "death." Stuck ever since... :p
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: NuclearFusi0n
death :cool:

Anyways, thanks guys, I remember seeing the umask command in /etc/skel/.bashrc and wondering what it did....:D:beer:

BTW, it's actually a shell built-in. Try "whereis umask", it's not there. :p Try "man umask" and you get the man page for the C function. Try "help umask", and bash tells you all about it. :)