How to add environment variable assignments on Elementary OS 6.1 via the terminal emulator and the bash shell?
Environment variables
Environment variables are dynamic values that can affect the behavior of processes and programs running on a computer's operating system.
These variables store information such as system configuration settings, user preferences, or data that is used by various software applications.
Environment variables are used to control how programs behave and to provide them with necessary information.
Open the terminal
CTRL + SHIFT + T
Check your shell
echo $SHELL
My output is
/bin/bash
Your output might be one of the following:
Edit the shell configuration
Use your favorite text editor to edit the shell configuration file. I'm going to use nano
. You can use nano, vi, vim, gedit and even VS Code.
nano ~/.bashrc
Add the variables
In ~/.bashrc
, add the variables at the end:
export GITHUB_TOKEN="glpat-Z2hxZY6BhDPyZwQbYuZm"
export DOCKER_TOKEN="dckr_pat_ORhj8i17IaMZ8gvLMqZgdKnkD9Z"
export PG_USER="my_user"
export PG_PASS="d9l85nbp"
Save the changes and exit
if you are using nano, follow the order:
CTRL + X;
Y and press Enter;
Confirm the changes
source ~/.bashrc
Check the changes
echo $GITLAB_TOKEN
echo $DOCKER_TOKEN
echo $PG_USER
echo $PG_PASS
Done
Celebrate
You've made it!
Let's become friends
Final thoughts
I hope this article has been helpful to you. Please feel free to reach out if you have any questions. Your thoughts, suggestions, and corrections are more than welcome.
By the way, don't hesitate to drop your suggestions for new blog articles.
I look forward to seeing you next time.