Cum se afișează, adăugați și să eliminați variabilele de mediu în Fedora Linux

Variabilele de mediu sunt stabilite pentru a fi utilizate de către programe.

Sistemul de variabile definite sunt stabilite de către sistem. Un exemplu este PWD care deține directorul de lucru curent.

Variabilele definite de utilizator sunt definite de către utilizator, fie temporar(pentru shell curentă) sau permanent.

Variabilele de mediu locale sunt stabilite pentru sesiunea curentă.

User environment variables are defined for the user and is used every time the user logs in. These variables are set in the files found in the user’s home directory:

  • .bashrcLoaded when new terminal is opened
  • .bash_profileLoaded when user logs in remotely. If not present .bash_login or .profile is used
  • .bash_login
  • .profile

System wide environment variables are available system wide (for all users). Defined in following directories and files:

  • /etc/environmentSystem wide environment variable file
  • /etc/profileLike environment but for remote logins
  • /etc/profile.d
  • /etc/bash.bashrc

List current environment variables

env

Remove local environment variable

unset {var_name}

Add local environment variable

export VAR_NAME=myvar/new

The above will only be available during the session and will be cleared out when the session has ended.

To create a user environment variable edit the .bashrc file and add the export VAR_NAME=myvar/new command to the file. Save the file and use source .bashrc command to activate the changes.

To create a system environment variable edit the /etc/environment file and add the export VAR_NAME=myvar/new command to the file. Save the file and use source /etc/environment command to activate the changes.

 

 

 

lasa un raspuns