adding variables to the PATH
I have recently downloaded ns-2 network simulator and I am trying to add ns' directory to the environment variable PATH. The path of the directory that contains a link to the ns's executable file is:
/home/Myrto/ns-allinone-2.30/bin and the path of the actual executable file is: /home/Myrto/ns-allinone-2.30/ns-2.30/ns I have tried: export ns=/home/Myrto/ns-allinone-2.30/bin export $PATH=$PATH:$ns along with just about anything else that I could think of but I always get the message 'not a valid identifier'. If anyone could offer any suggestions I would be very grateful! Thanks. |
look at that code one more time.... carefully.
you're doing this: Code:
A=foo Code:
A=foo |
Code:
export PATH=$PATH:/home/Myrto/ns-allinone-2.30/bin |
Thank you very much!
|
The code voger gave you is correct. But you have to run that command each time you boot up your computer or login. Linux reads the default PATH statement from your profile or login script.
If you use the bash shell. In your home directory, you will have either profile or bash_profile. There will be something like this in either file: # Set the default system $PATH: PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:." The colons separate the folders. The period at the end of the PATH varible means you can run a program from the current directory. As an example, put the directory you want betwwen the coloons. Like this for example # Set the default system $PATH: PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/home/Myrto/ns-allinone-2.30/bin:." Save and exit. To take effect, you must log out and then log in. Or you can type source profile or source bash_profile. The source command will re-read the file. Now you can run the program anywhere from your home directory. Hope this helps you out. |
How to add variable permanently (so I don't have to export everytime I login) without altering the current path variables if my .bash_profile and.bashrc are blank?
for example i want to add this: /usr/local/arm/bin Currently I can only see the path variables using echo $PATH tnx. |
If your .bash_profile or .bashrc is blank, then you need
to edit the /etc/profile as root. Open the /etc/profile with any text editor. Search for something like this, yours may vary. # Set the default system $PATH: PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:." Each directory is separated by colons. Add the directory you want, in your case /usr/local/arm/bin within the colons. An example # Set the default system $PATH: PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/local/arm/bin:." Save and exit. To take effect, you need to logout and then login. Good luck |
Quote:
For the details on what bash(1) runs on startup/login, see the INVOCATION section of the manual (type 'man bash'). In short, ~/.bash_profile is only run on login. In almost all setups I've seen, there is a default .bash_profile that contains something like: Code:
# include .bashrc if it exists -dave |
hmm..getting more confused:confused:
oh ..1 more thing I can also look path variables using 'set'. Anyway, I'm newbie about this bash thing. I've read the INVOCATION part in bash man. actually, i want to make /usr/local/arm/bin behave like this : user (either from gui shell, login shell,any shell) can run $arm-linux-gcc while root must use #/usr/local/arm/bin/arm-linux-gcc this is a similiar behaviour like root can run #ifconfig while user must use $/sbin/ifconfig you know what I mean? Tnx. --edit-- fyi, i use slackware 11 upgraded from 10.2.If that matter.... |
All times are GMT -5. The time now is 06:10 AM. |