In Jack Wallen’s tutorial for developers, he show how easy it is to set temporary environment variables in Linux.
Did you know that you can set temporary environment variables on the Linux operating system? With these variables, you can more easily work with scripts or even systemwide programs. And for developers, setting environment variables can come in handy.
For example, you might want to set a temporary variable for the version of your distribution you use, so downloading the correct application to install is much easier. Or, maybe you want to set a URL as an environment variable to work with a script. You could set the MY_SITE variable as, say, techrepublic.com, and use the variable in a bash script. Next, you might want that variable to change, so you could reset the temporary variable to a different site, which means you don’t have to edit your script. And if you set the environment variable, it will work with any script needing to call that variable.
So, how do you set an environment variable in Linux? Let me show you.
First, log into your Linux desktop or server and open a terminal window. Let’s set MY_SITE to techrepublic.com. For that, the command would be
export MY_SITE='techrepublic.com'
You can verify the variable was set properly by issuing the command
echo $MY_SITE
and you should see techrepublic.com printed. When you need to change that variable, run the export command with a different option in place of techrepublic.com. And that’s all there is to it.
This is a great way of setting variables that can be used by any type of script or application. As always, it’s best to work smarter and not harder.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen
24World Media does not take any responsibility of the information you see on this page. The content this page contains is from independent third-party content provider. If you have any concerns regarding the content, please free to write us here: contact@24worldmedia.com
Gabriel Magalhaes to sign new Arsenal deal
Oil refinery in Russia region damaged in Ukraine drone attack: Authorities
Microsoft Security Vulnerabilities Decreased by 5% in 2023
Pre-Ozempic Obesity Drugs: Effective and Budget-Friendly
American Airlines (AAL) earnings Q1 2024
A Carefully Considered Morning Ritual That Can Brighten Your Day
Get a Lifetime Subscription of FastestVPN for just $40
Man Utd & Chelsea keeping tabs on 21yo Bundesliga star
5 things to know before the stock market opens Tuesday, April 23