Environment variables.
What are the environment variables, a regular definition or off the book definition of environment?
Variable is an environment, variable is a dynamic named a value that can affect the way running process
will behave on a computer.
They are part of the environment in which a process runs.
So in simple words, environment variables are a set of defined rules and values to build an environment.
So to make it more simpler, I will give you an example of a house we have.
Our house, by the way, is just a tall house.
That's the only house that I could picked out from from one of the 13 and that depicts the dining room
and bedroom.
Anyways, so we have our house.
Just take an example of our own house.
The house that you live in that house has its own environment.
What it means is it has a bedroom where you sleep.
It has a dining room where you eat.
So it has a kitchen where you cook and a dining room where you eat and has a playroom where you play
and so many different rooms for other purposes.
Now, those are the defined a set of rules or someone would say and unwritten rules, you cannot really
sleep in a kitchen or you cannot really cook in the bedroom.
Right.
Because those places are built for their specific needs.
So that's the environment of the house of your house.
Similarly, in Lennix, we have environment, environ meaning.
When a user logs in, that user is given an environment by saying, hey, your home directory, is this
your process or your shell?
Where are you going to run the script?
Those parts are these are these are the coloring you will get for all directory and listing.
And these are a few set of rules that you will get.
So they are inherited automatically through the global environment.
Those environment by the user can also be changed by a specific user as well.
So to view all environment variable in Lennix environment, you have to run the command print E and
we.
So by the way, it's not even it's E and we should fix that.
I and I will.
Definitely will.
And or you could just simply type E and we so both commands are the same will give you the same result.
If you want to list what is in your environment to view one specific environment variable, you could
run a command like Echo Shell.
So Dollar Shell, if you wanted to find out what is your shell.
Usually the shell in the it's given as Basche, Abin Basche.
That's a bass shell, conch shell seashell whichever you shell is.
If you wanted to find out your shell you will pacifically do eco shell.
If you want to find out specifically your your path you will do echo path.
Anyway, I'll show you in a few minutes what I'm talking about to set that environment variables on
the fly for example, you could export and test equal one and then do echo test.
Then when you type echo test you will get a result as one.
If you wanted to set the environment variable permanently, then you would have to modify that, bash
our C file and there you will have to put in test equal single code.
One, two, three.
Well single code y one, two, three.
Why not.
One is just the numbers.
I should have picked one anyway to be consistent and then you type export test.
But if you wanted to set the environment globally and you wanted to have it permanently, you have to
modify the profile and Bashar C that are inside of Etsy.
Now let me log in to my Linux machine and I will show you exactly what the shelves are.
So I am logged in and I'm logged in as myself I sol and if I wanted to list the environment I will type
print N.V. hit enter and as you see it, showing me a lot of stuff and it's going straight up, I could
do print environment and pipe it to more so I could view with one page at a time and you will see,
I'll tell you my my term, meaning that the terminal that will be used to log in would be like an external.
My hostname is my first Linux VM.
This is my session ID, which is automatically be assigned.
This is my shell.
Whenever I log in, a shell is given to me and that shell is bin bash.
The history size, which is whenever I run certain commands, those commands will be kept in history.
When you type history command, by the way, history command is something that I have covered in the
later lectures.
So history command that is telling you it has to record up to one thousand line.
So this is the environment, whereas the SS SSA y terminal that will be given what is the user comes
in of course is my user.
What are the different colors you see Ellis underscore colors when you run.
Ls minus l you see a different color for directory, different color for file.
Those are the colors you could change like any time, every time you you put in a file, it will show
up in the color code zero one semicolon thirty five.
What it refers to.
I'm not sure you can Google it, you can find out then going forward what where my mail will go.
Whenever someone sends me a mail where it will go it will go to war.
Spool mail.
I have TSOL.
So these are the set rules that define rules.
Where is my path.
Every time I run a command, the system, the operating system will go and find the location of the
belt that command.
And if that location is not listed and one of these path, it will not find that command.
My own bin directory will be home.
I have all been my home directory.
If I run would be home.
I have all the language that is set to UTF Dash eight.
Some histo history control my home directory, my login name, my data pad, Secich Connection and a
couple of other things which I could go over in detail, but I don't want to take up a lot of your time.
So these are the set variables, that environment that's given to you you could do if you wanted to
check which environment variable, a specific environment that you want to check.
You will do echo and you will do, for example, male.
You always have to start with dollar sign, by the way, because this way it will understand, oh,
this is a variable that I'm talking about.
So all I'm trying to find out what is the part that is defined for my male right here.
You see, it says male equals Glasspool male.
I have Zolt.
So if my shell is reading the correct environment variable, I should get this back.
So now if I do echo male washbourne male eyes are perfect.
Yes I am getting that now.
If I want to pass I will do echo pat and it will list every directory where my pat has defined just
to like that.
The path is defined here.
If I wanted to do my home I will do x go home and you will see this is my home directory right here
home.
This is my home directory also.
Sometimes what people do they if they are in one directory, let's say if, if you are in azzi directory
you do, you could simply do CD Dollar Home and it will take you home.
It's just us.
That's how your environment is defined as well.
So if you wanted to set in and an environment variable while you logged into the system, let's say
you wanted to do test equal one so you would type export test, which is variable, equal one.
And then you when you do echo.
Test a dollar test, you will see the value one, but of course, this is not permanently defined.
If you log out of your system right now, this environment variable will go away.
So if you want to set this environment variable permanently in your operating system, then you will
have to actually Vieaux Bash or C file.
So you are in your home directory first.
Make sure then I would recommend that you copy your bash, our C file, which is not Bash R, C and
make it Basche.
R, C, dot orridge.
So this way, if you make a mistake, you can always revert back to this.
Now you vidot bash our C.
And hit enter.
Now, come all the way down and define your variables, so I wanted to define my variable as test equal.
Now, this time I just want to do one, two, three.
When you define a variable inside of the Bashar, see, you put a code, a single code, then you hit
enter and then type export.
Test, go ahead and save your file now if you do test again.
I could test you, you will get one, why are you getting one?
Because it is still reading that export test equal one and then it is giving you that same value.
You have to log out a log back in.
So for me, I could just go here and click on this little icon up here and type in duplicate session
for my PUDI.
I will do I afsal login hit enter and now and I do echo.
Test.
You will see it is giving me one, two, three, because this session I have a new session and when
I logged into a new session, every time I log into a new session, my log in will read Dot, Bash or
C file this file.
And when you do a list minus L.
And by the way, if you go up, you will see that Dr. Bashar is not showing up because it is a hidden
file.
Any time you need to view a hidden file, you have to do ls minus a hit, enter and now you could go
up.
And you will see your dot Benghazi file right here, this is the one I modified, if you have modified
as you could modify this file to set your environment and then make sure you log out and log back in
or start a new session if you want to have your environment variable take effect right away.
And the last one I have right here, I'll go ahead and close the session behind it is if I want to set
global environment permanently, meaning if I wanted to set these environment not just for myself,
I wanted to set it for everyone else who logs into that system, make sure you know what you're doing,
first of all.
So I will not recommend you that you do it right now in your lab.
However, I will explain you the files that you would need to modify.
Those files are at C profile.
This is the file that you would have to modify or you you have to modify ATSE, Bash Arcy so you can
modify these files and you will put in exactly the same way you put it in in your DOD Bashar.
But again, as I said, please do not modify this because the lab environment I don't want you to modify
globally and it will cause problem and then you will know the root canal log-in or yourself self log
in.
But if you wanted to do it for your production environment or your corporate environment where you're
working, I would recommend you to do it in development first.
And then you tried in production.
All right, Kulluk.