DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

If you execute this command, you are likely to notice a
lot of keywords with the = sign tied to values. One
environment variable that you use every time you
execute a command is the PATH variable. This is where
your shell looks for executable files. If you add a new
command and can’t execute it, more than likely the place
where the command was copied is not listed in your
PATH. To view any variable value, you can use the echo
command and the variable you want to view. You also
need to tell BASH that it’s a variable by using the $ in
front of it. Here’s an example:


Click here to view code image


$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware
Fusion.app/Contents/Public:/opt/X11/bin

To add a new value to the PATH variable, you can’t just
type $PATH=/new_directory because the operating
system reads the environment variables only when the
terminal session starts. To inform Linux that an
environment variable needs to be updated, you use the
export command. This command allows you to append
your additional path to BASH and exists for the duration
of the session. Make sure you add the : or , in front of
your new value, depending on your operating system.
The following example is for a Linux-style OS:


Click here to view code image


$ export PATH=$PATH:/Home/chrijack/bin

When you end your terminal session, the changes you
made are not saved. To retain the changes, you need to
write the path statement to your .bashrc (or .zshrc if
using Z shell) profile settings. Anything written here will
be available anytime you launch a terminal. You can
simply copy, add the previous command to the end of the

Free download pdf