[Intro Music]
We have just successfully created
a new executable script called
script.sh. And we have successfully
executed it using the absolute or
relative path to location of this
script. Here are three different
examples for execution of this
script. But we are not able to
access it like this. And if you
want to do so you need to modify
PATH variable. But first, let's
create a new subfolder in the home
directory for this user, 'bogdan'
user. And inside of it, we will
place this script file and
afterwards we will add path to
this 'bin' folder, to this PATH
variable. Let's do that. Let's
first create a new folder called
'bin' here in home directory for this
user. And here I see this folder.
And now let's move this script.sh
file into this 'bin' folder. For that
I'll use command 'mv', and move
'script.sh' to 'bin/script.sh'. Like
so. And now if I list the contents
of the 'bin' folder, I'll see script.sh
file here inside. Let's 'cd' to
'bin', and here type 'pwd', print
working directory. And I see the full
path to 'bin' folder. And now I
need to take this path, and
concatenate it to this PATH
variable. For that you need to do
following. Let's first copy
this section; and next type following
command, 'export PATH =
$PATH', next ':', and
let's now paste copied path to
'bin' folder. What this command
will do? It will take existing PATH
variable and concatenate to it this
section. Please don't forget to add
here ':'. And afterwards, this
resulting path will be exported
into PATH variable. And technically
we will rewrite existing PATH
variable. Let's try to press Enter
and see what will happen. Let's use
'echo', and type now PATH variable.
And now I see that this section was
concatenated to previous PATH
variable. And now I am able to
execute that script that is located
inside of the 'bin' folder here in
home user directory for 'bogdan'
user anywhere I want. Let's
try to do that for example, here in
'bin' folder type simply 'script.sh'
without any prefixes, without
any path, like so. Let's press Enter,
and I see result. Script was
executed successfully. 'Hello from
the custom script'. I could 'cd' for
example to root directory like so,
and enter the same command 'script.sh',
and the result will be the same.
And the reason for that is that now
this script is located in the PATH,
here. And I'm able to access it
anywhere I want. And of course, if
you want to, you could even remove
this extension and name the
script without any extension at all.
For example, let's rename it to
let's say, 'my-script' without
extension. Let's use 'mv' command;
and here I need to use absolute or
relative path to this script file,
and let's use the relative path,
home directory, here will be '/bin/
script.sh', and let's rename it to
'/bin', and here will be simply
'my-script' without any extensions, like
so, Enter. And now let's try to
execute this my-script. Simply type
'my-script', and the result is the
same. And if I list the contents of
the 'bin' folder like so. Let me do
that. Let's actually add the '-l'
option. I'll again see that this
file is executable script, it is in
green color. And here I see
executable permissions for a
specific user, for owner of this
file. That's how you could pretty
fast and easily allow execution of
any executable script from anywhere
by adding a path where this script
is located to PATH variable like we
did here. Great. That's all for
this lecture. And this is all actually
about executable scripts and
permissions. I will not show you how to
create more complicated scripts.
And if you want, you could do so.
Actually executable script is
simply a set of shell commands,
nothing else. You are able to
perform any actions you like. You
could create variables, you could
perform any other actions like list
files, grep output of some
commands, and so on. Script is
simply a set of commands that are
executed one by one. All right,
that's all for this subsection. And
next let's talk about networking in
Linux systems. I'll see you next. Bye-Bye.
[no audio]