Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

How to Set, List and Remove Environment Variables in Linux

by Cloudbooklet
2 years ago
in Google Cloud, Linux
How To Set List And Remove Environment Variables In Linux
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

Environment variables are key-value pair in Linux which are stored permanently or temporarily to be used by applications through shell. In this guide you are going to learn how to setup environment variables in Linux, list them and remove them. The global environment variables are stored in etc/environment. Any changes that is made in this […]

ADVERTISEMENT

Environment variables are key-value pair in Linux which are stored permanently or temporarily to be used by applications through shell.

In this guide you are going to learn how to setup environment variables in Linux, list them and remove them.

The global environment variables are stored in etc/environment. Any changes that is made in this file reflects throughout the system for all users.

ADVERTISEMENT

Set Temporary Environment Variables

Temporary variables are only available to the current shell session. The variables will get deleted once you close the terminal.

You might also like

&Quot; Systemd Service On Linux

How to Create a New systemd Service on Linux: A Step-by-Step Guide

3 months ago
List Groups In Linux

How to List Groups in Linux: A Guide for Beginners

3 months ago

You can create temporary variables using the following syntax.

KEY1=value
KEY2="value 2"
KEY3=value1:value2
  • The environment variable names should be in UPPERCASE. They are case sensitive.
  • The name and value pair should be separated by = sign without any spaces around it.
  • Multiple values can be added to a single variable which is separated using colon:.
  • The values that are having spaces should be enclosed using quotes " ".

List Environment Variables

You can list all available environment variables by simply using the following commands.

ADVERTISEMENT
env
printenv

These both commands will list all the environment variables stored in the system.

Read Environment Variables

You can read the environment variables using the printenv command and echo command.

ADVERTISEMENT

Using printenv command.

printenv HOME
Output
/home/cloudbooklet

You can also use the printenv command to read multiple variables.

ADVERTISEMENT
printenv TERM SHELL
Output
xterm-256color
/bin/bash

Using echo command.

echo $HOME
Output
/home/cloudbooklet

You can also use the echo command to read multiple variables.

ADVERTISEMENT
echo $TERM $SHELL
Output
xterm-256color /bin/bash

Delete Environment Variables

It is very simple to delete environment variables. You need to just use the unset command with the variable name to delete it.

unset variablename

This command will remove the variable permanently.

Set Permanent Environment Variables

The permanent environment variables are stored at 3 places.

  • /etc/environemnt: This file stores the variables that are globally accessible by all users throughout the system.
  • /etc/profile: Whenever a bash shell in entered the variables in this file will gets loaded. To add environment variable to this file you need to use the export command.
  • ~/.bashrc: User specific environment variables are added here.

To load the added variables in your current session you need to use the source command.

source ~/.bashrc

Prepare yourself for a role working as an Information Technology Professional with Linux operating system

Conclusion

Now you have learned how to set environment variables, list them and remove if not needed.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Tags: CentOSDebianUbuntu
Share49Tweet31SendShare
Cloudbooklet

Cloudbooklet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

Hostname In Linux

How to Modify the Hostname in Linux

3 months ago
Linux Systems

Linux systems Hacked with OpenSSH Malware

3 months ago
Install Iptables On Ubuntu

How to Install Iptables on Linux

3 months ago
Open Port In Linux

How to Open Port in Linux: Simple Step-by-Step Guide

3 months ago

Follow Us

Trending Articles

Cloud Vps Server

Top 10 Advantages of a Cloud VPS Server

September 19, 2023

Top 7 Free Dating Sites for Men in 2023

How to Block YouTube Ads on Android TV in 2023 (6 Easy Methods)

7 Best AI Girl Generators for Creating Realistic and Beautiful AI Girls

5 Best Fantasy Minecraft Servers in 2023

5 Best Laptop for Minecraft in 2023: Top Picks for All Budgets

Popular Articles

Clear Gmail Inbox

How to Clear Gmail Inbox with AI: Tips and Tricks

September 13, 2023

ImgCreator AI: Free AI Image Generator by ZMO

BlackInk AI Tattoo Generator: Create Your Own Custom Tattoos in Minutes

Top 5 AI Jewellery Generators to Create Jewellery Designs

Top 9 NSFW AI Story Writers to Try Today

NordVPN AI Gets a Major Upgrade with Nordlabs AI Integration

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.