Linked Questions
12 questions linked to/from Why are PATH variables different when running via sudo and su?
20
votes
3
answers
21k
views
Why is PATH reset in a sudo command? [duplicate]
After much frustrating head-brick-wall contact, I've discovered this:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/steve/bin
$ sudo bash
# echo $PATH
/usr/local/...
0
votes
1
answer
372
views
Why are sudo su and bash root script paths different? [duplicate]
Admin note: This question is different then why is sudo path different then su because the environmental variables in a bash script ran from cron do not appear to carry over from environmental ...
0
votes
1
answer
467
views
Trying to run a program in /root/ by other user by adding it to path [duplicate]
Specifically, I am using conda command part of Miniconda distribution. It happens that the installer put files in /root/miniconda3/.
The problem is that /root/miniconda3/bin is in path, but the ...
219
votes
9
answers
184k
views
How to make `sudo` preserve $PATH?
I have a program that is installed in a custom directory under /opt. To make it easier to run it, I edited my bashrc to add said directory to my path:
export PATH=$PATH:/opt/godi/bin:/opt/godi/sbin
...
136
votes
8
answers
40k
views
Which is the safest way to get root privileges: sudo, su or login?
I would like to have the root account in safety even if my unprivileged user is compromised.
On Ubuntu you can only use sudo for "security reasons" by default. However I am not sure it is any safer ...
17
votes
4
answers
30k
views
What environment do I get with sudo?
When I run sudo, what exactly happens to my environment?
When I run sudo command, it doesn't seem to see my or root's environment. For example, my path for both includes /usr/local/bin, but if I try ...
18
votes
2
answers
37k
views
Why running command as sudo returns command not found?
Sample command:
drush cc all
works, but this:
sudo drush cc all
gives me:
sudo: drush: command not found
Why? How to fix this?
0
votes
3
answers
3k
views
Command not found error - bash
$ which sudo emacs
/usr/bin/sudo
/home/user1/local_build/bin/emacs
$ sudo emacs /etc/apache2/sites-available/000-default.conf
sudo: emacs: command not found
$ emacs /etc/apache2/sites-available/...
1
vote
1
answer
1k
views
PATH env var declared in /etc/environment not inherited?
Working on Ubuntu 16.04.05.
According to the official debian and ubuntu documentations, variables declared therein should be inherited by all users;
Then how is the following explained:
root@pkara-...
0
votes
2
answers
726
views
Sudo echo path does not show the path that is used to execute as sudo
I'm confused by the following:
[user@QVr740-11 ~]$ which ninja
/usr/local/bin/ninja
[user@QVr740-11 ~]$ sudo which ninja
which: no ninja in (/sbin:/bin:/usr/sbin:/usr/bin)
[user@QVr740-11 ~]$ sudo ...
0
votes
1
answer
364
views
How to keep all environmental variables during sudo?
I am trying to use sudo -u postgres to run all postgresql commands inside a container and I'd like to inherit all environment variables before the sudo.
I need to sudo in the first place because some ...
2
votes
0
answers
222
views
Ubuntu 24.04 - /usr/games and /usr/local/games missing in $PATH for newly created user accounts
A fresh installed Ubuntu 24.04 system creates the first user account. That user account has by default the following $PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/...