To set permissions for a new file, use the following steps:

  1. open a terminal and type umask 077 in order to set the permissions for the new file to be readable by everyone.
  2. close the terminal and reopen it so that you can continue working on the file.
  3. change the permissions of the new file to be as desired by using the following command:
  4. 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.

If you use a Bourne shell, you can put this in your ~/.bashrc: #!/bin/bash export PATH=$PATH:/usr/local/bin:/usr/sbin:/usr/bin:/usr/games export TMPDIR="/tmp"

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 a new file on Linux, you first need to determine the umask setting for the directory or file. This setting determines whether the file can be read, written, or executed. To set permissions for a new directory, you must be able to run the directory to access its contents. The umask setting is used to determine which bits of information are stored in the directory’s permission settings.