All right.
You can tune the bash environment
to keep your settings persistent.
There's a couple of files involved.
To start with, etcprofile, which is a generic bash startup
file that contains all system settings that
are processed in a login shell.
Then there is etcbashrc, which is processed
while opening a subshell.
We have the .bash underscore profile
in the user home directory, which
is for user-specific settings and equivalent to what you
do in etcprofile system wide.
The .bashrc is the user-specific version of etcbashrc.
And you can use custom startup files
to make settings like variables and aliases persistent.
So let's check it out a bit.
So first, I'm using sudo vim on etcprofile.
I want you to have an impression.
And as this is a system file, if I just want to write it,
well, I don't need sudo privileges.
But I want to have the option to modify it as well.
So let's do the sudo privileges anyway.
And here we can see that this is quite a complex shell script.
It is, by the way, a nice example
of some shell scripting constructions.
And shell scripting is something that's
a part of the RHCSA objectives as well.
It's nice to know that this exists.
And it's nice to understand the meaning of a construction
like this, which means that if square bracket minus z dollar
hist file.
So if we don't have a variable with the name hist size,
then we are going to set it to hist size is 1,000.
But in general, the most important thing about bashrc
is to leave it alone.
That's what you can see right here.
It's telling you leave it alone.
It's not a good idea to make changes to this file.
The good idea to make changes to this file
is to get into the etcprofile.d directory.
This is a so-called drop-in directory.
So in this drop-in directory, every file that exists
will be considered while you are using your profile.
So instead of editing etcprofile directly,
you should create a drop-in file.
Because that leaves an option during an update process,
if ever it is needed, to update the etcprofile without you
losing your own changes.
Now likewise, there is this etcbashrc.
etcbashrc is a little bit like etcprofile.
It's coming very close to what you are doing in etcprofile.
But the difference is that profile
is for a login shell only.
So it will be processed only when
the user starts its first shell.
etcbashrc is for any shell.
And as you know that any command that you are using
is running in a sub-shell, etcbashrc
is probably more powerful.
But here also goes, leave it alone.
And if you have any drop-ins, better put them
in this etcprofile.d drop-in directory.
And you might also want to consider tweaking
your personal shell files.
So we have the bash profile, the bashrc.
So in my bashrc, if I would want to set an alias, for instance,
so if I'm adding alias sonder equals echo hello world,
then I've defined my own alias in a persistent way.
If I want to test it, I need to source .bashrc.
Source means that I'm going to include it right now.
I'm going to run it right now.
And the result is that I have a sonder command which
is printing echo hello world.
Is that useful?
I don't know.
But I do know that it is very useful to know
how to put aliases for your own usage in these bash startup
files.
Oh, and one more is the bash logout.
So do we have anything in the .bash underscore logout?
Well, by default, we don't.
But if there is any commands that you
would like to execute any time where you log out,
this is the location to put them.