I have some duplicates in my PATH I need to remove, however I don't know where they're coming from. I'm on Ubuntu 10.04 with bash, and have checked ~/.bashcr (there's no ~/.bash_profile or ~/.profile).

Is there any command that can show the files that add to or set PATH? And more generally, is there a command that can show where any environment variable is being set?

asked 10 Aug '10, 20:46

Kurtosis's gravatar image

Kurtosis
1081310
accept rate: 50%




try:

echo $env

this should let you know where your environment is being set for your individual user.

however there are global path sets as well, the usual suspects are:

/etc/profile
/etc/profile.d/*
/etc/bashrc
/etc/bash.bashrc
/etc/environment

You can grep through them below:

grep -HP "^\s*(export)*\s*PATH=" /etc/profile.d/*
grep -HP "^\s*(export)*\s*PATH=" /etc/profile
grep -HP "^\s*(export)*\s*PATH=" /etc/bash*
grep -HP "^\s*(export)*\s*PATH=" /etc/environment

The above assume you are using bash.

ksh is below:

grep -HP "^\s*(export)*\s*PATH=" /etc/ksh.kshrc
link

answered 10 Aug '10, 21:12

rfelsburg's gravatar image

rfelsburg ♦
6061618
accept rate: 25%

Thanks! Your greps found it. Though 'echo $env' returns a blank line. Should something be in $env?

(11 Aug '10, 04:38) Kurtosis
1

Not sure with ubuntu, on redhat based systems it returns the file that your environment loads.

In may case it returns /home/$USER/.bashrc

(11 Aug '10, 12:27) rfelsburg ♦

Try the command "printenv". While it doesn't show where things are set, it shows what is set and often helps to pinpoint where the duplications arise.

You can get further details from:

man printenv

Good Luck.

link

answered 11 Aug '10, 15:01

DBA's gravatar image

DBA
2264
accept rate: 23%

$PATH will show what is in your PATH For me it shows: bash: /usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/surfraw:/usr/lib/surfraw:

Running Debian sid.

link

answered 12 Aug '10, 01:42

craigevil's gravatar image

craigevil
1162
accept rate: 6%

and, if you want to know where does the library load, then you should change file /etc/ld.so.conf , add your new library path here...

link

answered 17 Aug '10, 11:49

twwwater's gravatar image

twwwater
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×3

Asked: 10 Aug '10, 20:46

Seen: 1,895 times

Last updated: 17 Aug '10, 11:49

powered by OSQA