Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# The PATH variable
The PATH environment variable (variable available by all shells) is very important, it specifies the directories to be searched to find a command absent from bash itself.
When calling a tool, Bash will first look among commands shipped with him, then look at your current directory, and finally will look in order in all directories listed un the PATH variable.
It is how your computer access tools. There is no magic. The computer is just following some simple rules. If you call a tool unknown by Bash and not part of any path listed in $PATH, there is no way for your computer to guess where it is and will tell you `command not found`.
The only solution is to fill the full path to the tool you want to use (You must know where it is standing then).
You can list the folder in which your bash is always looking at when trying to execute a command via:
```bash
echo $PATH
```
The paths are listed using the `:` separator.
!!! Exercise
* run the following command:
```
python3 --version
```
What happens?
??? example "Click to show the solution"
We call python3 to see its version. We get an answer from python.
* Using the `which` command you will ask where is located the python3 executable.
```
which python3
```
Is that path part of $PATH?
??? example "Click to show the solution"
yes
!!! Success "Quick recap"
In this section we've learned:
- the PATH variable
- the logic how a command or a tool is found on the computer