The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
Same ol "no acceptable cc found in $PATH" but I'm not clueless... just still a noob SloYerRoll UNIX for Dummies Questions & Answers 4 10-22-2007 11:20 AM
Network Path Not Found Error "Sunfire V100" louisd11 SUN Solaris 4 12-13-2006 01:20 PM
Why is it Bad Idea to insert "." (Dot) to PATH ? amitbern UNIX for Dummies Questions & Answers 2 11-07-2005 12:12 PM
Adding "Private" to path name roadrunnerray UNIX for Dummies Questions & Answers 5 10-15-2004 11:33 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2006
PixelLover PixelLover is offline
Registered User
  
 

Join Date: May 2006
Location: Hamburg, Germany
Posts: 8
Unhappy How to add a variable to the "path"

Hello,

I am new to this board and I have several questions:

For two days now I've been trying to add a variable to my "path" -- without any success. What I want to do is add the path for my MySQL database to my "path" so I can access it from anywhere. Why is this such a hard thing to do in UNIX? Everybody recommends something else. WHERE do I have to add the path. Is the file called ".bash-profile" or ".cshrs" or ".shrs" or ".profile" or what? And, if you can give me an ultimate answer to my question, where exactly is this file located on the system?

I have been a computer science student at uni for 3 years now, but nothing has ever caused me so much trouble. Such an easy task, but so hard to do, so many possible combinations!! Why??

Can anybody tell me how to do it?
  #2 (permalink)  
Old 05-21-2006
jsandova's Avatar
jsandova jsandova is offline
Registered User
  
 

Join Date: May 2006
Location: Burbank Ca
Posts: 28
Well if you are using a sh/bash/ksh shell then do the following:
cd <enter>

ls -lrta <enter>

vi .profile

Look for the following line and add the path you want after the :
PATH=$PATH:$HOME/bin:/var/juno/bin:/usr/sbin/ifconfig:

After you save and exit out of your .profile then do the following so you changes can take effect:

source .profile <enter>
  #3 (permalink)  
Old 05-22-2006
amit.verma amit.verma is offline
Registered User
  
 

Join Date: May 2006
Posts: 8
or use
export PATH=$PATH:<your additions seperated with colons>:

on command line and will be valid for the session only
  #4 (permalink)  
Old 05-22-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
About UNIX shell differences and overview pls read THIS And about .profile, .login files, these files are located in user's home directory, which is most probably /home/username, list the contents of user's home directry with ls -a and you can see these files there. And which file to modify, its very simple not so complex, check the login shell of user with command:
Code:
cat /etc/passwd | grep username
admin:x:101:1:Tayyab:/home/username:/usr/bin/ksh
Last field tells you the login shell of the user, in case of ksh, bash or sh you have to modify .profile to set the path and in case of csh it is .login.

Hope it helps!

Best Regards,
Tayyab

Last edited by tayyabq8; 05-22-2006 at 07:50 AM..
  #5 (permalink)  
Old 05-23-2006
yarx yarx is offline
Registered User
  
 

Join Date: May 2005
Posts: 37
Quote:
Originally Posted by shereenmotor
About UNIX shell differences and overview pls read THIS And about .profile, .login files, these files are located in user's home directory, which is most probably /home/username, list the contents of user's home directry with ls -a and you can see these files there. And which file to modify, its very simple not so complex, check the login shell of user with command:
Code:
cat /etc/passwd | grep username
admin:x:101:1:Tayyab:/home/username:/usr/bin/ksh
Last field tells you the login shell of the user, in case of ksh, bash or sh you have to modify .profile to set the path and in case of csh it is .login.

Hope it helps!

Best Regards,
Tayyab

If you want to know which Shell use now ,you can enter : echo $SHELL

then modfiy this shell's configure file(.bashrc,.cshrc....) and soruce(.) it !
  #6 (permalink)  
Old 05-24-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
"which" searches the directories in your PATH for the mysql command and reports:
Code:
 
no mysql in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /Users/timo/usr/local/ /usr/local/bin
but your command line was
Code:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
Try adding the directories from your command line that aren't currently in your path (/usr/local/sbin:/usr/local/mysql/bin) to the path in your .profile. Log out and back in - you can check the actual value of your path using the command "echo $PATH".

hope this helps
  #7 (permalink)  
Old 05-22-2006
PixelLover PixelLover is offline
Registered User
  
 

Join Date: May 2006
Location: Hamburg, Germany
Posts: 8
Quote:
Originally Posted by jsandova
Well if you are using a sh/bash/ksh shell then do the following:
cd <enter>

ls -lrta <enter>

vi .profile

Look for the following line and add the path you want after the :
PATH=$PATH:$HOME/bin:/var/juno/bin:/usr/sbin/ifconfig:

After you save and exit out of your .profile then do the following so you changes can take effect:

source .profile <enter>
OK, thanks. I did what you said, but still MySQL can't be found. My .profile now looks exactly like this:

PATH=$PATH:$HOME/usr/local/

But when I type "which mysql" <enter>

I still get this:

no mysql in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /Users/timo/usr/local/ /usr/local/bin

Can it be that there are different files setting my path? I can't really see a connection between the path I set and the error message I get.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0