LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 10-15-2002, 05:09 AM   #1
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Rep: Reputation: 30
How to set path permanently for a particular user


Recently I had install java jsdk, I need to set the path and inorder to exec program (export PATH and etc.) But everytime i quit the terminal and i need to type the path again.

How can I set the path permenently just for this user so i dont need to tpye everything all over again?
 
Old 10-15-2002, 05:43 AM   #2
bah
Member
 
Registered: Apr 2001
Posts: 38

Rep: Reputation: 15
It depends on your user's default shell. I presume you are using a bourne shell variant (bash or sh) - you can put the "export PATH ..." command in a file called ".profile" in your users home directory.
With csh and tcsh put a "setenv PATH ..." command in a file called ".login" in your user's home directory.

Last edited by bah; 10-15-2002 at 05:50 AM.
 
Old 10-15-2002, 09:14 AM   #3
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Original Poster
Rep: Reputation: 30
currently in my home dir I dont have any files call .profile, .csh or .tcsh
I am using Slacware 8.1
 
Old 10-15-2002, 09:54 AM   #4
sandy
Member
 
Registered: Aug 2002
Location: Mumbai,India
Distribution: Linux Mint 12, Gentoo
Posts: 230

Rep: Reputation: 30
Quote:
Originally posted by Sifvion
currently in my home dir I dont have any files call .profile, .csh or .tcsh
I am using Slacware 8.1
Check for the file .bash_profile or .bashrc
and add the lines
PATH=$PATH:<full path of java executable dir>
export PATH
 
Old 10-15-2002, 10:05 AM   #5
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Original Poster
Rep: Reputation: 30
I dont have any files call bash_profile or bashrc. Hmmm.......
 
Old 10-15-2002, 10:07 AM   #6
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
Then you have to create them. Slackware by default doesn't have these files in user's home directories, it usually goes by the global file /etc/.profile
 
Old 10-15-2002, 10:26 AM   #7
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Original Poster
Rep: Reputation: 30
So trickykid which file should I create. There are quite a number of files mention above. Please advise
 
Old 10-15-2002, 10:33 AM   #8
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
Usually you can create or use either .bashrc or .bash_profile which would probably be the most used ones when using in the home directory of that particular user.
 
Old 10-15-2002, 10:56 AM   #9
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Original Poster
Rep: Reputation: 30
so when after i create this .bashrc or .bash_profile and put those export PATH command when i reboot the system or open a terminal i will not need to key in any command again?
 
Old 10-15-2002, 11:05 AM   #10
sandy
Member
 
Registered: Aug 2002
Location: Mumbai,India
Distribution: Linux Mint 12, Gentoo
Posts: 230

Rep: Reputation: 30
just open a new terminal and you would be able to see the difference. Or if u want to see the change in the same terminal try source .bashrc
 
Old 10-15-2002, 05:20 PM   #11
bah
Member
 
Registered: Apr 2001
Posts: 38

Rep: Reputation: 15
bash will source .profile if it doesn't find a bash-specific .bash_profile in your home directory. I prefer to use .profile for things like PATH cause then it is available (potentially) if you switch shells.

If the shell is an interactive shell (as opposed to a login shell), then bash will source from .bashrc. This means that if you put commands in a .profile it won't necessarily show up in a new xterm unless you log out and then log back in.
 
Old 10-15-2002, 08:45 PM   #12
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Original Poster
Rep: Reputation: 30
hmmmm...... I created a file call .bash_profile and open a terminal and type java no command found. I guess i need to try .bashrc and try again. Will post the outcome when I get home.
 
Old 10-15-2002, 11:09 PM   #13
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 55
Did you put the lines as stated above to this file
PATH=$PATH:/path/to/java/bin
export PATH
?
after it's done run
source .bash_profile
or
. .bash_profile
to update environment
 
Old 10-16-2002, 08:50 AM   #14
Sifvion
Member
 
Registered: Jan 2002
Location: Singapore
Distribution: Slackware
Posts: 250

Original Poster
Rep: Reputation: 30
okie after i source .bash_profile it work. But after i close the terminal and open again the path is gone again. thus i need to source .bash_profile again.
 
Old 10-16-2002, 11:02 AM   #15
0x0001
Member
 
Registered: Sep 2002
Distribution: Slackware 8.1
Posts: 84

Rep: Reputation: 15
A simple solution would be to set JAVA_HOME to where you have java installed. To do this goto /etc/profile.d
This directory contains various files that will be executed when you log on IIRC. Files ending with .sh are read if you use bash-like shells, files ending in .csh will be read when using tcsh-like shells.
Sample for tcsh, assuming you hava java installed in /usr/local/java.

vim /etc/profile.d/java.csh
type in:
#!/bin/tcsh

setenv JAVA_HOME /usr/local/java

save and set permission to executable (chmod 755 /etc/profile.d/java.csh)

done.

btw you should create a symlink /usr/local/java to the real place java lies around, this simplyfies(sp?) updates of java to linking to the new version. (this however is only how i prefer to do it, so it's not important
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
edit value of PATH permanently rsumbeling Linux - General 2 12-13-2004 10:57 AM
permanently adding to the path hyphenage Linux - General 12 07-16-2003 01:14 AM
setting PATH permanently evian Linux - Software 3 03-14-2003 11:29 AM
How to set PATH permanently chandhru Linux - Newbie 3 09-24-2002 12:43 AM


All times are GMT -5. The time now is 04:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration