Environment variables are of great importance when you are building software applications based on the Ubuntu Operating system. They are used to store details about the environment in which the program or a script runs.
Types of Environment Variables:
- System-Wide Environment Variables: These environment variables apply to the entire operating system and affect all users.
- User-Specific Environment Variables: These environment variables are specific to individual user accounts and not the whole system.
- Temporary Environment Variables: These are only in effect for the duration of the current session, once the session is closed or the Terminal is exited, these settings will be lost.
- Permanent Environment Variables: These environment variables persist across sessions and reboots, even when the session is closed or the Terminal is exited, these settings will not be lost..
Examples of Setting Environment Variables
- System-Wide Temporary Environment Variables: We make use of the export command to set temporary variables.
Example:export DEV_SERVER_URL="https://192.167.8.2:8000"
- System-Wide Permanent Environment Variables: We will to add the environemnt avriable to /etc/environment file to make it parmanent.
Example:nano /etc/environment
Add the environment variable and save and exit.
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
- User-Specific Temporary Variable: We make use the export command.
Example:export EDITOR=nano
- User-Specific Permanent Variable: We add to the PATH variable under ~/.bashrc or ~/.zshrc
Example:export PATH="$PATH:/home/user/bin"
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Ubuntu,
- Fix - sudo: systemctl: command not found
- How to know the version of Ubuntu
- [Fix] Ubuntu E: Unable to locate package sudo error
- How to install Apache Maven on Ubuntu
- Steps to Kill a Running Process in Ubuntu Linux
- How to know current Ubuntu Linux version via terminal command
- How to stop/start/restart apache server using command [Ubuntu]
- Fix: Ubuntu (Linux) - bash: sudo: command not found error
- Ubuntu: How to search for a package to install using apt in Terminal
- Fix: E: Command line option --installed is not understood in combination with the other options
- How to install Python on Ubuntu
- Ubuntu Linux: How to Login as root User
- Access Windows share folder in Ubuntu Device in Network
- Add a User as a Sudoer Using Ubuntu Linux Command Line Terminal
- Install Oh My Zsh on Ubuntu Docker complete steps
- Fix: Make makefile:31 Error 127 (GCC)
- [fix] openssl No such file or directory error C++
- How to install zsh shell on Ubuntu
- Install Golang (Go) on Ubuntu
- Ubuntu Linux: Unzip a zip file using Terminal
- Where are Environment Variables stored in Ubuntu
- apt-get list --installed packages in Ubuntu Linux
- Ubuntu: List all Installed Packages using apt
- Quick steps to install Nginx on Ubuntu Linux
- How to kill service running on a port on Ubuntu Linux
More Posts:
- Display Seconds in Digital Clock on Mac Menu Bar [macOS] - MacOS
- Meaning of javascript:void(0) explained with example - JavaScript
- How to change the font in TextEdit on Mac - MacOS
- How to Disable Trackpad on MacBook - MacOS
- How to Enable Remote Management using Mac Terminal - MacOS
- Remove AirDrop Icon from macOS Menu Bar - MacOS
- Microsoft Office Mac Ventura: System Settings must be changed before Microsoft AutoUpdate can run - Microsoft
- Get Word Count in TextEdit - MacOS