How do I set `umask` permanently?

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

  1. Open the .bashrc file in your home directory:
    nano ~/.bashrc
  2. Add the following line at the end of the file:
    umask 022
    (Replace 022 with your desired umask value.)
  3. Save the file and exit the editor (Ctrl + O, Enter, Ctrl + X).
  4. Apply the changes:
    source ~/.bashrc

For Zsh

  1. Open the .zshrc file in your home directory:
    nano ~/.zshrc
  2. Add the following line at the end of the file:
    umask 022
  3. Save the file and exit the editor (Ctrl + O, Enter, Ctrl + X).
  4. 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.

0 Comments

no data
Be the first to share your comment!