views:

993

answers:

2

Is there someway to set the default file permission in Linux? That is, the file permission for a newly created file (regardless of the context for which it was created ). I know about putting umask in the shell startup but that only works for shell sessions. When I transfer files to a Linux box using pscp, the file is always created with permissions of 664 (rw-rw-r--). The has occurred across every flavor of Linux that I've used. This is especially annoying when I pscp a file to shared Linux machine (like my ISP). Until I can shell in and chmod the permission, the file is basically sitting there with read access for everyone, which is not exactly secure.

+8  A: 

Put the umask in the non-interactive shell startup (.bash_profile, .zshenv, .tcshrc depending on your shell). Then it'll run for non-login sessions.

Matt Curtis
How do I know what shell the pscp server is going to use?
Steve Kuo
When you log on (with putty), what shell does it start up?Or, if you're logged on, "grep yourname /etc/passwd" and see what the last entry on that line is ("/bin/bash", for example.)
Matt Curtis
this didn't work for me. I put it in my .bash_profile and still have the same problem
eviljack
@eviljack: can you tell me what shell you're using (grep yourname /etc/passwd)? Can you tell whether anything from .bash_profile runs when pscp connects? (Maybe put an "echo" in the file, and try plink, it might help diagnose the problem.)
Matt Curtis
+2  A: 

If you want to affect the whole system, you can also put it in /etc/profile

Kim