How to Set Permanent Environment Variables in Linux

Linux Servers
Environment variables in Linux make things easy to navigate with and execute from. Most Linux systems come preset with a few variables, including a $PATH, which tells the system where to look for programs. This article will show you the steps to use to set variables that last with each log in.
 
1. Log into your system using SSH.
 
2. Open .bash_profile with your favorite editor. We use nano in our office, but you can use emacs or vim if you prefer those over nano.
 
nano ./.bash_profile
 
 
3. Add your variables and their corresponding export statements at the bottom of the file.
PLESK=/usr/local/psa/bin
WEBROOT=/var/www/vhosts

export PLESK
export WEBROOT
4. Log out and back in again. You can test your variables by changing the directory. Please note that all variables start with a dollar sign ($)
cd $WEBROOT

$PLESK/admin --show-password
Please note: The above is case-sensitive 

Add Feedback