Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux default file permission

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.

like image 579
Steve Kuo Avatar asked Oct 23 '08 04:10

Steve Kuo


People also ask

How do I set default permissions in Linux?

To change the default permissions that are set when you create a file or directory within a session or with a script, use the umask command. The syntax is similar to that of chmod (above), but use the = operator to set the default permissions.

How do I check the default permissions in Linux?

You can use the umask (stands for user mask) command to determine the default permissions for newly created files. The umask is the value that is subtracted from the 666 (rw-rw-rw-) permissions when creating new files, or from 777 (rwxrwxrwx) when creating new directories.

What is the chmod 777 means?

777 - all can read/write/execute (full access). 755 - owner can read/write/execute, group/others can read/execute. 644 - owner can read/write, group/others can read only.

What are the 3 standard Linux permissions?

read – The Read permission refers to a user's capability to read the contents of the file. write – The Write permissions refer to a user's capability to write or modify a file or directory. execute – The Execute permission affects a user's capability to execute a file or view the contents of a directory.


1 Answers

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.

like image 168
Matt Curtis Avatar answered Oct 02 '22 01:10

Matt Curtis