Mụta otu esi edobe mgbanwe PATH gị na-adịgide adịgide na Linux


Na Linux (nakwa UNIX) PATH bụ mgbanwe gburugburu, a na-eji agwa shei ebe a ga-achọ faịlụ ndị enwere ike ime ya. Ngbanwe PATH na-enye nnukwu mgbanwe na nchekwa na sistemụ Linux yana ọ dị mma ịsị na ọ bụ otu n'ime mgbanwe gburugburu ebe dị mkpa.

Mmemme/ederede dị n'ime akwụkwọ ndekọ aha PATH, enwere ike igbu ya ozugbo na shei gị, na-akọwapụtaghị ụzọ zuru oke maka ha. N'ime nkuzi a, ị ga-amụta otu esi edobe mgbanwe PATH n'ụwa niile na mpaghara.

Nke mbụ, ka anyị hụ uru PATH gị ugbu a. Mepee ọnụ ma nye iwu a:

$ echo $PATH

Nsonaazụ kwesịrị ịbụ ihe dị ka nke a:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Nsonaazụ na-egosi ndepụta ndekọ aha ndị colons kewapụrụ. Ị nwere ike ịgbakwunye akwụkwọ ndekọ aha n'ụzọ dị mfe site na-edezi faịlụ profaịlụ shei onye ọrụ gị.

N'ime shells dị iche iche nke a nwere ike ịbụ:

  1. Bash shell -> ~/.bash_profile, ~/.bashrc ma ọ bụ profaịlụ
  2. Korn Shell -> ~/.kshrc ma ọ bụ .profile
  3. Z shei -> ~/.zshrc  ma ọ bụ .zprofile

Biko mara na dabere na otu i si abanye na sistemụ a na-ajụ, enwere ike ịgụ faịlụ dị iche iche. Nke a bụ ihe akwụkwọ ntuziaka bash na-ekwu, buru n'uche na faịlụ ndị ahụ yiri shells ndị ọzọ:

/bin/bash
The bash executable
/etc/profile
The systemwide initialization file, executed for login shells
~/.bash_profile
The personal initialization file, executed for login shells
~/.bashrc
The individual per-interactive-shell startup file
~/.bash_logout
The individual login shell cleanup file, executed when a login shell exits
~/.inputrc
Individual readline initialization file|

N'ịtụle ihe ndị a dị n'elu, ị nwere ike itinyekwu akwụkwọ ndekọ aha na mgbanwe PATH site n'ịgbakwunye ahịrị na-esonụ na faịlụ dabara adaba nke ị ga-eji:

$ export PATH=$PATH:/path/to/newdir

N'ezie na ihe atụ dị n'elu, ị kwesịrị ịgbanwe/ụzọ/na/newdir na kpọmkwem ụzọ na ị chọrọ ịtọ. Ozugbo ịmechara faịlụ .*rc ma ọ bụ .*_profile gị, ị ga-achọ ịkpọ ya ọzọ site na iji iwu “source”.

Dịka ọmụmaatụ na bash ị nwere ike ime nke a:

$ source ~/.bashrc

N'okpuru ebe a, ị nwere ike ịhụ ihe atụ nke gburugburu PATH m na kọmputa mpaghara:

[email [TecMint]:[/home/marin] $ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/marin/bin

Nke a bụ n'ezie omume dị mma ịmepụta folda bin mpaghara maka ndị ọrụ ebe ha nwere ike idowe faịlụ ha nwere ike ịmegharị. Onye ọrụ ọ bụla ga-enwe folda dị iche iche iji chekwaa ọdịnaya ya. Nke a bụkwa ihe dị mma iji chekwaa sistemụ gị.

Ọ bụrụ na ị nwere ajụjụ ọ bụla ma ọ bụ ihe isi ike ịtọ mgbanwe gburugburu PATH gị, biko egbula oge ịnye ajụjụ gị na ngalaba nkọwa n'okpuru.