70

I just installed picc-9.82.9453-linux.run from Microchip website, and at the end it asked me

==> NOTE: You may wish to add the following  
   /usr/hitech/picc/9.82/bin  
   to your PATH environment variable.  

What does it mean?

I also need to add this to the environment path:

/usr/hitech/picc-18/pro/9.66/bin  
4
  • 3
    PATH is a global operating system variable that contains names of files that are to be executed without specyfing the whole path to them. For example You can just write startx to start graphic environemnt instead of /bin/some other folders/startx
    – Misery
    May 24, 2012 at 15:56
  • After editing .profile restart your system to get the changes to take effect. (Perhaps there is a way around this, but restarting certainly works)
    – thn
    May 30, 2013 at 8:42
  • 2
    Run . ~/.profile for changes to take immediate effect
    – beam022
    Sep 16, 2015 at 11:48

4 Answers 4

96

Partial duplicate: How to add a directory to the PATH?

PATH is an enviroment variable. It basically tells your machine where to search for programs, so when you run your picc program you can just do this:

picc

instead of

/usr/hitech/picc/9.82/bin/picc

To add a directory to your $PATH, follow either one of the options below.

Method 1

Edit ~/.profile:

gedit ~/.profile

find the following line:

PATH="$HOME/bin:$PATH"

and change it to:

PATH="$HOME/bin:$PATH:/usr/hitech/picc/9.82/bin"

Method 2

Run the command below in the terminal:

export PATH=$PATH:/usr/hitech/picc/9.82/bin
7
  • 2
    i do not clearly understand what do i edited /etc/profile but the link in your answer says something like this if [ -d "$HOME/bin" ] ; then PATH="$PATH:$HOME/bin" fi what do do with this?
    – ths
    May 24, 2012 at 16:09
  • 1
    There you go. I updated the answer.
    – reverendj1
    May 24, 2012 at 16:18
  • what to do if i need to add more than 1 path?
    – ths
    May 24, 2012 at 16:32
  • 9
    Just keep adding a colon, then your new path to that string. i.e. PATH="$HOME/bin:$PATH:/usr/hitech/picc/9.82/bin:/my/new/path"
    – reverendj1
    May 24, 2012 at 16:37
  • What if there is no ~/.profile file there? Apr 26, 2017 at 8:38
18

Shell environment variables are used for several purposes, from storing data, storing software configurations, set terminal settings, and changing shell environment. The environment variables are normally set at boot time, or by different software as required. One way of setting environmental variables is from the command line.

List all variables on terminal

env

this will print all the variable that you have

Show one variable at a time

The amount of these variables can become a very long list and locating one specific variable can become a tough task. Fortunately Linux allows us to display the value of one shell variable by using the echo command along with the name of the variable. This makes the task very easy. example: echo "$HOME"

Add or change a variable

To add or modify an environment variable, we can use the export command followed by the name of the variable and the values that go with it.

export NameofVariable='value'

Note, however, that this will only work for the current shell session. It won't be available in any other terminals.

1
  • 2
    Hi there, great first answer! Oh, and welcome to Ask Ubuntu!
    – grooveplex
    Jul 4, 2016 at 13:31
3
vi(m) ~/.profile
PATH="$HOME/bin:$HOME/.local/bin:{whatever_path_you_need_to_add}:$PATH"

If you don't have .profile file... this will also create one:

In that scenario add this also-

if [ -n "$BASH_VERSION" ]; then
   # include .bashrc if it exists
   if [ -f "$HOME/.bashrc" ]; then
      . "$HOME/.bashrc"
   fi
fi

# set PATH so it includes user's private bin directories

PATH="$HOME/bin:$HOME/.local/bin:/usr/bin:$PATH"
1

Add the environment variable in ~/.bashrc and log out, then log in and everything is working fine.

Step by step:

  1. sudo nano ~/.bashrc.
  2. add this export PATH=$PATH:/usr/local/go/bin to the end of the file.
  3. source ~/.bashrc, and everything works!

Note: To ensure the go working properly, open terminal and type go version then you will see the go help.

Hope it helps!

2
  • 1
    Instead of steps 3 and 4, you can just use source ~/.bashrc.
    – MikaelF
    Jan 29, 2020 at 4:43
  • Thanks, @MikaelF. I edited the answer. Jan 30, 2020 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .