4:47:02
2025-02-19 09:20:08
2:39
2025-02-19 21:55:33
1:15:07
2025-02-20 09:31:43
1:28:23
2025-02-20 11:13:37
1:16:38
2025-02-20 13:43:10
Visit the Network Engineers Programme course recordings page
WEBVTT
-->
uh...
-->
uh...
-->
uh...
-->
uh...
-->
back here with you
-->
now
-->
uh... hopefully you're still here with me
-->
so we just made an alias for CP
-->
uh... what if i want to execute CP
-->
without the minus i
-->
right now
-->
as expected the alias is working
-->
so right now
-->
it's a little bit annoying
-->
i just want to run CP as it originally runs
-->
not the alias
-->
what happens
-->
if i directly refer to that path
-->
of the executable
-->
would the temporary alias or the alias set
-->
still be an effect
-->
looks like not
-->
if you directly point
-->
to the executable
-->
it ignores your alias
-->
if you don't
-->
your alias is an effect
-->
give it a try
-->
when it is CP
-->
you can see CP on its own is replaced with CP minus i so the alias is working
-->
what if we didn't want to
-->
run the alias
-->
run the
-->
command from the actual path
-->
and you can set up alias
-->
just to make your life easier
-->
you don't have to remember complex commands
-->
every single time you want to run them
-->
just a quick alias
-->
and the software will work for you
-->
are we ok so far?
-->
very good
-->
some other basic tricks onto the command line
-->
just getting comfortable
-->
you can execute multiple commands
-->
together
-->
simply put
-->
multiple commands separated by a comma
-->
a semicolon
-->
and it can be
-->
as many commands as you want as long as you separate them
-->
guess what the sleep command does?
-->
quite literally puts the terminal to sleep isn't it?
-->
just introduces a little bit of a delay that's all
-->
useful in scripting and other scenarios
-->
now right now
-->
between these two commands
-->
or three commands or four commands
-->
there is no logic between them
-->
they are simply separate commands being executed
-->
what if I want to execute the second command
-->
only if the first command is successful
-->
or the other way around
-->
I only want to run the second command
-->
if the first command fails
-->
we are going to give this a try
-->
I am going to create a file x y z
-->
now you know this from experience
-->
what would happen if I did this?
-->
it's not going to let me do it
-->
because there is a file with the same name
-->
by the way what happens if you use the command touch
-->
and the file already exists with date
-->
it's not going to overwrite the other one
-->
no it just updates the date and time stamp
-->
of that file last access
-->
it's a non-destructive command
-->
similarly if you say touch for a folder
-->
all it does is just update the metadata
-->
it doesn't do anything destructive
-->
but in this case I have created a file first
-->
and now I am going to create a folder
-->
if I do this command now
-->
cd x y z
-->
or cb slash hosts
-->
to x y z
-->
it just stops me right there
-->
hey I cannot create a directory
-->
another example if I do this
-->
and say create a file a b c
-->
now we know that the first command is going to fail
-->
has it created a file a b c?
-->
what does this prove?
-->
so it proves that if one command fails
-->
the other one is going to fail
-->
no it won't execute
-->
it's a conditional connection
-->
between the two different commands
-->
if I remember correctly
-->
that's a big F
-->
is that that?
-->
let me just check
-->
b c
-->
oh I do remember
-->
if you put two pipes together
-->
it's the inverse logic
-->
only if the first command fails
-->
then execute the second one
-->
oh ok
-->
I would request you to please try this out
-->
continue working on this concept
-->
of chaining the commands together
-->
and working with the output of commands
-->
I will give you a few minutes
-->
just give this a try
-->
Ivan you are comfortable with this?
-->
yeah
-->
alright
-->
giving a quick minute for people to try this out
-->
E2 all good?
-->
yes all good
-->
let's continue now
-->
and look at the idea
-->
of chaining multiple commands together
-->
and what I mean by that is taking the output of one command
-->
and using it as an input
-->
of the second command
-->
just a quick reminder we did this command earlier w c
-->
what is it waiting for?
-->
this command right now
-->
maybe for you to terminate
-->
or you have to write and then terminate
-->
then it will terminate
-->
isn't the file that it must wait
-->
to come from
-->
so it needs some input
-->
isn't it simple words
-->
it needs some input
-->
and then
-->
it does what it does
-->
so to terminate when you type it just
-->
we have to use what control d
-->
control c will abort it
-->
so you come to an empty line
-->
a blank new line and then do control d
-->
control d is technically called as end of file
-->
and the trouble is sometimes
-->
when you are reading websites or documents
-->
and they say EOF
-->
and you are like what is this? what do I do?
-->
because you literally type EOF
-->
that's the end of file
-->
and you are like
-->
and you are like why is it not working
-->
I am typing what the guys say
-->
because there is no way for them to type
-->
the keystrokes
-->
so this is how they are represented
-->
so here I am going to do this
-->
ls minus l
-->
or slash
-->
let's say
-->
of my current
-->
folder
-->
so I am going to do ls minus l
-->
what I am going to do now I am going to put a pipe
-->
and literally the pipe is acting as a pipe
-->
is going to take this
-->
output of ls minus l
-->
and it will pass on that output to the word count
-->
as an input
-->
and now word count is counting
-->
the output of the first command
-->
it says hey you have 41 lines and so many words
-->
so this is the idea of piping
-->
you can carry on piping
-->
you can take the output of word count and give it to another command
-->
and you can change them together
-->
the most common reason
-->
in the Linux Unix world when we are piping
-->
is because we want to filter the output
-->
and we are looking for something specific
-->
let me explain for example
-->
let's look at this file
-->
ETC hosts
-->
there are many lines in this
-->
some lines contain the word localhost
-->
correct?
-->
what if I wanted to see only those lines
-->
so typically you can use
-->
attune grep
-->
I can say grep I am looking for localhost
-->
in this file
-->
I have to say vini and eto
-->
are the fastest at doing what I am doing
-->
sometimes I get confused
-->
am I watching my terminal
-->
or somebody else
-->
I look at vini and eto's terminal
-->
is that me with the delay
-->
what do we get
-->
it has kind of filtered out
-->
all the lines that contain localhost
-->
is only showing us that
-->
I can do it the other way round
-->
inverse
-->
with a minus v
-->
I don't want to see any line that contains the word localhost
-->
goes the other way round
-->
minus v
-->
eto
-->
is
-->
not the way
-->
I know
-->
I use it to
-->
show when I am running
-->
maybe I am executing something
-->
so that it can show me what it is doing
-->
so be very careful
-->
options are
-->
different for different commands
-->
every command
-->
has its own options
-->
so minus v for one command doesn't mean the same as minus v for the other command
-->
in many
-->
minus v stands for verbose
-->
but please don't make that assumption
-->
every single command has its own options
-->
you have to read the main page for it
-->
this is specifically for graph
-->
now let's combine a few things together
-->
for example
-->
ls minus l slash etc
-->
now this is a big output
-->
these are all the files in
-->
etc
-->
I specifically want to look at
-->
all the configuration files in
-->
etc
-->
I only want to see
-->
those that were updated let's say in
-->
February I put a pipe
-->
grip and give me a quick second
-->
hang on
-->
hello
-->
yes boss
-->
from
-->
why are you calling me my friend
-->
thank you my friend thank you
-->
sorry
-->
so I say grip
-->
I include minus i because I don't care about uppercase and
-->
I will simply
-->
say fab
-->
some kind of filtering out
-->
and I want to know how many of these are there
-->
as you can see
-->
the pipe is one of the most useful
-->
to allow us to chain multiple commands
-->
together
-->
yes I'm familiar with the pipe
-->
what did you say the semicolon was for again
-->
just to run multiple commands at the same time
-->
there is no chaining between them
-->
okay
-->
that's fine
-->
this is the graveyard shift
-->
it's a happy time for a trainer
-->
because people have no questions at all and if you are
-->
doing any workshop in person
-->
the moment you look at somebody they just shake their head
-->
in anticipation saying all is well
-->
don't look at me I have products
-->
here I can just monitor who's typing and whose terminal
-->
is blank
-->
hopefully this is clear
-->
go ahead
-->
I like that Akona is the
-->
translator between me and others
-->
he's acting as
-->
I'm not sure if you are acting as a bridge or a switch
-->
or a router or a gateway or a proxy
-->
but well done
-->
it's more like a layer two amplifier to me
-->
so that's basically the idea of
-->
connecting and chaining the commands
-->
together frankly comes in very very handy as well
-->
and things like graph kind of work as well
-->
quite well
-->
talking about connecting commands together
-->
and working on
-->
files we saw this earlier when we did
-->
a little bit of this
-->
and we did that
-->
so what does that greater than sign represent
-->
it says
-->
it's like redirect
-->
you are
-->
you are sending
-->
these to a file
-->
my understanding is that you are sending this
-->
so these that you are going to be writing on the first line
-->
of the file
-->
always on the first line
-->
you are redirecting
-->
the output
-->
somewhere to some device
-->
however let's pay attention to that
-->
a little bit what happens if I run
-->
a command like this
-->
so var is a folder that exists
-->
so I get some output
-->
and var one is a folder that does not exist
-->
and I get some error
-->
what would happen
-->
if I did this and the command takes
-->
multiple arguments what am I going to get
-->
only the good only the bad the both nothing
-->
only the good
-->
that will be very nice very convenient
-->
I like that
-->
I get both
-->
I get the error
-->
as well as
-->
what we call as a standard output
-->
so there is a standard error
-->
there is a standard out I get them both okay
-->
what we are going to do now we are going to repeat exactly the same
-->
command
-->
and I am going to say this
-->
what do you expect
-->
to be captured into that log file
-->
first we ran the command we saw
-->
everything on the screen
-->
on the terminal and now I am saying okay let's run
-->
exactly the same command again and I want everything to go
-->
into that log file
-->
watch what happens
-->
what do you see on the screen
-->
this cannot access
-->
so that's the error correct
-->
so guess what's in the log file
-->
only the good news
-->
oh okay
-->
not expecting
-->
sorry
-->
the output
-->
of
-->
that directory that command
-->
worked
-->
slash war
-->
is successful
-->
so that output
-->
is saved into the log file
-->
this is the output
-->
yeah
-->
the error is on the
-->
terminal
-->
so the
-->
error is on the terminal
-->
the good news goes in there
-->
so watch this now
-->
same command
-->
and let's see
-->
we'll explain in a bit
-->
but see if you notice any difference
-->
what's different this time
-->
here there is one
-->
there is two
-->
and what's showing up on the screen
-->
it looks like
-->
do you see any errors like you saw last time
-->
no
-->
so what does log file 1
-->
contain
-->
no log file 1 contains the good output
-->
yes and you can guess
-->
log file 1 in the same output
-->
the second output
-->
but I think there is a trick in there
-->
this one
-->
so it's not the
-->
first output or the second output
-->
one is a special number
-->
which means standard output
-->
and two is redirecting the
-->
so one is the code for the good output
-->
two is the code for errors
-->
so there's no three
-->
yes
-->
so my question
-->
is that
-->
so you said
-->
the AR1
-->
and then you said
-->
one
-->
must redirect to log file 1
-->
and two must redirect to log file 2
-->
first and the second
-->
no it isn't
-->
but that's not the case
-->
maybe I type it
-->
no I can't see your screen
-->
no no
-->
I can explain very simply
-->
if I just say mkdir
-->
I'm in a current folder
-->
let's say I make a folder
-->
called as data100
-->
what happens if I repeat the same command again
-->
so that's an example of an error
-->
so this is what 2 greater than
-->
simply represents
-->
any errors are redirected
-->
in the case of the first one
-->
was the command successful
-->
so if I take an example again
-->
I say make directory 101
-->
it worked correct
-->
yes
-->
what if I say echo
-->
dollar question mark
-->
this is a special command
-->
how did the last command exit
-->
what was the code exit code
-->
exit code 0 it exited without any errors
-->
basic programming
-->
I run the same command again
-->
what was the exit code
-->
of that command
-->
that's an error
-->
so anytime
-->
you are doing redirection
-->
one greater than simply means
-->
without errors
-->
two greater than means any error
-->
the reason I'm showcasing
-->
a single command here
-->
is because I can show both
-->
good output and an error
-->
from a single command
-->
is it always based on the last command
-->
yes yes yes
-->
what do you mean 1 and 2 based on the last command
-->
so you run a command right
-->
this echo dollar question mark
-->
is the exit code of the last thing that ran
-->
in the terminal
-->
now let's do something interesting
-->
ls slash var
-->
which we know will work successfully
-->
and slash var 1
-->
as well we are going to do something
-->
we are going to redirect this to
-->
I'm going to do something
-->
here
-->
what's going to happen here
-->
we still don't have var 1
-->
yeah so we will get both
-->
the output and the
-->
the good output will go into the good
-->
log fair enough
-->
where is the error going
-->
and dev null
-->
is a black hole
-->
in your operating system
-->
even light
-->
cannot escape it
-->
so whatever you throw there never comes out
-->
it disappears in thin air
-->
so you can't go to this
-->
direct and say I'm going to check
-->
what is inside null file
-->
nope
-->
so there you just throw in
-->
what is garbage
-->
so I don't see it on the terminal
-->
it's not recorded into a log file
-->
in a file system as you said is garbage
-->
please try this out
-->
Vinny you are right about being the quietest one
-->
I know
-->
I mean in the training session
-->
not in general
-->
wrong impressions
-->
that's what we need today
-->
that's what we need
-->
it depends on the situation
-->
it's an alias
-->
oh it's because it's not conveyed
-->
I see
-->
I don't know what you want to want now
-->
it's a stranger danger
-->
I think it's bad as much as people
-->
it's also a bit quiet
-->
it doesn't involve cyber security
-->
type
-->
type
-->
just type
-->
you have a terminal just type
-->
alright
-->
hopefully you can try this out
-->
hoping that this makes sense as well
-->
as to how do we redirect the output
-->
and in this case
-->
sending some part of it
-->
to them now
-->
please tell me one thing
-->
so if you're saying
-->
the code output must go to code log
-->
don't need to have created code log
-->
as a file format
-->
only one thing to note
-->
and that thing to note is
-->
if you keep doing this
-->
you will overwrite that file
-->
if you keep doing what?
-->
redirection
-->
unless you do
-->
that
-->
this is going to append at the end of the file
-->
yeah, I wanted to ask if it
-->
applies here as well
-->
be careful with that
-->
append otherwise
-->
you're going to overwrite
-->
that can happen
-->
you can accidentally just use the redirect again
-->
and then you look at the file and you're like
-->
where is everything? you just wiped it clean
-->
so just be careful with that
-->
I'll give you the opportunity of course to try everything out
-->
that was the intent today to keep it as a workshop
-->
and obviously you need to spend some time
-->
with the OS yourself
-->
most many networking devices and systems
-->
have underlying Linux
-->
minimum you want to go there, look at some log files and stuff like that
-->
so hopefully you feel more comfortable doing that
-->
when I started with my life in IT
-->
back in those days
-->
there were only three options
-->
that people understood related to IT
-->
either it was hardware
-->
or software
-->
or multimedia and I had a hard time telling people
-->
I'm a network engineer, nobody understood
-->
I'll tell them I'm from the network
-->
and they're saying yeah so which one?
-->
hardware, software or multimedia?
-->
you had to put yourself in one of the buckets
-->
scroll up
-->
scroll up
-->
I think that's all there is
-->
are you happy to show me the history?
-->
you can try this out
-->
this is for everybody, just run the command
-->
lso lso
-->
and any command you want to execute
-->
just put exclamation mark
-->
and put the command number
-->
oh you can do that
-->
as you can
-->
yeah
-->
so what can you do?
-->
so what can you do?
-->
oh you can run the command
-->
and the history
-->
using the number
-->
I thought I know Linux
-->
that's fair
-->
I mean you would always assume
-->
that since you are comfortable with it
-->
you can get certain things done
-->
I can understand why you would say that
-->
the commands you know are enough
-->
for the work that you do
-->
specific tasks
-->
nothing wrong with that
-->
yeah but I was using the wrong commands
-->
to do certain things
-->
in fact I was just doing
-->
five steps
-->
and then I'm done
-->
so hopefully that works out
-->
we can see the append
-->
with the greater science twice
-->
a quick look at the history
-->
and then executing the commands
-->
in the history
-->
so there are lots of tricks
-->
on the shell
-->
and that's kind of what we are
-->
aiming for here
-->
knowing how to get certain things done
-->
or maybe understanding how things happen
-->
and then these could be very handy as well
-->
so this works
-->
now as you are working with the log files
-->
and the file system
-->
and we are looking at how to append
-->
one thing just comes to mind
-->
and that is when you are
-->
specifically if you are working with log files
-->
and reading some log files
-->
what comes in kind of handy
-->
let's have a look
-->
I'm in the same folder just to make my life easier
-->
so if I have a log file
-->
and we have seen a couple of log files
-->
like here is the good log file
-->
and we saw that we could add something
-->
into the log file
-->
if I cat or more
-->
I will see that happening
-->
but I can actually watch a file live
-->
I can keep the file open
-->
text file open
-->
and what tail is going to do is show me as new entries
-->
come into that log file
-->
so very handy if new messages are getting recorded
-->
so I keep tail minus F
-->
you can see here it's keeping the terminal open
-->
this command I can tell you
-->
here
-->
all of us
-->
we use it in telephases
-->
you are masters of this
-->
that's only, I'm sure, not true
-->
I'm sure with all these tricks
-->
maybe it's something
-->
because already I'm seeing the number of lines
-->
1, 2, 3, 4, 5, white has always written 5
-->
is that the default? can we change the number of files?
-->
but it's doing echo there
-->
redirecting to good log
-->
I'm just adding more
-->
into the file
-->
it's just watching the file
-->
live
-->
okay
-->
that's one
-->
you can always control C out of it
-->
there are a few other things
-->
frankly I haven't tried them on Ubuntu
-->
is there a command watch? oh yeah there is
-->
very nice
-->
that should work
-->
so
-->
watch
-->
2 minus A
-->
it's actually repeating the command
-->
every 2 seconds
-->
then showing me the output
-->
so tail was showing you a file
-->
as data enters into that file
-->
who is just repeating the command
-->
over and over and over again
-->
so if I open a new terminal
-->
another terminal
-->
number of terminals incrementing
-->
let me just
-->
arrange this a bit
-->
that's
-->
number 6
-->
I wonder why not
-->
I just need to
-->
I'm not sure
-->
my other terminals
-->
let's
-->
let's
-->
let's try something very simple
-->
ls
-->
slash temp
-->
and let's
-->
just create
-->
a file
-->
typically it works
-->
I will just check some options
-->
I can see the file x show up now
-->
let me
-->
create another file y
-->
that shows up there as well
-->
takes 2 seconds but it shows up
-->
I wish this was there back in the day
-->
in the Unix world but yeah here we go
-->
you have a command that watches other commands
-->
execute and update that might be handy
-->
instead of you manually running the command
-->
every time
-->
no tail is watching a file
-->
showing your data coming
-->
into the file watch is running a command
-->
repetitively
-->
any command
-->
that's fine
-->
you mean the
-->
interval
-->
don't look at the command ls
-->
watch can be just used for anything
-->
watch the date
-->
about 2 seconds of the time changes
-->
don't equate watch
-->
with files watch is simply a way to repeat command
-->
and watch them execute
-->
control c just works
-->
control c is your best friend
-->
on the Unix command line
-->
when in doubt control c
-->
except to the e or f
-->
sleep for one second
-->
give me the list of
-->
clear
-->
just simply
-->
works very handy
-->
keep looking at my IP addresses
-->
see if anything changes a new IP gets
-->
created whatever
-->
what is your friend helps in many cases
-->
so that you don't have to repeat
-->
so watch
-->
can only
-->
show if this
-->
changes or just show
-->
it just yeah exactly it just repeats the command
-->
iteratively
-->
not like it's waiting for anything
-->
no no no
-->
simply it's a recurring
-->
demon just repeats the command over and over
-->
again
-->
and it doesn't
-->
it's not recording anything
-->
that's why we just
-->
did this one right ls minus l
-->
slash temp I just want to see
-->
what files are there I can then say hey I want to
-->
keep watching
-->
this folder
-->
it'll just keep watching that
-->
folder it just repeats the command
-->
as always there might be
-->
quite a few number of options
-->
this one's for you
-->
minus
-->
d for differences you can specify
-->
the interval you don't have to do it
-->
every two seconds
-->
okay so minus d might be interesting
-->
if we said watch
-->
the date
-->
nice right
-->
so that's nice it's a nice option
-->
I can just see the differences which are there
-->
very handy
-->
and I think all of this at the end
-->
kind of culminates into writing a script
-->
that can automate some of
-->
the work we're not getting into scripting here but the point
-->
of learning all of these different commands is at the end
-->
making your own recipe
-->
I log in I perform some routine tasks
-->
maybe a simple script can accelerate
-->
that workflow for me
-->
that's where that kind of comes in
-->
just putting it all together
-->
the life ends with a nice script
-->
just talking about
-->
creating scripts
-->
we can start by just creating
-->
a simple text file
-->
which contains some commands
-->
just creating a simple text file
-->
of course there's a whole syntax on it
-->
but let's do that I'm going to create a script
-->
I was going to do the
-->
vi escape dd then I realized this is not vi
-->
nothing very special
-->
just a bunch of commands right now
-->
I'll end with some special characters
-->
so we understand how these characters could be used
-->
alright here we go I save this
-->
so here I have
-->
my script
-->
how do I make this
-->
as a script how do I execute it
-->
right now it's just a text file
-->
if I just type this
-->
do I have to make it an executable file
-->
what if I just mention it's exact location
-->
I'll wait for Vinny
-->
I know you were just typing something in
-->
what happens if I do this
-->
like we did with the binaries
-->
slash user vin cp what if I just mention the exact path
-->
don't look at that because
-->
I need to create a new script
-->
that file is already done
-->
so let me just create a quick new script
-->
and it doesn't do anything special
-->
I am fine with it
-->
so let me mention the full path
-->
here
-->
let's mention the full location
-->
slash new
-->
slash new script
-->
doesn't like it
-->
it's saying as a file you are not
-->
executive permission is denied
-->
yeah Vinny give it a try just put the full path
-->
of the file you can see E2 is trying as well
-->
careful with the file path
-->
Vinny make sure that that location is correct
-->
slash home slash student slash new script
-->
just careful with what you are writing
-->
try again it should work
-->
it will work with an error
-->
like what you see in my case you are going to get this permission deny
-->
sorry can't execute
-->
what if
-->
I do it the other way
-->
I execute by running
-->
the shell
-->
and then I mention the path
-->
would this make any difference I am loading a new shell
-->
environment spawning a shell so to speak
-->
hello that works
-->
as you can see if I manually load a shell
-->
spawn the shell mention that file
-->
the shell executes and it runs that script
-->
the commands you mentioned probably are not
-->
there in the file just taking a closer look
-->
at
-->
okay Vinny just take
-->
a list first just do an
-->
ls minus l
-->
ls minus l in present let's just see everything we have got
-->
there is a my script
-->
new file and there is a new script
-->
new script
-->
so now
-->
one day it cannot find that file maybe you can
-->
rename it with mv new script
-->
use the tab I think it should auto complete
-->
is there a new script also
-->
it is a my script and then there is
-->
another file that is new script new script
-->
yeah just backspace
-->
put the full file name again please
-->
yes
-->
now just write new script alright
-->
that should do the trick
-->
thank you
-->
so as you can see in my case if I
-->
kind of spawn the shell it works
-->
but on its own it doesn't work like an
-->
executable let's take a look
-->
at this file
-->
that I have created
-->
and what we are going to do is use a very simple
-->
trick
-->
that many of us know
-->
chmod is the command used to manipulate file
-->
permissions I wonder what is happening there
-->
let me just take a closer look bash space
-->
I think inside that file
-->
you have written certain things can you edit that file
-->
again the new script file just do nano
-->
because in the script on the third line
-->
all you have written is the name of the script
-->
we need some commands here
-->
you can just delete everything here
-->
and then type
-->
some commands you can just do uname minus a or
-->
hostname or echo something
-->
yeah hostname
-->
for good measure
-->
alright that's it save your file
-->
we get it we get it a couple of commands are good
-->
let's save this file
-->
as it is run that again
-->
thank you
-->
so here I say chmod
-->
let's make this executable
-->
what changes in the permissions
-->
I get a little x
-->
in the permissions of the owner
-->
the group everybody else anyone and everyone
-->
should be able to execute it now
-->
one way of doing that either I
-->
mention the full path
-->
if you see
-->
last time that didn't work
-->
I have made it executable now
-->
it works now if I mention the full location
-->
or just like this because it's in the current location
-->
remember dot
-->
is your current directory
-->
lucky you're trying things
-->
already comfortable
-->
maybe these are things you're already used to at the moment
-->
let's see
-->
after dot give a space
-->
cases and cases very important
-->
how about you all well
-->
shut down already
-->
no no everything is fine
-->
I think if we run the top command it might show a different output
-->
if I run the
-->
I said if we ran the top command on you we might see a different
-->
command
-->
system utilization
-->
is very high
-->
I want to tell you a story about the top command
-->
this is like
-->
maybe 15 years ago this was for one of the clients
-->
we were looking at the total CP utilization
-->
was very high
-->
80 percent 90 percent but when we
-->
looked at individual applications and we
-->
added it together it was just 10 15 percent
-->
so this output here
-->
of individual process
-->
CP utilization did not add up
-->
to the total utilization that we were seeing
-->
and we were just scratching our head
-->
saying what's going on
-->
the system utilization is definitely high
-->
but we can't see any process
-->
which is using that
-->
and after a bit of low level
-->
message kernel debugging
-->
what we realized was that one command
-->
was creating or one process
-->
was creating other processes
-->
thousands of processes every second
-->
and all these processes
-->
were instantly dying
-->
so the system was creating processes
-->
and killing them so fast that they were not even
-->
showing up in the output on top
-->
so we didn't
-->
see those thousand processes here
-->
but it was adding up to the total
-->
it was a brilliant low level debugging
-->
of an exercise where the client says
-->
something weird is going on in my machine
-->
something is eating the utilization
-->
I just don't know what
-->
and of course here if you press
-->
H in the top command there are plenty of
-->
things you can see and do
-->
it's a brilliant command
-->
that's a little bit about
-->
the final piece which is you know just kind of
-->
putting it all together
-->
and creating potentially certain scripts
-->
I think that's the natural
-->
I would say destination I do not have many commands
-->
it kind of does what you do
-->
alright quick one any questions
-->
from anyone
-->
there's a lot
-->
we have seen
-->
so far so good
-->
so this is a very good session
-->
any unresolved queries or questions
-->
curiosities things
-->
that this session might have made you think ah I wonder how
-->
that works or I wonder how to do something
-->
it's just only one thing for me
-->
to search
-->
yeah
-->
yeah
-->
so if you are talking about finding
-->
a file in the file system we are typically
-->
looking at the command find has two core
-->
arguments one is where to start looking
-->
from and what to look for
-->
if you don't know where to start from
-->
you can always start from the root but do keep in mind
-->
it can slow things down a little bit specially
-->
on systems which have a large file system
-->
if you kind of know where it might be
-->
it's always a good idea to
-->
filter limit and scope
-->
and say hey I'm looking for files
-->
starting from where it's a good start
-->
now comes
-->
sorry go ahead Akrana
-->
the type as well there's a type option
-->
no so now after this
-->
comes what do you know about that file
-->
so the first is start looking from where
-->
and the second is one or more attributes
-->
is it a file is it a folder
-->
do you know the name part of the name
-->
do you know when it was last modified
-->
last accessed all of those parameters
-->
I can start with the simplest of the things
-->
I think I know
-->
that somewhere in the name is
-->
conf
-->
and then it kind of punches out
-->
everything there
-->
ok these are all the files
-->
I have found so in this case
-->
dash name is literally the name
-->
if you look at the main page
-->
the manual page for this command
-->
you might see that it supports many expressions
-->
and you will see some examples
-->
here of the expressions
-->
some of these are
-->
really quite long
-->
but let's try out what we can see
-->
you almost feel like you're reading a book
-->
isn't it
-->
I understand that's why we end up
-->
googling for it
-->
because it might be a bit faster
-->
but obviously this is the
-->
full system help
-->
and you're like never mind
-->
I don't need to find it
-->
is this the manual for the find command
-->
yes
-->
oh ok
-->
so
-->
last modified less than
-->
what we saw right now was
-->
dash name
-->
that's a better
-->
but I can use many of these
-->
combinations it's in which paths
-->
what are its permissions
-->
so classic example is we will look for file
-->
especially if you're doing system hardening
-->
or we are auditing a system
-->
we will look for files with certain kind of permissions
-->
in the wrong place that could indicate as a compromise of a system
-->
but you might have your own reasons why you're looking for files
-->
and this is very useful
-->
for example what if I'm only looking for directories
-->
this is very handy I'm only looking for directories
-->
this is also nice all the files
-->
owned by a specific user
-->
the last time the file was used
-->
good if you're trying to do a backup or an archive
-->
Econa likes this one
-->
very small
-->
oh by the way you can do
-->
a lot more with the find command
-->
every file which is found you can
-->
execute something on it
-->
what if I say find all the files
-->
owned by this user not
-->
accessed in last 30 days
-->
and move them to an archive location
-->
so find normally doesn't take an action
-->
but be careful with this one
-->
but you can not just see the files
-->
you can directly take action on them
-->
maybe I can remove certain files which are less than
-->
certain size last accessed more than
-->
five years ago owned by a certain user
-->
I can just do this dash execute
-->
put the command and the parenthesis kind of acts
-->
like a placeholder every file
-->
which is found it's like a loop
-->
so there are other ways to expand on it
-->
that means you
-->
and if you don't want it to execute
-->
without asking you you can say dash ok
-->
ask me one by one
-->
if you trust your command close your eye
-->
no need for dash ok go
-->
you find thousand files that match this
-->
fine execute something on them
-->
copy them move them remove them whatever
-->
please be careful with these the potential for messing things up
-->
is high
-->
but the wonderful things you discover if you read
-->
the man page
-->
big man page right
-->
it's just one
-->
book
-->
hopefully that answers the query
-->
around the find and how to find what you're looking for
-->
so look for those expressions a time
-->
m time dash user
-->
all of that should do it
-->
any other question from anyone
-->
else
-->
how to get something specific done
-->
or any curiosity
-->
yes there's another
-->
I don't know if I'm mistaken
-->
there's a command called locate
-->
does it work
-->
same as
-->
find
-->
depends on the distribution that you're working on
-->
as well
-->
so I think not every distribution
-->
will have locate
-->
let me just check
-->
right now
-->
because the idea is that we might
-->
things might be a little bit faster if there is like an index
-->
of sort
-->
let me just check which distributions
-->
supported
-->
because it may not be
-->
for
-->
every distro as well
-->
as
-->
you can see here as well
-->
it's not built in as a package
-->
you'll have to install that
-->
tool again if you don't have administrative
-->
rights you may struggle to do that
-->
but if I'm not wrong
-->
I believe it's something that creates
-->
kind of an index
-->
so it runs in the background like every
-->
day I think once 24 hours
-->
and then it kind of builds an index so that is a lot faster
-->
find command is literally going through
-->
the entire file system tree
-->
so in large file systems you could be sitting there
-->
for a very long time and other tools like locate
-->
and what they do is they kind of offload this a little bit
-->
by automatically building indexes like indexing
-->
service in Windows
-->
making it a lot faster because it maintains a database
-->
of what's where with the metadata
-->
yeah so that's the reason we don't see
-->
it here it might be there on the systems that we're working on
-->
so find is literally
-->
sifting through the file system
-->
locate builds an index
-->
there are similar packages across
-->
different distributions hopefully that helps
-->
there is also something
-->
I just saw it somewhere called inodes
-->
we saw when we did the
-->
hard links
-->
inodes I think it's inodes
-->
and you
-->
here here
-->
this is the inode number the door
-->
and the room
-->
oh
-->
inode is the room number
-->
all of this sounds like mumbo jumbo right when the context is not
-->
very clear
-->
and now you're like ah so that's what it is
-->
it's just the identifier of the actual resource
-->
so what did you see when I create that link with the red file
-->
and the blue file and the pink file that they were all pointing
-->
to the same inode
-->
yes yes yes pointing to the same resource
-->
anything else
-->
any questions from anyone else?
-->
E2 winning
-->
corner
-->
E2 that I am good really sounded
-->
like the system shutting down
-->
I like the analogy of network people
-->
saying it sounds like a dial-up connection
-->
I remember back in the day
-->
when we were hooking up to service provider networks
-->
through slip before PPP
-->
you had to type in your own IP address
-->
once you dialed in
-->
you dial into the ISP and the ISP is like
-->
so what's your IP address
-->
so this is before PPP and
-->
I remember like wow the IP comes from the provider
-->
that's amazing
-->
hey I've connected quick give me the IP address
-->
that we have
-->
alright that pretty much is the end
-->
as I said small document with some of these
-->
and the deck I'll just make sure it has that on the
-->
cloud storage you can always have that
-->
as a reference hopefully now
-->
again with the mission that we had
-->
to get more comfortable with the command line
-->
hopefully we have made progress there
-->
E2 go ahead please
-->
how do you use the
-->
the no
-->
the idea is that if you are running
-->
so when you say no hang up typically the idea is
-->
if you are remotely hooked up to a system
-->
telnet SSH whatever
-->
we don't want the process to die
-->
if the shell dies
-->
and that kind of makes sense if I log out then my login
-->
shell is gone and the process
-->
that I have started is often
-->
typically you kind of do this
-->
at the end of command
-->
what that
-->
literally does is it changes the
-->
parent process of that process
-->
and the parent of that process
-->
is like maybe the inet demon basically like the core
-->
of the system so now it no longer matters
-->
if this shell that I am in dies
-->
who cares my child
-->
process will survive
-->
so typically you do this
-->
if you are doing patching or some other work
-->
I remember setting in front
-->
of a system for 6 hours
-->
making sure the terminal doesn't
-->
close till somebody showed me that
-->
but GP now there is the screen command
-->
yeah there are again
-->
see as you go from the
-->
archaic historic Unix environment
-->
the more you go towards the Linux
-->
what has fundamentally changed is all of this
-->
and now for the last
-->
10 years Unix is borrowing from Linux
-->
they are saying you know what people want these capabilities
-->
and they want these features and then
-->
some Unix if not all they have started to adopt
-->
look the fact is in the enterprise world Unix
-->
adoption is done
-->
so I noticed in your list when we started you didn't have
-->
sent us
-->
no no it's just I mean we can't list every distro
-->
out there there are thousands of them now
-->
I think new ones pop up every day and then everybody
-->
everyone has their own favorite ones and they swear by it
-->
so I have
-->
personally worked
-->
I'm not going to say on all but everything which is on
-->
the enterprise side I've worked on
-->
your Suses your Red Hat and everything else
-->
HP UX your Solaris
-->
Co all different systems
-->
in the Linux world yes new distros come up all the time
-->
you pick the one that works for you and
-->
frankly it's more of an enterprise decision
-->
yeah
-->
and then the reality is comfort
-->
of sysadmins is the last consideration
-->
if ever in choosing a platform
-->
it's the overall productivity stability
-->
how it matches the ecosystem that you currently have
-->
and in the long run what the direction
-->
your infrastructure was the long term goals of the enterprise
-->
kind of goes in there so
-->
no right no wrong it's what works
-->
obviously
-->
everyone has their own favorite I like this one
-->
so that's your
-->
no hang up
-->
anything else from anyone
-->
questions doubts thoughts
-->
you're welcome
-->
anything else from anyone before we wind up
-->
no no all good on my side
-->
I appreciate that ito thanks guys thanks for being
-->
here spending a day with me on
-->
Linux fundamentals hopefully you were a bit
-->
more comfortable on the
-->
terminal the next time you are there and
-->
more adventurous as well trying new things out
-->
thank you
-->
thank you
-->
yeah
-->
yeah
-->
it's
-->
yeah it's fun it's pretty close
-->
thank you very much
-->
yeah
-->
yeah
-->
alright see you guys take care
-->
okay
-->
yeah
-->
yeah
-->
yeah
-->
yeah
-->
yeah
-->
yeah
-->
I don't want to have a conversation
-->
a conversation
-->
with the people
-->
Runaway, Runaway, Runaway
-->
Brother
-->
Hello
-->
My brother
-->
What happened?
-->
My brother had some problem
-->
Who was he talking to?
-->
Who was he talking to?
-->
Haseed brother
-->
Where is my brother?
-->
There is a certain credit card
-->
Number of people wasting time
-->
It's just crazy on the phone
-->
Thank God I don't have WhatsApp
-->
Imagine the number of people who get your number
-->
What are you wearing in this skirt?
-->
And what's this?
-->
He might be out there in the marriage
-->
Haseed brother, it's 7pm
-->
He is wasting time
-->
He will not answer the phone
-->
He will not come
-->
I am searching for something for tomorrow
-->
I am not interested
-->
I am not interested
-->
I am not interested
-->
I am having a problem
-->
I am not interested
-->
Please
-->
Get up
-->
You haven't showered go
-->
I don't like to shower
-->
I don't know how I am going to get up
-->
I just want you to shower
-->
Don't even talk
-->
You have to say hello to our neighbor