82

How will I make this /media/De Soft/mongodb/bin PATH variable permanent?

Everyone is saying "export PATH=$PATH:media/De\ Soft/mongodb/bin to your ~/.profile, or .bashrc, or .zshenv depending on your shell".

I don't know what is ~/.profile, or .bashrc, or .zshenv. What do they do actually?

How will I add export PATH=$PATH:my/path to my .profile/.bashrc/.zshenv?

I'm using 64 bit Ubuntu 14.04 LTS with default terminal.

Kevin Bowen
  • 20,055
  • 57
  • 82
  • 84
Towhid
  • 4,195

4 Answers4

123

They are configuration files. One way:

  • Open a terminal window using Ctrl+Alt+T
  • Run the command gedit ~/.profile
  • Add the line

    export PATH=$PATH:/media/De\ Soft/mongodb/bin

    to the bottom and save

  • Log out and log in again

Edit:

A safer way is to use quotes. Doing so is necessary if one or more directories in the original PATH contain spaces. So:

export PATH="$PATH:/media/De Soft/mongodb/bin"
15

To permanently change PATH you need to make changes to /etc/environment file. Make a backup before editing:

sudo cp /etc/environment /etc/environment.bak
sudo nano /etc/environment

sample output:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Paths are delimited by : so to add a new path say x/y/z this will how our /etc/environment looks like:

PATH="x/y/z:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
Xaqron
  • 1,292
5

Type the following in a terminal window

export PATH=/media/De\ Soft/mongodb/bin:$PATH 

Close the terminal and restart the computer. The path should include /media/De\ Soft/mongodb/bin when you type this in the terminal:

echo $PATH
0

You could also just write directly to the ~/.profile from terminal:

echo 'PATH=$PATH:/media/De\ Soft/mongodb/bin' >> ~/.profile
Niko Fohr
  • 1,571
  • 3
  • 16
  • 27