To set umask permanently, you can add the umask command to your shell's configuration file. Here’s how to do it for different shells:
For Bash
- Open the
.bashrcfile in your home directory:nano ~/.bashrc - Add the following line at the end of the file:
(Replaceumask 022022with your desired umask value.) - Save the file and exit the editor (Ctrl + O, Enter, Ctrl + X).
- Apply the changes:
source ~/.bashrc
For Zsh
- Open the
.zshrcfile in your home directory:nano ~/.zshrc - Add the following line at the end of the file:
umask 022 - Save the file and exit the editor (Ctrl + O, Enter, Ctrl + X).
- Apply the changes:
source ~/.zshrc
For Other Shells
If you are using a different shell, look for its respective configuration file (like .profile or .bash_profile) and add the umask command there.
After following these steps, the umask setting will be applied every time you start a new shell session.
