The problem: I set my umask for my user to be 0077. Now I use sudo instead of su when I need super-user access, and the problem is that whenever I execute a software installation using sudo with something like sudo pip3 install sympy, all the software installed by that gets the permission masked by 0077, meaning all these libs are not reachable by any user!!

The question: How can get all sudo calls to have the mask 0022 while my user calls have a mask of 0022?

Note: I did add the line Defaults umask = 0022 in sudo visudo and still didn't work. Is this everything to be done?

How do I set my umask: I have the line umask 0077 added to ~/.bashrc and ~/.profile.

1 Answer 1


This seems to have been overlooked:

Defaults umask_override

which does what was asked (see the sudoers manpage):

If set, sudo will set the umask as specified by sudoers without modification. This makes it possible to specify a more permissive umask in sudoers than the user's own umask and matches historical behavior. If umask_override is not set, sudo will set the umask to be the union of the user's umask and what is specified in sudoers. This flag is off by default. If set, sudo will run the command in a pseudo-pty even if no I/O logging is being gone. A malicious program run under sudo could conceivably fork a background process that retains to the user's terminal device after the main program has finished executing. Use of this option will make that impossible. This flag is off by default.

  • Thanks! I'll have to test it though :) Apr 24, 2016 at 22:23
  • Be careful editing /etc/sudoers using sudo. Syntax errors result may result in a lockout. Jul 6, 2020 at 4:28
  • 2
    That's what visudo is for. Jul 6, 2020 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.