PATH is not getting exported by default in Ubuntu 12.04

7,392

It works for me:

reut@HP-EliteBook-8470p:~$ which lesspipe 
/usr/bin/lesspipe

How to fix anyway?

Short answer - make sure the following line is in /etc/environment:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/your/specific/folder"

Notice the last folder is a specific folder you want to add. The folders you mentioned are in fact part of the PATH by default (unless you changed it).

If you want to extend your PATH:

# extend perserving old path (locations are prioritized by order)
PATH=$PATH:/some/folder
export PATH

You can add this code in ~/.bashrc to have it available to you specifically.

you can also add /some/folder to the line I mentioned in /etc/environment to have it available to everyone, so you'd end up with:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/some/folder"
Share:
7,392

Related videos on Youtube

bornfree
Author by

bornfree

Updated on September 18, 2022

Comments

  • bornfree
    bornfree over 1 year

    When i run su on command line and enter root password, I am getting error as mentioned below:

    Command 'lesspipe' is available in the following places

    • /bin/lesspipe

    • /usr/bin/lesspipe

    The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.

    lesspipe: command not found

    Command 'dircolors' is available in '/usr/bin/dircolors'

    The command could not be located because '/usr/bin' is not included in the PATH environment variable.

    I have to manually export PATH variable which earlier used to work by default.

    I then set the PATH variable in bashrc

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

    Now whenever I run su, I get this :

    bash: groups: command not found.

    However, I can tab groups command and the PATH variable is also set. Does anyone have any idea where should PATH variable be set so that it is exported for all users?(it was working fine earlier without any errors)