Cách thêm thư mục vào biến PATH trong Linux

lykimthytruc

New member
** Cách thêm các thư mục vào đường dẫn trong Linux **

Biến môi trường đường dẫn là một danh sách các thư mục mà shell tìm kiếm các tệp thực thi khi bạn nhập lệnh.Theo mặc định, biến đường dẫn bao gồm các thư mục như /bin, /usr /bin và /usr /local /bin.Điều này có nghĩa là bạn có thể nhập các lệnh `ls`,` mkdir` và `rm` mà không phải chỉ định đường dẫn đầy đủ đến các tệp thực thi.

Bạn có thể thêm các thư mục bổ sung vào biến đường dẫn để bạn có thể dễ dàng truy cập các tệp thực thi được đặt trong các thư mục đó.Ví dụ: nếu bạn có một thư mục gọi là `~/bin` chứa một số lệnh hữu ích, bạn có thể thêm nó vào biến đường dẫn để bạn có thể nhập các lệnh trong thư mục đó mà không phải nhập đường dẫn đầy đủ.

Để thêm thư mục vào biến đường dẫn, bạn có thể sử dụng lệnh sau:

`` `
Xuất đường dẫn = $ PATH: <Thư mục>
`` `

trong đó `<thư mục>` là đường dẫn đến thư mục mà bạn muốn thêm.

Ví dụ: để thêm thư mục `~/bin` vào biến đường dẫn, bạn sẽ sử dụng lệnh sau:

`` `
Xuất đường dẫn = $ PATH: ~/BIN
`` `

Khi bạn đã thêm một thư mục vào biến đường dẫn, bạn có thể bắt đầu sử dụng các lệnh trong thư mục đó mà không phải chỉ định đường dẫn đầy đủ.Ví dụ: nếu bạn có một lệnh gọi là `mycommand` trong thư mục` ~/bin`, bây giờ bạn có thể nhập lệnh sau để chạy nó:

`` `
Lệnh của tôi
`` `

** Tài nguyên bổ sung **

* [Cách đặt các biến môi trường trong Linux] (https://www.digitalocean.com/community/tutorials/how-to-set-environment-variables-in-linux)
* [Biến môi trường đường dẫn] (https://www.tldp.org/ldp/linux-filesystem-hierchy/html/sysconfig.html#path)

** hashtags **

* #linux
* #phần cuối
* #dòng lệnh
* #EnvironmentVariables
* #Con đường
=======================================
**How to Add Folders to PATH in Linux**

The PATH environment variable is a list of directories that the shell searches for executable files when you type a command. By default, the PATH variable includes directories such as /bin, /usr/bin, and /usr/local/bin. This means that you can type the commands `ls`, `mkdir`, and `rm` without having to specify the full path to the executable files.

You can add additional directories to the PATH variable so that you can easily access executable files that are located in those directories. For example, if you have a directory called `~/bin` that contains a number of useful commands, you can add it to the PATH variable so that you can type the commands in that directory without having to type the full path.

To add a directory to the PATH variable, you can use the following command:

```
export PATH=$PATH:<directory>
```

where `<directory>` is the path to the directory that you want to add.

For example, to add the directory `~/bin` to the PATH variable, you would use the following command:

```
export PATH=$PATH:~/bin
```

Once you have added a directory to the PATH variable, you can start using the commands in that directory without having to specify the full path. For example, if you have a command called `mycommand` in the directory `~/bin`, you can now type the following command to run it:

```
mycommand
```

**Additional Resources**

* [How to Set Environment Variables in Linux](https://www.digitalocean.com/community/tutorials/how-to-set-environment-variables-in-linux)
* [The PATH Environment Variable](https://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/sysconfig.html#PATH)

**Hashtags**

* #linux
* #terminal
* #commandline
* #EnvironmentVariables
* #path
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock