How to Set Environment Variables in Linux

preview_player
Показать описание
Follow this tutorial to learn how to set shell environment variables in a Linux operating system like Ubuntu.

In this tutorial, you will learn how to set environment variables in linux.
Linux based operating systems use bash shell. The shell environment variables are used for several purposes, from storing data, storing software configurations, set terminal settings, and changing shell environment. The environment variables are normally created by the operating system during installation, or by different software as per the required need. Apart from that, in linux, to set environment variables, we first need to access the terminal application. That's because the user has the privilege to add, edit, and remove different variables at will.

Step # 1 -- All variables on terminal

In linux, to set environment variables we first need to access shell environment variables.
For that, we will need to open the terminal by searching for it in the applications menu, or selecting it from the dock on the left.
Once the terminal is opened up, to check for all environment variables, type the set command and press enter. This will list all the environment variables stored in the shell.

Step # 2 -- One variable at a time

The amount of these variables can become a very long list and locating one specific variable can become a tough task. Fortunately Linux allows us to display the value of one shell variable by using the echo command along with the name of the variable. This makes the task very easy.

Step # 3 -- Changing a variable

Now, to add or modify an environment variable, we can use the export command followed by the name of the variable and the values that go with it.

Multiple values for a variable need to be separated by a colon. The colon indicates to the operating system that one value has ended and another has begun. The variables can be created and removed from the shell easily, and can be done whenever required. But changing important variables may mess with the operating system's functionalities so it's important to be careful.
And that's basically all you need to know for how to set environment variables in Linux.
Рекомендации по теме
Комментарии
Автор

Jesus... That's what I call straight-forward. Thank you, man

GustavoCosta-jrmh
Автор

Straight to the point but still descriptive, Thank You!

TeganBurns
Автор

The good tutorial: fast, clear and working perfectly. I wish all the tutorial were like this.

kristupasantanavicius
Автор

I liked this tutorial just based on length. Exactly what I needed so kept the like and subscribed too after watching.

andreasaa
Автор

This was a life saver for me! Thanks a ton.

rudrapratapkhemka
Автор

Bro you really helped me! I was having problems setting the JAVA_HOME variable! And you video was perfect! Tks!!

gabrielmalheiro
Автор

THANKS GOD, your video save my embedded Linux career

nguyenxuannghia
Автор

The set command is to list shell variables and env command is to list the environment variables . When you do export variable, basically you "promote" a shell variable to an environment variable, the idea behind is that an environment variable will be inherited by each launched process .

dejanualex
Автор

adding this to my favorites and subscribing.

xarzu
Автор

thank you! I am currently working on a science fair project with raspberry pi and i am trying to set up some variables to name pictures! does anyone know how to create a new variable as you do with common languages like java script?

codingwithgrace
Автор

Amazing video! THANKS (: no time wasting

Torres
Автор

Thanks for the info; but... any advice on how to do it in the .bashrc file directly? my aim is to make the addition of a path to a variable persistently.

arquimedon
Автор

You took 55 seconds and taught what most people can't even do in 5 minutes

csense
Автор

doesnt work in the latest kali distro, the changes only take effect in that terminal export does nothing

OPatron
Автор

i messed up my $PATH how can i get it back like it was because now i can't use many commandes in my terminal :/

youcefbahatte
Автор

This dont show me how to set it...It shows what it does but not how it does it, or step by step to do it.

kennynvakehve