How to add a directory to PATH in the file .bashrc? - bash

After installing python(EPDFee), I want to add the /bin directory to $PATH variable. I am use bash shell. I have found that I have to add the following line in the file .bashrc
export PATH=/home/usrname/epd/bin:$PATH
I have found the file .bashrc, it reads
PATH=$PATH:/opt/bin
# Added by Canopy installer on 2014-03-29
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /home/an/Enthought/Canopy_64bit/User/bin/activate
Could you please tell me where can I add export PATH=/home/usrname/epd/bin:$PATH to or is should be added in another file?

add the following line to your .bashrc file ...don't forget to replace your path.
export PATH="/path/directory:$PATH"
then do
source .bashrc
to let the changes make effects. I am not sure about other distributions of Linux but It will work on CentOS and RedHat.

You can do it like this :
Define a EPD_HOME var and append it to PATH
EPD_HOME=/home/usrname/epd/bin
PATH=$PATH:$EPD_HOME:$HOME/bin
export PATH
Notice that the $EPD_HOME variable is in the PATH variable and is now loaded once you open a connection to your user on the machine.

Related

Add to PATH on server

i want to add the following directory to my path on the server, and i want it to stay permanently and be allowed to be run from anyplace
this is the directory path:
/usr/local/texlive/2017/bin/x86_64-linux
i tired the following but if i exit the server and login again it is not there and if a website tried to call a function from the directory it can not see it
PATH=/usr/local/texlive/2017/bin/x86_64-linux:$PATH
what is the proper way to add this directory to my default $PATH and make this change permanent
Depends on the shell you are using on the server if bash you could edit your .profile and add something like:
export PATH="/usr/local/texlive/2017/bin/x86_64-linux:$PATH"
If you want it to be for all users you could add it to a file in /etc/profile.d/path.sh.
/etc/profile and /etc/profile.d/*.sh are the global initialization scripts that are equivalent to ~/.profile for each user.
If using zsh add it to ~/.zshrc check this answer https://stackoverflow.com/a/10583324/1135424
If using csh, you could edit the .cshrc something like this:
set path = (/usr/local/texlive/2017/bin/x86_64-linux $path)

ROS_PACKAGE_PATH issue. Need help in setting .bashrc

I have added
export ROS_PACKAGE_PATH="/home/kathir/ORB_SLAM":${ROS_PACKAGE_PATH}
in .bashrc and I am getting this error during cmake of ORB_SLAM.
ORB_SLAM cloned path : "/home/kathir/ORB_SLAM"
I have another workspace in "/home/kathir/catkin_ws/devel/setup.bash" in the .bashrc since I was using ROS for ARDRONE.
CMake Error at /opt/ros/indigo/share/ros/core/rosbuild/private.cmake:102 (message):
[rosbuild] rospack found package "ORB_SLAM" at "", but the current
directory is "/home/kathir/ORB_SLAM". You should double-check your
ROS_PACKAGE_PATH to ensure that packages are found in the correct
precedence order.
check below for further info
kathir#kathir-VirtualBox:~/ORB_SLAM/build$ source .bashrc
bash: .bashrc: No such file or directory
kathir#kathir-VirtualBox:~/ORB_SLAM/build$ $ROS_PACKAGE_PATH
bash: /opt/ros/indigo/share:/opt/ros/indigo/stacks:M$:: No such file or directory
The error you are likely seeing is because of your exported variables not taking effect in your current shell. You need it to source it in the current shell for it to take effect,
source ~/.bashrc
or more simply just
. ~/.bashrc
which imports all the new environment variables to the existing session. You don't have do this for subsequent sessions, as this will be sourced for every new session opened upon startup.
source ~/.bashrc should be used to make the package path effective
if you have add the path and write it to the .bashrc, you can:
run the script: source ~/.bashrc as said by the other answer;
or reopen the terminate, next everytime you open terminal, the script will run automatically

How to set up packer PATH on Mac Unix

The documentation of packer says: Packer Setup Documentation
on how to set the PATH : How to permanently set PATH in Unix
And I did add :
export PATH=$PATH:~/packer/
in my ~/.zshrc file
however, when I go to type packer on the terminal first time, the dir changes to be ~/packer and when I type packer again I get :
~ packer
➜ packer packer
zsh: command not found: packer
Does anyone have a better clue on how to set up packer's PATH on a Macintosh Unix system?
In OS X you would typically have any exports set in:
~/.bash_profile
If you already have a .bash_profile setup then it will override .profile. Since you're using zsh you might try putting the export in ~/.zprofile.
Please try adding your edits to the ~/.profile file instead of ~/.bashrc file.
To make the new path stick permanently you need to create a .bash_profile file in your home directory and set the path there.
Open terminal on Mac and write nano .bash_profile.
Create the .bash_profile file with a command line editor called nano,If it is already exists then it will open a text editor containing path.
Add the path you require like:
export PATH="/usr/local/node/bin:$PATH"
Save the file in nano by clicking Ctrl+O and confirming the name of the file as .bash_profile by hitting enter. And the Ctrl+X to exit nano.
Then for checking path is set or not just write echo $PATH in terminal. Your path would be there in it.

How do I change the order of $PATH?

echo $PATH gives me
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
but when I want to change the order of /usr/local/bin to the front of /Library/Frameworks/Python.framework/Versions/3.4/bin, I type
sudo emacs /etc/paths
I only get
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
How can I insert /usr/local/bin in front of my PATH?
You can set your PATH in the file .bash_profile, which is in your home directory.
More specifically, you can simply add the following line to the end of that file
export PATH=/usr/local/bin:$PATH
This results in /usr/local/bin being prepended to the existing PATH. In other words, the folder /usr/local/bin is inserted in front of your PATH, and so it would have the highest priority. You can also append a folder to your path by doing
export PATH=$PATH:/usr/local/bin
In general, you can set the order of the folders or files that you export in a similar way as the following:
export PATH=/usr/local/bin:/Applications/Sublime Text 2.app/Contents/SharedSupport/bin:/Users/pathreskoo/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
Note: this is not the only place you can set the PATH, but it is a common one.
Your $PATH normally overridden by the initiation part of your shell. Normally follows the system-wide profile (/etc/profile), then user-side profile (if you use bash .profile, .bash_profile, .bashrc) and any source command in these files. The overridden command mainly in .bashrc
Edit you .bashrc file and find $PATH, you may find the export command and delete the path you do not want. export $PATH=/usr/local/bin:$PATH override the command user-wide.

How to remove entry from $PATH on mac

I was trying to install Sencha Touch SDK tools 2.0.0 but could not run it properly. It created an entry in the $PATH variable.
Later I deleted the sencha sdk tools folder but didn't realize that the path variable is still there.
When i did echo $PATH I got -
/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
I searched on how to remove variables from $PATH and followed these steps :
Gave the command PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
Did echo $PATH which showed /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
gave the command export PATH
Closed terminal and reopened it. Gave the command echo $PATH. This time I got
/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Can anyone tell me what am i doing wrong?
echo $PATH and copy it's value
export PATH=""
export PATH="/path/you/want/to/keep"
Check the following files:
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
Some of these files may not exist, but they're the most likely ones to contain $PATH definitions.
On MAC OS X Leopard and higher
cd /etc/paths.d
There may be a text file in the above directory that contains the path you are trying to remove.
vim textfile //check and see what is in it when you are done looking type :q
//:q just quits, no saves
If its the one you want to remove do this
rm textfile //remove it, delete it
Here is a link to a site that has more info on it, even though it illustrates 'adding' the path. However, you may gain some insight.
What you're doing is valid for the current session (limited to the terminal that you're working in). You need to persist those changes. Consider adding commands in steps 1-3 above to your ${HOME}/.bashrc.
If you're removing the path for Python 3 specifically, I found it in ~/.zprofile and ~/.zshrc.
$PATH contains data that is referenced from actual files. Ergo, you should find the file containing the reference you want to delete, and then delete said reference.
Here is a good list to run through progressively [copied from #Ansgar's answer with minor updates].
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
/etc/paths
/etc/paths.d/
Note that /etc/paths.d/ is a directory that contains files with path references. For example, inside this directory may be a file called, say, fancy-app, and inside this file you'll see an entry like below:
/path/to/fancy-app
This path will appear in your $PATH and you can delete the entry in the file to remove it, or you can delete the file if it has only the one reference you want to remove.
Use sudo pico /etc/paths inside the terminal window and change the entries to the one you want to remove, then open a new terminal session.
when you login, or start a bash shell, environment variables are loaded/configured according to .bashrc, or .bash_profile. Whatever export you are doing, it's valid only for current session. so export PATH=/Applications/SenchaSDKTools-2.0.0-beta3:$PATH this command is getting executed each time you are opening a shell, you can override it, but again that's for the current session only. edit the .bashrc file to suite your need. If it's saying permission denied, perhaps the file is write-protected, a link to some other file (many organisations keep a master .bashrc file and gives each user a link of it to their home dir, you can copy the file instead of link and the start adding content to it)
Close the terminal(End the current session). Open it again.
If the manual export $PATH method does not seem to be working after you close the terminal and open again, definitely check the shell configuration files.
I found a small script that kept adding some more path in front of the $PATH everytime it was open.
For zsh you can check the ~/.zshrc file.

Resources