Linux and NS2
NS2 runs on both Windows and Linux. But, it runs best on Linux. If you are a windows user, I suggest you to run NS2 over Cygwin, a Linux emulator. Instruction for installing NS2 is available [ here ].
Initializing Linux Shell
As a Linux or Cygwin (Linux emulation for Windows) new, would you wonder what really happen when you execute the shell (e.g., double click on the Cygwin icon)? In the old day, Windows always invokes a file called “autoexec.bat”. This file contains a bunch of things Windows will do at the boot-up such as setting path or invoke other programs (e.g., anti-virus).
Hidden under your home directory (which should look like /home/youname), there are two Linux initialization files, namely “.bash_profile” and “.bashrc”. If you want to see it, type “ls -a”.
When you open a shell, they are automatically executed as a shell initialization.The path setting is contained in these files.
These two files are created when you first run Linux or Cygwin Environment. So you won’t see it if you browsing the directory using window explorer but have not run Cygwin.
Differences?
“.bash_profile” is invoked for a log-in session. Log-in? Yeah, log-in. It is invoked every time you provide user name/password. It includes both local login and remote login (e.g., ssh).
“.bashrc” is invoked for a non-log-in session. For example, when you have already log-in to a graphical environment such as KDE. All you have to do is to click on a terminal icon and you don’t have to provide username/password to open a shell.
How To Configure the Files
In fact, you can see in the file “.bash_profile” the following
if [ -f ~/.bashrc ]; then source ~/.bashrc fi
which basically executes “.bashrc” if it exists.
Adding Your Own Initialization Codes
For the Cygwin environment, you can add your own initialization in either “.bashrc” or “.bash_profile”.
Wanna try? Add the following lines into the files and restart the shell.
- Add to “.bashrc”
echo “Add2.bashrc”
- Add to “.bash_profile”
echo Add2.bash_profile
Example: Adding a certain directory to the PATH variable
Suppose you would like to add a directory /home/yourName/yourDir to the PATH variable. You can add the following line to the file “.bashrc”
$PATH=$PATH:/home/yourName/yourDir
After adding, save the file and restart the shell. Then, type following to see whether the modification takes effect:
echo $PATH
The directory /home/yourName/yourDir should appear at the end of the $PATH variable.
———————————————————————-
Source: Josh Staiger