Environment and Shell Issues

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey, there's Cybrarians.
00:00
>> Welcome back to the Linux+ course here at Cybrary.
00:00
>> I'm your instructor Rob Goelz.
00:00
In today's lesson, we're going to be covering
00:00
Environment and Shell Issues.
00:00
Upon completion of today's lesson,
00:00
you're going to be able to understand
00:00
how to determine the user's default shell,
00:00
as well as locate files that control
00:00
environment variables and explain
00:00
the purpose of the PATH variable and
00:00
issues that a user may encounter with PATH.
00:00
The shell is a command interpreter and
00:00
command line interface which we use to run commands,
00:00
utilities, tools, and write scripts or
00:00
programs which we're going to see in the next domain.
00:00
Now in this course we've used the Bourne Again Shell,
00:00
otherwise known as bash.
00:00
But there are several other shells
00:00
that a user can choose to use.
00:00
For example, tcsh, which is the enhanced C shell.
00:00
This is a scripting language that is a
00:00
lot like the C programming language.
00:00
The korn shell,
00:00
ksh, that can also be used as a programming language.
00:00
Then zsh or the z shell,
00:00
Z as in zebra, [LAUGHTER] hard to say.
00:00
The z shell, that's another scripting language,
00:00
and as the current default for MacOS.
00:00
Now to see a user's default shell,
00:00
you can run the getent command.
00:00
That's the get entry.
00:00
We can getent password rob and that
00:00
will get my entry in the
00:00
password file, that's the password.
00:00
You can see at the very end of that bin
00:00
bash, that's my shell.
00:00
Now if the shell is incorrect,
00:00
we can change it with usermod or chsh.
00:00
For example, usermod dash,
00:00
dash shell and then provide the shell.
00:00
Four slash bin bash change it to bash and then my name,
00:00
or whatever the user's name is.
00:00
Same thing, change shell works exact same way,
00:00
chsh, dash dash shell,
00:00
the shell and the user whose shell needs to be changed.
00:00
Now the configuration of environment or shell variables
00:00
can also impact how the account works and cause issues.
00:00
User environmental variables are set in
00:00
a few places depending upon the distribution.
00:00
Definitely check your distribution
00:00
and see where those are set C,
00:00
which files are in place in your home directory.
00:00
For example, dot profile or dot bash underscore profile.
00:00
You may also see dot bash
00:00
underscore login and dot bashrc.
00:00
These environment variables are used for
00:00
other shells and things like vim as well.
00:00
You might see that rc files
00:00
or dot vimrc, things of that nature.
00:00
We can also display these environment variables
00:00
with the commands like set,
00:00
env and printenv and we can use
00:00
those to verify what environment variables are in use.
00:00
Now, one of the more common issues users encounter
00:00
is with the PATH environment variable.
00:00
It seriously happens all the time because it's
00:00
variable sets of which
00:00
directories are searched for commands.
00:00
When a user says they can't run
00:00
a command, chances are good.
00:00
It's because they aren't using
00:00
the absolute path to the command,
00:00
and instead they're relying upon
00:00
that command to be found in their PATH.
00:00
But if a command is not found in
00:00
their PATH in their PATH statement,
00:00
the shell doesn't know how to interpret
00:00
the command. The fix is easy.
00:00
You have to add that directory to the PATH and
00:00
the environmental variable file for the user.
00:00
Now on CentOS, that's a dot bashrc file,
00:00
and on Ubuntu that's a dot profile file.
00:00
Then once that said you could do an echo path and
00:00
see if the PATH to
00:00
that command exists in the PATH statement.
00:00
If it's not there, that's the problem.
00:00
In this lesson, we covered how to
00:00
determine the user's default shell.
00:00
We also talked about locating files
00:00
used to control environment variables.
00:00
When we talked about the purpose
00:00
of the PATH variable and issues
00:00
users may encounter when it's not correctly configured.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next