Managing Environment Variables in Linux

 


Introduction

Environment variables store configuration values that affect how processes and shells behave. They are widely used to set paths, define user preferences, and configure applications.


Step 1: View All Environment Variables


printenv


➡️ Lists all current environment variables.


Step 2: View a Specific Variable


echo $HOME


➡️ Prints the value of the HOME variable.


Step 3: Set a Temporary Environment Variable


export MYVAR="Hello Linux"


➡️ Available until you close the terminal.


Step 4: Make Environment Variables Permanent

Add them to ~/.bashrc or ~/.profile:


export PATH=$PATH:/new/path


➡️ Reload the file:


source ~/.bashrc


Step 5: Unset an Environment Variable


unset MYVAR


Conclusion

Environment variables are key for customizing and configuring Linux systems. Next, we’ll explore disk partitioning tools like fdisk and lsblk.

Comments