Skip to content

Commit 4311f0f

Browse files
authored
Create path.md
1 parent 5ab8c3d commit 4311f0f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

linux/path.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Set `$PATH` variable in Ubuntu
2+
3+
The `$PATH` variable is one of the default environment variable in linux (ubuntu). It is used by the shell to look for executable files or commands.
4+
5+
One way to permanently add a directory to `$PATH` environment variable is to use the `~/.profile` file. Add the following to the `~/.profile` file to add `myNewDir` to `$PATH`
6+
7+
```
8+
$ export PATH=$PATH:/myNewDir
9+
$ source ~/.profile
10+
```
11+
12+
## The `source` command
13+
14+
`source` is a bash shell built-in command that executes the content of the file passed as argument, **in the current shell**. It has a synonym in `.` (period).
15+
16+
Note that `./` and `source` are not quite the same:
17+
18+
- `./script` runs the script as an executable file, launching a new shell to run it
19+
- `source some_script` reads and executes commands from filename in the current shell environment
20+
- `source some_script` is the same as `. some_script`

0 commit comments

Comments
 (0)