10

I'm just trying to follow this tutorial and set up my environment. My system is WSL Ubuntu 18.04. Here is already an answer on my question, but I as an absolute novice in Linux/UNIX don't know which variant presented there more suitable for my goal. Do I need to add this string

export PATH="$PATH:/path/to/dir"

into my ~/.profile or ~/.bashrc file?

Or may I need to accomplish the second step from the answer?

cd /usr/bin
sudo ln -s /path/to/binary binary-name

And then run these commands?

source ~/.profile 
or
source ~/.bashrc
2
  • Add it to your .bashrc – j-money Jan 29 '19 at 13:20
  • The .bashrc file should be fine! – George Udosen Jan 29 '19 at 13:21
10

If you make a ~/bin folder in your home folder, it'll already be in your default path. No need to modify anything, or add folders to a hidden .local folder. Create the ~/bin folder, log out, log back in, and open a terminal window, and you can confirm the path by typing echo $PATH.

Update #1:

If you decide to use ~/.local/bin anyway, add this to the end of your ~/.profile...

# set PATH so it includes user's private ~/.local/bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

Then log out, log back in, and your new path will be available.

12
  • According the tutorial (link in my question) next command python -m site --user-base should output ~/.local/bin But now only ~/.local This command - export PYTHONUSERBASE=/myappenv solve the problem, but only till reload. – Alex Stelmakh Jan 29 '19 at 16:38
  • @AlexStelmakh that tutorial, and extra link, is TL;DR, but is mostly for linux and Mac. I'd follow something else as a learning guide. – heynnema Jan 29 '19 at 16:52
  • What is TL;DR? I need a guide for Ubuntu 18.04 – Alex Stelmakh Jan 29 '19 at 17:08
  • @AlexStelmakh Too Long;Didn't Read. See help.ubuntu.com for help guides on Ubuntu. – heynnema Jan 29 '19 at 19:33
  • ~/.local (with ~ expanded to the absolute path to your home directory) so you’ll need to add ~/.local/bin to your PATH. You can set your PATH permanently by modifying ~/.profile. I'm trying to follow these instructions. And accordingly it is not as simple as adding /bin in my home directory. – Alex Stelmakh Jan 30 '19 at 18:37
3

The PATH variable gets changed when this shell command is executed:

export PATH=$PATH:/your/new/path

The ~/.bashrc and ~/.profile will be executed automatically when you open a bash session (normally when you open a new terminal window/tab).

So if you want to change the PATH in current shell session only, you could just type export PATH=xxx and execute it once. But if you want to make it difference permanently, you should add the command above into ~/.bashrc or ~/.profile.

2
  • Should be the second part of the command enclosed in quotes? Like this one. export PATH="$PATH:/home/maverick/.local/bin" As this (tinyurl.com/y86jc2pp) answer suggests it should be enclosed. I entered the command above, but PATH still the same. I proved this by next command: python -m site --user-base And the result's as follows: /home/maverick/.local – Alex Stelmakh Jan 29 '19 at 14:57
  • @AlexStelmakh python -m site --user-base just tell you where the pip packages are installed at. You can view the PATH in the current bash session by the command echo $PATH. – Balthild Ires Jan 29 '19 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.