How to add a variable to the "path"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to add a variable to the "path"
# 1  
Old 05-21-2006
Data 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  
Old 05-21-2006
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  
Old 05-22-2006
or use
export PATH=$PATH:<your additions seperated with colons>:

on command line and will be valid for the session only
# 4  
Old 05-22-2006
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  
Old 05-22-2006
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. Smilie
# 6  
Old 05-22-2006
By the way:

If I enter the following command directly into the shell, everything works fine and I can connect to the MySQL database simply by typing "mysql":

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

But how can I add this to the path...??? I'm really a dummie, aren't I... Smilie
# 7  
Old 05-23-2006
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 !
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find files in sub dir with tag & add "." at the beginning [tag -f "Note" . | xargs -0 {} mv {} .{}]

I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
Discussion started by: Nexeu
6 Replies

2. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

3. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

4. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

5. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

6. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Advanced & Expert Users

add seconds to: date"|"time"|"HHMMSS

Hey all, I have a shell that invokes a AWK. In this AWK i want invoke a function that receives 3 parameters: date: 20080831 time: 235901 duration: 00023 that function receive this 3 parameters and sum to this value two more seconds: 2008083123590100025 Remember that in case that... (3 Replies)
Discussion started by: anaconga
3 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question