-1

Going through this tutorial, I had to execute the command export PATH=~/.local/bin:$PATH

It explained with

This command inserts the path, ~/.local/bin in this example, at the front of the existing PATH variable.

However, I still don't understand what exactly is happening there. What is the goal/effect of that command?

Joey Coder
  • 3,199
  • 8
  • 28
  • 60
  • 1
    https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path – basilisk Jul 27 '19 at 14:09
  • 2
    Possible duplicate of [How to permanently set $PATH on Linux/Unix?](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix) – basilisk Jul 27 '19 at 14:09

1 Answers1

0

This command prepend the folder ~/.local/bin (~ is your home folder) to your global variable $PATH (echo $PATH too see it).

Thanks to that, you'll be able to execute program/script stored in the folder ~/.local/bin without typing the full path.

Example, if you have a script myScript.sh in your folder, before adding ~/.local/bin to your $PATH, you can run it with the command:

~/.local/bin/myScript.sh

After adding ~/.local/bin to your $PATH, you can execute it with the command:

myScript.sh
Dorian
  • 761
  • 3
  • 11
  • 28
  • Now it makes sense! Great explanation. Thank you, Dorian. – Joey Coder Jul 27 '19 at 14:31
  • What does that mean @EdMorton? – Joey Coder Jul 27 '19 at 21:03
  • 1
    @EdMorton it’s fixed. Thanks you. Joey: it means that the shell will scan the folder ~/.local/bin before others directories in your PATH. It’s important if you have multiple command with the same name, the shell will execute the first found. – Dorian Jul 28 '19 at 05:43