How Do You Make an Environmental Variable Persist through a Reboot on a Linux server?

Problem scenario
Every time a server is rebooted, you have to manually set environment variables with the "export" command. You want a variable to persist through a reboot so you do not have to do this manual work. You want a variable to be in the environment of the OS every time you log in. You want the solution to be specific to one user but you want it to work for any distribution of Linux (a Debian or Red Hat derivative including SUSE, CentOS/RHEL/Fedora, and Ubuntu). How do you get a variable to be in the environment of a Linux OS for your user every time you log in?


  1. Modify the .bashrc file in your home directory: vi ~/.bashrc
  2. At the very end of the file add a new line. Place the "export …" command without the initial "export " (export and space). Here is an example:
  3. The above is specific was one user. If you want every user to get this variable, see this link titled How Do You Set an Environment Variable for Every User Upon Rebooting a Linux Server?.

Leave a comment

Your email address will not be published. Required fields are marked *