Adding to the $PATH when sudoing

Normally to add to your $PATH permenantly you do something like this: export PATH=$PATH:/new/dir. You may notice though tht this doesn't always seem to work. Here's an example:

$ export PATH=$PATH:/home/sbrl/bin
$ newcommand # works
$ sudo bash
# newcommand # works
# exit
$ sudo newcommand # doesn't work...wait what?

When a command is run with sudo, it doesn't respect your existing $PATH variable. To change it, you need to open the file /etc/sudoers and add your path to the line that says something like

Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin

In order for your folder to be in your $PATH when you use sudo command.

Tag Cloud

3d 3d printing account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio automation backups bash batch blog bookmarklet booting bug hunting c sharp c++ challenge chrome os cluster code codepen coding conundrums coding conundrums evolved command line compilers compiling compression containerisation css dailyprogrammer data analysis debugging demystification distributed computing documentation downtime electronics email embedded systems encryption es6 features ethics event experiment external first impressions future game github github gist gitlab graphics hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet interoperability io.js jabber jam javascript js bin labs learning library linux lora low level lua maintenance manjaro network networking nibriboard node.js operating systems own your code pepperminty wiki performance phd photos php pixelbot portable privacy problem solving programming problems projects prolog protocol protocols pseudo 3d python reddit redis reference releases rendering resource review rust searching secrets security series list server software sorting source code control statistics storage svg talks technical terminal textures thoughts three thing game three.js tool tutorial twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 xmpp xslt


Art by Mythdael