You can change environment variables on a Linux or FreeBSD system by using the export
command in a terminal.
For example, to set the PATH
environment variable to include the /usr/local/bin
directory, you can use the following command:
export PATH=$PATH:/usr/local/bin
This will add the /usr/local/bin
directory to the PATH
variable, which specifies the directories that the system should search for executable programs.
To set a different environment variable, you can use the same syntax. For example, to set the EDITOR
variable to nano
, you can use the following command:
export EDITOR=nano
The changes made with the export
command are temporary and will only apply to the current terminal session. To make the changes permanent, you can add the export
command to the ~/.bashrc
file. This file is executed every time you start a new terminal session, and is used to set up the environment for the session.
For example, to set the PATH
variable permanently, you can add the following line to the ~/.bashrc
file:
export PATH=$PATH:/usr/local/bin
Note: The
~/.bashrc
file is specific to thebash
shell. If you are using a different shell, you will need to edit the appropriate startup file for that shell.