Fedora Linux Support Community & Resources Center
  #1  
Old 18th April 2012, 07:46 PM
neocortex Offline
Registered User
 
Join Date: Sep 2011
Posts: 30
linuxfirefox
Where and how to put a PATH= variable?

Hello ALL!
I am trying to put a system-wide PATH= variable, but nothing seems to work.
Firstly, I added a lines in /etc/profile. Somewhere here:
Code:
# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi
Then, I removed these lines, and added sh-script in /etc/profile.d/ with something like (this is what I've found in one post; example is with JDK):
Code:
echo 'export JAVA_HOME=/opt/jdk1.5.0_12' > /etc/profile.d/jdk.sh
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile.d/jdk.sh
source /etc/profile.d/jdk.sh
That did not work either. So, I wonder how to put permanent and system-wide PATH=?

Thanks in advance!
PM
Reply With Quote
  #2  
Old 25th April 2012, 10:15 AM
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,276
linuxfedorafirefox
Re: Where and how to put a PATH= variable?

I'd suggest to add your PATH variables to your $HOME/.bashrc
If you are required to log in as root in terminal, and do need those paths from root account too, edit the /etc/bashrc with root rights.

Simplest is to directly add them there.
Adding them to /etc/profile.d/script.sh works too, but there is no need to source it from there (loop), as these scripts are read EVERY time you open a terminal, or log in, or something alike.

The simplest, and imho savest, way to add your own PATH, is like the next few lines in ~/.bashrc:
Code:
JH=/opt/jdk1.5.0_12
export PATH=$JH:$PATH
Hope this helps.
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Text User Interface (TUI) // Windows 8+ & Fedora 20+ Dualboot
Reply With Quote
  #3  
Old 25th April 2012, 02:03 PM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 897
linuxfirefox
Re: Where and how to put a PATH= variable?

The way I set system-wide shell settings is to add a script to the /etc/profile.d directory.

I think to do what you want, I would use a text editor to create a new file java-path.sh somewhere in my home directory, which contains
Code:
JAVA_HOME=/opt/jdk1.5.0_12
export JAVA_HOME
PATH="$JAVA_HOME/bin:$PATH"
Next, copy this into /etc/profile.d with
Code:
su -c 'cp java-path.sh /etc/profile.d/'
Now restart the shell. (Close the current terminal, and open a new one; or log out and in again.) Test that the settings have taken hold with
Code:
printenv JAVA_HOME PATH
Reply With Quote
Reply

Tags
path, variable

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PATH variable gbaldeck Using Fedora 3 27th February 2010 08:26 PM
path variable michaelcarlson Using Fedora 2 14th August 2006 03:02 PM
In FC4 where is the $PATH variable set. d2e2 Using Fedora 12 18th September 2005 06:02 PM
$PATH variable fkar Using Fedora 6 1st February 2005 03:41 PM
PATH Variable flyer2000 Using Fedora 4 25th September 2004 05:29 PM


Current GMT-time: 17:45 (Thursday, 24-07-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat