How Permanently Save Environment Variables in Linux?

How Permanently Save Environment Variables in Linux?
Contents

How do I permanently set an environment variable in Linux?

To make the change permanent, enter the command PATH=$PATH:/opt/bin into your home directory’s . bashrc file. When you do this, you’re creating a new PATH variable by appending a directory to the current PATH variable, $PATH .

How do I permanently set environment variables in Ubuntu?

1 Answer

  1. Open a terminal window with Ctrl + Alt + T .
  2. Open the file for editing with gedit ~/.profile.
  3. Add the command to the bottom of the file.
  4. Save and close gedit.
  5. Log out and log in again.
Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.