Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

export $PATH

Here is where users who have been using MEPIS awhile and know the basics of linux and MEPIS can ask questions.
Post Reply
Message
Author
User avatar
eemaestro
Forum Guide
Forum Guide
Posts: 1010
Joined: Wed Aug 02, 2006 12:12 pm

export $PATH

#1 Post by eemaestro » Sat Aug 08, 2015 2:30 pm

Here is my default PATH in bash:

Code: Select all

$ echo $PATH
/usr/lib/x86_64-linux-gnu/qt4/bin:/home/jon/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
When I prepend the current directory and current direcory's bin subdirectory, this works fine in bash:

Code: Select all

$ export PATH=./:~/bin:$PATH
jon@mepis1:~$ echo $PATH
./:/home/jon/bin:/usr/lib/x86_64-linux-gnu/qt4/bin:/home/jon/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
I don't understand. I guess something is resetting the PATH variable when I log in?

But when I post the same export command to the end of .bashrc, I still get the original PATH value posted above.
What is overwriting the PATH variable? Where should I put this export command?

User avatar
Stevo
Forum Veteran
Forum Veteran
Posts: 16175
Joined: Fri Dec 15, 2006 8:07 pm

Re: export $PATH

#2 Post by Stevo » Sat Aug 08, 2015 4:00 pm

Look to see if you have ~/.bash_profile, and if you have the PATH settings already in there. Then it's easy to edit to add your extra directory.

User avatar
eemaestro
Forum Guide
Forum Guide
Posts: 1010
Joined: Wed Aug 02, 2006 12:12 pm

Re: export $PATH

#3 Post by eemaestro » Sat Aug 08, 2015 4:29 pm

I do not have a ~/.bash_profile

User avatar
Stevo
Forum Veteran
Forum Veteran
Posts: 16175
Joined: Fri Dec 15, 2006 8:07 pm

Re: export $PATH

#4 Post by Stevo » Sat Aug 08, 2015 11:38 pm

Try creating one with that export command in it.

User avatar
eemaestro
Forum Guide
Forum Guide
Posts: 1010
Joined: Wed Aug 02, 2006 12:12 pm

Re: export $PATH

#5 Post by eemaestro » Sun Aug 09, 2015 11:01 am

I created ~/.bash_profile with teh export command, logged out, and logged back in.

Code: Select all

jon@mepis1:~$ echo $PATH
/usr/lib/x86_64-linux-gnu/qt4/bin:./:/home/george/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
jon@mepis1:~$ cat .bash_profile
export PATH=./:~/bin:$PATHjon@mepis1:~$
What is prepending that first field into PATH? How do I make the first two fields of PATH ./ and my ~/bin subdirectory?

User avatar
Adrian
Forum Veteran
Forum Veteran
Posts: 8877
Joined: Wed Jul 12, 2006 1:42 am

Re: export $PATH

#6 Post by Adrian » Sun Aug 09, 2015 1:28 pm

./ is a shortcut that means current path, you are not supposed to use it this way. If you use it in a script like that is going to be expanded, so for example if .bash_profile is called from /bin folder than ./ will be replaced with /usr/bin because that's the current path when the script is run. I might be wrong but this is how I interpret things happen...

Also read this:
http://unix.stackexchange.com/questions ... h-how-come

You have there some reasons why this is not a good idea and also the solution how to do it. Your choice...

User avatar
eemaestro
Forum Guide
Forum Guide
Posts: 1010
Joined: Wed Aug 02, 2006 12:12 pm

Re: export $PATH

#7 Post by eemaestro » Sun Aug 09, 2015 2:17 pm

Thanks, Adrian, for posting that URL. I read the two most popular replies. I decided to append the current directory to PATH after experimenting and discovering that the current directory is not searched by default unless I prepend dot slash to the command.

Post Reply

Return to “Regulars”