To set permissions for a new file, use the following steps:
- open a terminal and type umask 077 in order to set the permissions for the new file to be readable by everyone.
- close the terminal and reopen it so that you can continue working on the file.
- change the permissions of the new file to be as desired by using the following command:
- exit from your terminal and save your changes to a file called “permissions” in your home directory.
Steps to Set Permissions for New Files with Umask on Linux
To see the current umask, type: umask -S
Setting umask for a user
umask 077 This sets the umask to 077, which will prevent any user from reading or writing to the file without explicit permission.
alias ls=‘ls -F’ ..
Setting up a system-wide umask
If you’re running a multi-user server, it’s a good idea to set a good system-wide umask. You can do this by doing a umask setting in the global shell startup files for all shells installed on the system. ..
You can put the umask configuration in /etc/profile, as this will be read by Bash and Zsh on startup. If you use a login shell, it will also read the /etc/csh.cshrc and /etc/csh.login files.
Final Words
To set permissions for new files on a Linux system, use the umask command. This command sets the bits for a file or directory, allowing you to control who can access it. ..