Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a path to the .bashrc file?

At the moment I am trying to add a path for ns-2 to my .bashrc file, I have installed the ns-allinone-2.34 but the command ns gives the result: command not found when entered into the shell.

Here is what my .bashrc file currently looks like, I edited it using gedit:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


# User specific aliases and functions
export PATH=/home/michael/ns-allinone-2.34/bin/ns:/home/michael/ns-allinone-2.34/bin/nam:$PATH

Can someone please explain why this isn't working or what a possible solution may be? I am using fedora 17.

like image 251
user1825241 Avatar asked Nov 29 '12 17:11

user1825241


People also ask

What is the PATH of .bashrc file?

In most cases, the bashrc is a hidden file that lives in your home directory, its path is ~/. bashrc or {USER}/. bashrc with {USER} being the login currently in use.

How do I add file PATH to PATH?

To add a path to the PATH environment variableIn the System dialog box, click Advanced system settings. On the Advanced tab of the System Properties dialog box, click Environment Variables. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.

How do I permanently add a PATH in Linux?

Permanently add a directory to $PATHbashrc file of the user you want to change. Use nano or your favorite text editor to open the file, stored in the home directory. At the end of this file, put your new directory that you wish to permanently add to $PATH. Save your changes and exit the file.


2 Answers

Also if you export path like this, you want to keep old PATH as well, therefore include it as well.

export PATH=$PATH:/home/michael/ns-allinone-2.34/bin/
like image 189
user1830432 Avatar answered Sep 21 '22 05:09

user1830432


The PATH should contain the directory for the binaries, not the binaries themselves.

For example, in the above:

export PATH=/home/michael/ns-allinone-2.34/bin/ns:..

should actually be:

export PATH=/home/michael/ns-allinone-2.34/bin:...
like image 30
Brian Agnew Avatar answered Sep 20 '22 05:09

Brian Agnew