sudo returns "sorry, you are not allowed to preserve the environment" error
Issue
sudo returns sorry, you are not allowed to preserve the environment error:
-
Run sudo with
-Eoption to preserve their existing environment variables.$ export MY_NAME=foobar $ sudo -E bash -c 'echo $MY_NAME' sudo: sorry, you are not allowed to preserve the environment -
Below sudo rule exists for the user
bob ALL=(ALL) NOPASSWD: /usr/bin/bash *
Environment
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- sudo
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.