Okay.
Now let's start with environment variables.
Now, when you open a terminal window and you pass a process which has its own environment, variables
is initialized, and these variables are form of global storage for various settings inherited by any
application that are run during that terminal session.
So open the terminal here.
I want to increase the font size a little bit.
Let's clear the screen.
Now, here we have the first environment variable which called the path, and we already saw it.
So I will use the eco command and what the delta sign and the name of the variable.
And this is not just the variable, it is environment variable, which means it is for the system.
So eco path here it will show start showing us the path where Linux will start looking for commands.
We have other environment variables like the user.
So eco user.
Here it will show us what is the current user which is curly.
And by the way, we can see that from here, which is curly.
We can see the working directory.
So by typing BWT we know that we are inside home cally now we can use EchoStar dollar sign be doubled
it will show us home cally as well.
Also we can use another environment variable which is home.
This is the home directory for the current user, which is home.
Kanae.
As we saw by the way, we are inside the tilde.
That's why BWT it will show us the same values.
So if I go last, for example, to desktop now if I type BWT, it will print the working directory.
Please don't get confused.
Okay.
BW D or e co that w d it will show us home cally desktop which is where is the current directory or
print working directory or the current directory?
Which is here.
All right.
But go home.
It will show us the home directory for the current user, which is Kelly.
Now, what if we want to create a new variable inside the bash?
So it firstly screen the screen.
I want to declare this variable var one equal.
For example, one, six, eight.
For example, it's put inside it.
Google dot com.
All right.
So if I type equal dollar sign one one, it will show us Google dot com.
But if I type or if I open a new terminal so control shift and and if I type equal var one again it
will show us nothing y because we open a new terminal session.
So this variable is inside the current process.
So again, if I type bash command and bash command here is to open a new bash inside this process so
it will be considered a sub process.
If I type e var one, it will show us nothing.
So how to make this variable available for all the sub processes?
Well, first let's put the exit command.
This is to exit from the current shell or by typing control d so to exit.
Now if I type e var one again you can see that it is google dot com.
Now I will use command called export.
So this export var one equal.
YouTube dot com, for example.
If I type E for one, this time it will be YouTube dotcom.
Now if I open a new bash OC bash terminal or a batch process, if I type equal bar one, it will be
here, which is YouTube dotcom.
So far so good.
Now if I type control D or exit clear the screen eco bar one.
Yeah, youtube dotcom is still here, so we will use export command for such things to have this variable
for all the sub processes.
All right, now, what is the use of the variable?
Of course we can use it in bash scripting of thing.
So for example being the dollar sign var one this will start binging YouTube dotcom.
But again, don't do this on life.
Targets by the way of being will not do anything harmful.
But please don't do any scanning or any reconnaissance whatever on a life target because you may get
in trouble.
Now we have special variables.
First, let's clear the screen.
The first one, which is equal dollar sign.
Dollar sign.
So here it will bring us the current process ID or P ID.
So the current ID.
PID for this bash terminal or process is like this number 1105.
So to make sure open a new bash now type equal dollar sign dollar sign.
You can see that oh it is different.
Which means this is another batch process as a separate process inside this batch process and it will
show us the PID.
Also we have the echo.
So first let's quit from this bash.
Clear the screen, equal dollar sign and question mark.
So this to tell us what is the status of the last running command so that if zero which means it is
run successfully if other than that it will be considered failed.
So for example, let's put this command.
This is not a command.
This is an error.
As you can see, command not found.
If I type echo the last sign question mark, it will be 127, which means there was an error.
Okay, but if I run again, if I run it again, what is the last command?
Which is equal sign?
So this will be zero.
All right, cool.
So far, so good.
So this will give us the status of the last running command if it is zero, which means successful.
Other than that, it will be considered failed.
Now to see all the variables.
So, for example, we have the var one, remember, or var one here.
So to see all the environment variables or the variables, run the command input.
So run it like that.
And you can see that here is all of the commands are here or the variables.
I mean.
Okay, so you can see that have var one it is here var one equal youtube dot com.
So all of the environment variable that are here inside the the bash process will be here.
Okay now if I quit again from it from the process, if I run it again, let's increase the font size
equal var one.
You can see how it is not here if I type in the same thing.
Bar one is not here.
As you can see.
Why is that?
We will talk about this later on.
There is something called the Toot Bash RC OC here.
So I will run this command, the Kat Bash RC here.
We can put whatever variables, then it would be exported.
Each time we run the bash program or terminal.
Don't worry, we will talk about this in detail later on.
For now, keep that in your mind.