Skip to content

Path not the same in Ubuntu when using sudo


In case you run in to the same problem when running an application with sudo. Sudo does not keep the same $path environment as the current user.
This behaviour is the expected behaviour since sudo has been compiled with –with-secure-path=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin for security purposes. This change was intentionally done in order to make it harder to run Trojan scripts as root user.

If you want to change that behaviour you can follow the steps below:

Edit /etc/sudoers
$ sudo visudo
Add the following entry to the file
Defaults secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/other_paths/

Save the file.
It should work as expected.


useful words: sudo, ubuntu, $path in ubuntu, environment path

Posted in Knowledge Base.

Tagged with , , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.