[Music]
okay so
welcome to the linux and electronics
raspberry pi course this is the second
class um
today we're gonna be seeing and and
learning about the
linux basics this is the fun part this
is uh
the biggest uh barrier to entry to the
raspberry pi the linux operating system
so hopefully at the end of the class or
hopefully after
a two or three repetitions of this video
you're gonna you're gonna be able to to
move
around the raspberry pi ecosystem
much freely than you did before this is
what we're going to learn today is going
to be uh the differentiator
the the main differentiator between
uh what you can do on an arduino or how
you can do things on an arduino
and a raspberry pi so
first of all um let's connect remotely
to the raspberry pi
on the on the first class we saw
how to open uh we did a process of
making ssh uh available
um so we can so we can connect to the
raspberry pi because it becomes disabled
by by default
and we're going we're going to do that
today we're not going to do the
the the file process as we saw in the
last class but we're going to
we're going to do it uh a little bit
different
so these are basically the options you
have to find the ip address
on of the raspberry pi every every
device connected on the on your network
has an ip address an ip address is
basically an address where
you can find that device on the network
every every device connected to the
router has
an ip address assigned to them by the
router
and and and you have to know which one
is it to talk to them
so this is this is these are these are
basically
the the the steps the first one is you
activate the ssh on the pi so you can
connect later
um or the the vnc which is
which is what i'm going to be using for
you to see my
my connection to the raspberry pi
through my computer
uh the vnc is something like uh
teamviewer just to put that more clearly
your first option is to go to the
settings of your router
um first of all you for for in order to
go to the router
you need to know your ip address which
is we we're going to be
we're going to be looking at in a in a
bit and then
the first the first one is going to be
the router always
the whatever number you have here is
probably
100 or 10 points something something
but at the end it's going to be a number
of your computer
which or your cell phone or whichever
but note that the the ip address for the
router
almost commonly is the first one the
number one
so um there you can also do a pin
raspberry pi dot local which means that
is
a dns uh it is this is a dns server
something like
www.facebook.com which is something like
uh an address look like that looks like
an
url uh this option hasn't hasn't worked
for me
um like ever but
if maybe it's something because of my
router's configuration
the uh this is the step the step to know
which
which address uh which ip address your
computer has
so you can know which one is the routers
so you can know
how to which one is going to be the
raspberry pi's
this is a command we're going to be
using in order to look for the
for the address of the all of all the
devices that are
in the in the in the network we're going
to see that later
and this is the command for you to go to
the
to initiate a connection ssh
to your ass to your raspberry pi note
that this is not
this is not going to be this is going to
change depending on
which ip address your raspberry pi has
on your network
this is just an example this ip address
so yes a good page is this one that is
below the
in the source it's the raspberry pi
access
remote access you can find it on google
like that
so let's do that so first of all we need
to see
which which ip address we have on the
computer
so i'm going to open this is the ubuntu
that i ask you to
download you can use whichever um
[Music]
console you have in hand i like the
linux one
but you can also you use the cmd from
windows
and you can find your your computer's ip
address on the network
for example in linux even though um my
my my operating system is windows ubuntu
runs on on windows 2. so i'm going to do
the command
called uh here ifconfig let's run it
here you can see that it gave
that it gave uh an answer so depending
on
which kind of connection do you have to
the to the router
is going to is going to tell you which
uh which ap address do you have on
for example i know this is my ap address
because i'm connected to
with wi-fi to the network if you're
connected through ethernet
the cable is probably going to be around
this one
an ip address should look like this uh
either
192 168
or 10 point something or a hundred point
something
this is ipv4 which is an old standard
but there's also ipv6 which is a
which is something that we're not gonna
be touching now but it's it could be it
could look something like this
right now we're gonna be working with
ipv4
so it should look something like this
depending on your router if you are on
windows we can do this right now
we can run ipconfig
i as you can see ipv4 address you have
this one as you can see it's the same
one
as we found out on the linux uh soup
opera soup operating system
so once we know um
which ip address we have this is good
because now we have we
we of we could kind of guess the range
of where the ips are going from
and to usually the
ranges come comes uh the
these are these numbers are going to be
the ones that are going to vary between
devices
for example these are probably going to
be common on all of your network
your devices maybe for example your
phone kit could be this same number
point 90 or 0.1 or 0.2
etc it's probably not going to be 0.1 as
i said because
that's going to be the routers so
in order to know which which which uh of
which is the right the the the address
of your raspberry pi
you need to do a command which is nmap
which is a which is a linux um
firstly linux tool to map the network
that you're on
but it's not it's not only to linux
i downloaded a a tool called
send map or nmap for windows you can
download it right now
and you can and you can use this command
to find out
the network that the device is on your
network
here you can see that i put nmr sn
same as here 192.168.100
this is different from the example but
it's the same as this one it has the
same uh initiate
the same number at the beginning
this you need to put at the end um kinda
mind
mandatory this at the end means that
it's going
it's going to go through all the devices
that are on this range
this this is the address is going to
look on the all the ranges of numbers
and and and and devices that are going
to be on the network
so you can download this program and use
this one
at the beginning we're going to use the
ubuntu one but i
but uh but i i i noticed that it doesn't
work
on the on the windows subsystem
you can also do this program the send
map is really
is really light so you can download it
right now and it's probably going
and you're probably going to do it with
me so
again i'm going to put the the program
i'm going to hit scan
it's going to ask me if for permission
of the administrator kind
and then i'm going to see every device
that i have on my network
here as you can see i can see the
raspberry pi foundation
note that if you use this command and
you're on a linux computer
you maybe need to use a sudo
which is right really like this at the
beginning of the comment because
it's going to tell you all the all the
addresses but it's not going to tell you
the the host names
this is the hostname of the raspberry pi
that comes um
from out of the box so as i can see this
is the
this is the the address for the
raspberry pi
um now i can do i can
use ssh or vnc to
to connect to the raspberry pi vnc
is a program that i'm going to be using
vnc viewer
for this for use this and or for use the
this ssh you need to ability
the the option on the raspberry pi from
the from the visual side
or with the with the file in ssh
that we did in the last class so i'm
going to connect through ssh
here on ubuntu while you guys maybe are
downloading
vnc viewer and sendmap
so i'm going to hit ssh pi
at let's copy the
the ip address that we know that is from
the raspberry pi
and here so let's let's say
the the parts of the structure of this
command this is the command this is the
one that makes the
thing secure it's making a secure
connection
it's secure chill chalice as we said in
the last class
is where you can the interpreter of
commands from linux
this is the the uh the user that we're
gonna be locked
on so if if we wanna locked on root
we can do something wait not like this
but like this and any other user that
you may have
we're gonna use pi on this one at
this means where where where the address
is
and you put the ip address if i do enter
wait here sweet
let's see if if it's going to let me
meanwhile
let's do this over here
to see if dnc is going to work
oh it changes it it changed i'm going to
use now this ip that's probably why it
was failing
okay so it's 1a
okay this is the error that gives
usually when it's not the same ip
address or it's not or is not
uh um enabled the ssh
connection refuse i'm going to use this
one
it is
by the computer i'm going to look in the
on the raspberry pi that i have to see
if there's any issues
things like this can happen guys
so don't worry too much if something
like this is not
it's not working right now for example
this is a very good example that is
happening to me
so i can teach so i can tell you guys
what to do in this case
okay i can see that now it's at 196.
from my raspberry pi i can see that too
okay there you go now i can now i can
have the connection it's asking me for
the password
of the pi user
is here this one i'm going to use the
the the password that comes out of the
box which is raspberry
on on my newscaps so here
i'm right now i'm locked on i can i can
i can i can do commands right now
and i can see whatever is on my on my on
my home
uh we're going to discuss commands in a
bit so let's do this also with the with
the vnc
so you can so you can see also what i'm
what i'm talking about
well about this one
oh wait um i forgot this was it is
96. let's do this one
okay so it's going to warn me i'm going
to click continue
it's going to ask me for the username
and the and and uh
and the password as i said raspberry
here is this is the the
the the password that comes out of the
box
hit okay and now i can see like it was
like it is team viewer
from my computer so this is where i'm
going to be
showing you whatever i do on the
raspberry pi and the gui
um let's show you first how to
um how to enable the
how to enable the ssh from the gui
i i i told you in the last class how to
do with a file
here you can do it on interfaces
and for vcn the teamviewer like
program and for ssh it's over here
you click they come disable by default
and you click enable
and also okay um remember this com
this how you configure this because
we're gonna use this
on the next classes when we're talking
about serial ports like i score c
okay so there's a couple of a few
options but we
we're not gonna see them right now
[Music]
okay so right now as you can see i can
see the
my screen the my my raspberry pi screen
and i also can be
on the on the on the on the co
on the console too here i'm connected
both ways this is um this is possible
because
each time you create a set you you can
be
there there can be many sessions on the
on linux so if i can
open a command line here and i can have
them both
working for example i'm i'm here on the
raspberry on the pi
raspberry pi and i'm also over here
also on the pi raspberry pi that's
i'm just letting you know that that's
possible
so once we got that out
and you got this figured out um
we can go through and see the other
things
okay so again if you if you're having
any trouble a good guy is the raspberry
pi one
um let's move this over here i've the
raspberry pi guy
um you can search raspberry pi remote
access on google
s and it's and it's really clear and and
you can see that
i i took i took um inspiration from that
to use to make this
if you're having any trouble learning
step uh
a google a google search can can can can
can really can really help these are
problems that are really common
so no note that many people have
had any problem on these steps so you
can find there too
again you enable ssh if you want to
connect directly to
ssh you either modify the interfaces
on on the configuration that we saw over
here
wait um our last connection right here
let's do that again
let's do that
okay probably change the ip again
that that usually doesn't happen okay
that's probably an
issue unless me the ratio that i'm
having right now so
um you activate the ssh either through
the gui
or through the file that we saw last
last week um
you do you find the routers
and you can do it through the menus of
the router of your battery it this is
this step is is only going to be
possible if you know your router's um
model
you can find the model physically on
your on your on your on your router
and you can find the the stock
configurations
there are probably instructions online
on how to access your router so you find
the model
you find you use google and then you go
there
you can also pin raspberry pi dot local
local
uh you can do that and it's going to
tell you which is the ip address of the
raspberry pi directly
you can do this from the web uh
from the ubuntu program of subsystem
from on your windows computer or you can
do it from the
command line on mac or or
linux you can use these these comments
on windows and linux to
to find uh to find which is your ip
and then you can use that and put in a
zero at the end
so you can do a a full scan of your
network
um you do you do an ssh
to your to raspberry pi or you do a vnc
using vnc viewer
which is something that is that that it
comes stuck under on the raspberry pi
so let's go let's let's go next basic
commands
uh this is something i'm fun that i'm
that i'm going to put i'm going to be
putting fun stuff
around here so you can so you can see uh
you
you're going to understand ironically
you're going to understand these these
messages at the end of the class
sorry today this class dxc
let's run a basic a couple of basic
commands let's
let's connect again let's see if i have
still have connection no i don't have
connection
okay let's see a second
i'm doing now another another another a
scan just in case
one eight i'm going to do an ssh
oh
connection refuse
1.99
i'm going to see if i have any issues
from my raspberry pi this is something
that is just
probably happening to me you shouldn't
have any trouble
even when when i was preparing this
class um
i wasn't having any issues
right now as it always happened let's go
it goes
okay 1896.
let me check if i disabled by mistake
the ssh
okay yeah i'm going to reboot my
raspberry pi okay
um so these are going to be the basics
common that you see on the screen
are going to be the basic comments that
we're going to see right now after after
that we're going to see the comment
structure
uh the command structure so you
understand what are you doing
and which part is it so you can know
when when you're going to look
for in on the internet up questions
about
each or if you need a command specific
if you specifically
for something you know uh the lingo
so there my raspberry pi is rebooting
password
i have my raspberry pi um right side
right by my side with a
with a keyboard and a screen just in
case something like this happened
glad that i did this
96 is saying me it's telling me that i
have 96
196 so let's try
yes okay so let's do it over here
okay there you go so we're gonna use the
commands
let me put this over here so you can see
all the commands where we're doing them
here
hopefully you can see let me see if i
can
okay apparently i cannot i cannot um
hopefully it's it looks well um if not
i'm going to
i'm probably going to use this let me
let me see okay i can see it i can use
this
okay again doing this over from the
anywhere in the world you can use this
anywhere in the world
or doing it from the oops
or doing it from the from the vnc like
or
directly on the raspberry pi shouldn't
be any difference between doing these
comments that we're gonna see
that we're gonna look uh in this class
um there are some commands that are that
are not gonna run if a gui
the the process x11 is not initiated
but those are very very very uh advanced
commands
so just letting you know that this
basics command and the ones that we're
going to be
using today shouldn't be a problem to
run in any
cssh connection anywhere in the world
here from my ubuntu subsystem computer
on windows
or on vnc using the the uh
the the comma the command line directly
from the raspberry pi
so let's do it over here so man
man this is going to be your first um
your first
uh command that you're gonna learn this
is good because this is
this is stand for manual so i'm going to
do amendment
which means i'm going to see the manual
from the manual and interface to the
online reference manuals
this is going to to tell you um
a little bit it has many parts so let's
start with the name
which is the demand diagnosis which is
how how are they
are they are they reading to
description and so forth and so on
so whenever you don't know what a
command
does or i also use also use it for
for to see if i have a command a command
or a program
installed uh i
use man and x program or tool or command
these are base you can use it kind of
interchangeably when you're talking
about the command line because a tool uh
it's it's uh you can use it
and you can use it as a command and a
command can be used as a tool and
program
etc so i'm going to do man ls
it's going to give me the manual for the
ls or list
directory content here you can see that
if i if i use the
oops if i use the
the the keys on my keyboard again i can
go around
and if i have if i have to quit the
manual i can press q so
let's go uh through the commands because
uh
i can see that we already have halfway
through the class
ls is a command so you can list the
the the things that are in your
directory your current directory
which is where you are right now or your
current folder
folder from windows is known as a
directory on linux
cd is a command to go into a directory
so
for example if i wanted to go to
documents i go i
write cd documents
press enter and now you can see that it
changes over here and it says
where i am right now this
sign we're going we're going to see it
i'm going to explain it in in a few
uh slides later
is to move um files
from directories from directories to
another directory so let's do
let's go back
and i'm going to move
errors
to documents
oh um probably because i made errors
with
with uh with with that with another kind
of permissions we're gonna see that tool
in this class
let's example dot txt i'm going to
explain
what dodge does in a bit i just want to
prove
what nv example
documents
oh
okay let's see what kind of permissions
does that have
okay so we can use we can do
we can do uh we can use move i don't
know
why it's not working on my computer
right now but we cannot we can also use
move to
change the name of a file so you can use
error
txt move error txt no
let's use example example txt
to example exam dot txt
when to ls you can see that it moved to
to here um i changed the name using the
move command
cp isn't is to copy cp
exam txt to uh
example tsc so when i do a ls i list the
commands
i have errors example txt2
so um echo
it's just shadows whatever you say in
the console
so echo one
is going to give you back a one
touch is the comment that i just use so
touch is used to make a file literally
you can make a file
i can call them a test
here test touch
i can do it with an extension or without
the extension
and you can use this
okay so you can use it you can use it to
create
files
okay so as you can see i'm going to
throw an ls
um so you can see example exam etc
um let's go to mkdir mkdir is good to
make f my make directory so i'm going to
make a folder
the slash directory i'm going to make
example directory
and to read whatever i have
on any of my txts
um i can use cap so
cat error txt
right now oh wait cat
errors dxe okay this is what it is
written on this file
um so history history is a command
to see which art which commands have you
thrown before that
and and if they have numbers
uh because of a reason you can
if you have a command that you want to
repeat for maybe it's more complicated
than these ones
you can you can do them again for
example let's let's repeat
this command the five three
one five three as you can see
it repeated the command and it repeated
the the answer
um mram is for deleting
so let's delete the errors file if if
it's going to let me
we don't have any anymore here and now
it's not here
um so yeah so far hopefully we're good
you can see if you have any any
questions about how to do any any of
these comments
you can throw them uh on the q a or on
the on the i o page
you can this pro this ram works on files
if you want to delete a directory you
need to put something called flag
which is we're gonna be look uh
oh okay first we're going to we're going
to see how to manage
managing the terminal there there's
there's a couple of things
that you need to know for example right
now i have the commands that i've thrown
i can do a command called clear and it
and it deletes everything that i have on
my on my
on my screen on the command line if you
have if you want to auto complete
for example cd to enter a directory
you go cd docu and then you press tab
and it's going automatically um auto
completed
this is really good because sometimes
you want to go inside of a folder then
inside of a folder and then you just
press the first few letters uh notice
that
this the command line is case sensitive
this is very important this is why many
programs do the same
or the many things from linux uh from
the
from the file system are doesn't have
caps
so yeah uh we already saw the how to the
command
so cd
as you can see if i do an ls flag
la i'm going to see everything listed
this
this is l means for for list
so it's going to throw it on a
as a list output as you can see
not only are the program that the files
that directories and that we already saw
like documents and the files that we
created from example
to exam we also have these two
directories
dot dot and dot dot means
here in linux and dot dot means
the directory from before which is the
pattern of the of of this folder
if you go if we go for example let's do
a clear
if we go cd downloads
we are on downloads right now right as
you can see here
if we want to go back we do cd dot dot
and then we go to the parent one which
is this one
um you can throw commands uh
with that semicolon in the middle so
they can they can do uh they can run
separately
for example echo one semicolon
echo
two and the n is going to run
on order first firstly the first one and
secondly the second one
and the last one means it means this
this means where you are right now which
directory you're right now
there's a pro there's a a a command
program called pwd which is going to
tell you where you are right now
if i do it it's going to tell you home
pi this means home
so if you are on cd um
documents
let's see if i have okay let's do that
um
cd
okay now we are two directories in
what about if one go back directly into
the home
and now do the cd dot dot couple times
we do cd and define and uh
and the home signal and you're going
straight to home
pwd is a command and also a a
global variable which means that you can
call the
global variable called pwd
or echo
pwd which is going to tell you
what the variable contains which is the
direction we are
in right now the path
hopefully everything is being is being
clear so far
and we have okay we have more people
right now so
the structure of the command usually
you'll have one command
then a couple or a single flag which is
uh
separated from one uh line or
or yeah a line or two
depending on what type of flags are you
going to be using
for example if i if i do man
ls you can see that
you can use a or slash sl or
or barbar all which are basically the
same
you can do ls a ls
oh i use
you can also to clean that your your
your
your command line you can use ctrl l
just for you to know this is
a handy uh trick so i like
the the the benefit or of using this
type of
uh flags is that you can you can
stack them for example ls
a l which means all meaning that there
are
files that are probably hidden that are
not showing if you're only using
l you can see there's no any hidden
files
but once you use ls al
then the one with the points means they
are hidden
from the from any normal search and now
you can see them because i
i i said you need to show them all and
list them
so so
here also are the targets or the
arguments
which means what the what
the command is going to apply to if i'm
going to do an ls
uh dev def or at efc
let's do this right now
that slash
yet c okay
right now you can see that they it gave
me
the both answers here from etc
here downwards and here for
death done everything
is here let me clean my thing
okay there you go so this is the basic
structure of a coma
now some medium commands pwd we already
saw it
which it tells us where we are right now
this home
pi for the the user pi and this
are the same so you can say cd
home pi or cd
and it's probably going to take you the
same the same the same route
uh grab is a favorite a favorite comment
of mine if we're gonna know if this is
for
like um searching things
from a command for example let's
use history again
i want to find the time that i used uh
the
clear command or no the touch command
to see this i'm going to use ls
no history use pipe
i'm going to explain what a pipe is
later but
bear with me on this one you scrap
and then put the keyword that we're
going to be looking for
in this case touch and it's going to
give me as a result
not the long answer from the full common
history
but the instances where the
the query or the keyword that we put is
is presented on the output from this
command
so here it even says the number the
number
it gave me the whole line this is
something that that linux does which is
really good
um so yes if i want to repeat any
command i can just do
uh again the exclamation point
and the number let's do um
148. oh no
148 46 i'm sorry
okay so i just created an example txt on
the desktop
okay this was my by mistake but uh it is
good because we don't have an example
txt there we can see it over here
example
tx over here there you go
so if you want to go home we do this or
home
pi now we're home again
you understand this better once we have
we we get to the point of the
file hierarchy which you're gonna know
what the
the the the memory or the the hard disk
or the operating system files are
organized
are organized i mean head and tail which
are it's going to tell me the beginning
or or the end of a program of the
of a file for example let's go to
desktop which i have a couple of
programs let's do cad which is for
reading a file which we didn't use
before actually
and let's do this and it's going to tell
me what is
on this program okay
so what if i just as you can see it's
filled my
my full screen my my my entire common
line screen
and i just want to see the beginning so
i can do head
um bluetooth and you know
only going to show me the few lines in
the beginning you can use some flags
to to um
to say how many lines do you want to see
and also tail which is going to show you
that the end of it
here this is the end
of the file
top which is something like the program
uh
the control center from for windows
which it tells you the amount of
um amount of processing power
which programs are using it who is using
this
this this or activated this program the
time that is running on et cetera et
cetera et etcetera
uh and get it this is not a program that
we have on
on on raspberry pi but it's on the
window on the
subsystem of linux which is like an
editor like a notepad i think we have
nano
yeah we have nano so we can do nano uh
uh test test file
file txt or no no we created a file
called example right yeah example so
let's edit that
that file notice that i did an ls
to know where i am or which files i have
there and
i did a tab to auto complete the name of
the program
or the argument that nano is taking it
hit enter
let me see if we take it
okay i don't think it's taking it
okay so let's let's try it again if not
we're going to use another
example okay there you go
so now i can write something echo
one um echo hello
hello now we're gonna we're going to
save it
this is for saving this
x um yes i'm going i want to save it
then
enter and then it should be saved how do
we know
that we wrote that we wrote i use the
command cat to read it
here here it is
so yes let's continue
with more commands kill command
let's do these couple ones so if we go
to the vnc
let's use this one right now as you can
see i have another terminal
over here let me open a program called
on yeah let's use genie i want to kill
that program
but from the common line
what do i do first of all i use stop
to see where the program is
let's see if i have it or here
again we know it's called genie we're
going to look for
it here
as you can see it's moving so what i can
do
is doing the grep command to to get that
line
once taken so i can do top
do the pipe then do grab and then do
search search for genie
if it's not on the first page it's
probably going to take a while what i
like to do
is click on the program so it goes up on
usage
and it shows then i go back i cancel
and then as you can see i have here i
have what i need which is the pid
this is needed for the for the kill
command so i can do
kill 12 42
[Music]
and there i killed the process that i
was running genie on
awk i'm not going to give you an example
because aki's also is so complex that is
um it can be easy there's
what i mean is you can go really complex
this is for word or or or or searches
for example if you want to have this
line but you don't need
uh the 20 the oh you only need the the
num the pid which is the process id
the who is running the user and the
command
there's a there's there's a way you can
do this command so it can gives you
these three this th only these
three uh values just as a result from
the from from their command
so know that sudo is something that
you've probably seen if you ever touch a
raspberry pi um it's a program that
makes you uh temporarily
have um have root
access and sue is is for changing the
user
so if if i want to create something like
um let's do sudo
let me do an ls which we should have an
example txt
so let's do a touch a
so we can know it's a different one txt
so if we do ls a l
and we look for the examples one
uh here there you go so when we created
the touch
the the the user that run it which is a
yeah those are the users and the group
the
user that created it was pi because i
was just using touch and it was running
here
but once i did the pseudo with the
example surah
it became from the root so it gave
it gave them permission from from the
root and it gave
and and is it and and it's signed like
it was
created by the rule is that is that
is the most powerful user that comes
from
by default on the linux operating system
if you want to change the user to
users you need to use this command
called su
for example we're going to use it right
now to change to root
i have it set it up so you can so
i have the same uh raspberry pi password
that we use on pi
for root so here now i'm on root
and i'm on the home pi okay
we can change back just use cu by
and there you go back so this is for
changing user on the command line
tar and and and unzip
are used to compress and uncompress uh
files
but due to time we're not gonna see them
right now
shmod and essay shown sh group
these are for changing this the the
permissions we
are gonna be seeing in a while the owner
and the group
these two we're not gonna be seeing it
right now but maybe if you go deep into
raspberry pi we you're probably gonna
use these ones
this is really good or you need to know
this because the
that's this is this is what makes uh
security
uh on on the raspberry pi this is this
is what com
uh it makes it it makes it uh powerful
so you can change who is going to access
you can create a user
make a file or a program the that user
to be the owner and only that
process or user is going to be able to
run that program
that's powerful so and that's that's why
uh this this is one of the reasons linux
is
very much used on for for for server
purposes
everything is a file so um
everything is a file something that
comes from unix uh this is something
that if if you have your raspberry pi
turn on right now i want you to do with
me
first of all uh if you need to check if
you
if you uh if this program the zoo
that to change the route is is giving
you trouble use this command
sudo pass pass pass wd root
this is giving you the the the root
access temporarily
this is a command to change the
the the password of an user and this is
the user that you're changing it to
you can also do this with the pi if you
want to
just but probably you don't need the
pseudo at the beginning you can try it
out
but now we're going to change at the
state of the
led that is on board on the raspberry pi
and we're going to do it
right now i'm not going to be able to
show you
because i don't have a the camera that's
set up so i can see the raspberry pi but
if you do the example with me you're
going to notice that the
the led on board not the one you bought
on the kit
but on board is going to turn on and off
so i'm going to do
the echo one which means we're going to
throw one
we're going to do this symbol which i'm
going to explain what it does
in a bit class
leds
led zero
brightness
okay so yeah i forgot to change the user
here now i'm root i'm going to copy this
here oops
here now it should it should be on as i
have it on mine
if you wanted to turn it off
you can just delete this and put on zero
and you can try this
so you can so you can be able to to
change the
the the the state of the led
um these are a couple of examples
um def new
dev random dev0 these are some files
that are on the on the linux operating
system
which for example if i move anything to
know it's going to
delete you may see this joke
let's change the user that we're on
okay so let's let me delete the example
txt file that we did
let me move the example example
to that i need to put the bar first
def no
okay so let me do a suit up in the
beginning
there you go so if i do an ls
there's no example txt on this on
on this directory right now def random
and you random are a stream of files
of bytes which is uh depending on your
computer
operating system and so forth uh fourth
it it there is a constant streaming of
random numbers of
pseudo random numbers generated from
them
i suggest you not to do something like
echo um
or eck or cat
for example def random
um tx uh something file txt
i'm not i don't suggest you to do that
because if you hit enter
your cpu usage going from the raspberry
pi is going to go
on like way up and it's going to write
on that file
until your whole um
operating system fails because it's
going to be filled so
this is how powerful linux is you need
to be very careful
whenever you use these three um
uh these three uh fight the stream of
bytes
and also be careful when using sudo this
is a command if you want to
if you want to uh test
um creating a little a little file
by with with random numbers
uh also this is zero it just has many
if you want to fill something or delete
or for example if you want to
um format a disk
you can use this to to to as a stream of
bytes of zeros
to change everything to zeroes this
something
uh a little bit advanced so just i'm
just letting you know this okay let's
talk about permissions
yes uh you're gonna understand this
later shmod
x ask questions dot pi
so permissions as you notice
every time we did an ls l
things appear like this so
it's going to tell you that the total
file size
is going to tell you the permissions for
example for these files is give you the
permissions
the group name the user
the number of our links the size
and the date time or last modifier and
the file name
we're going to see what what what it
where this
number uh letters down the beginning
this is going to to show you what type
of file it is
this is on the next slide so let's go
through to to this part
these are going to tell you which
permissions have
the owner the group
and the other users if you want someone
for example a txt create let's create
let's
touch nobody
watch dot txt
oh it's fine like that and i'm going to
do one
ls lsl
you can see that everybody can read it
right now
not only can write it the owner
here and nobody can execute it
if this was a program we need someone to
be able to execute it
so uh a uh a command
that we're gonna be using when we're
doing if uh
what we're doing um uh
by scripts or scripts with python it's
going to be
chmod which we saw plus x which is going
to be which is going to give
everyone the owner the group
and the other users permission to
execute this file
nobody watch so when we do an slsl
and we can see that here you have an
an execute permission for the
for the owner the group and the other
users
this is something a little bit more
advanced when you're doing a command you
can also specify
for example hmod you're going to specify
how are you going to give uh
with numbers the next precise
um files permissions so if you want to
give
everyone the owner the group and the
others
every single permission that there is
you go
here and you can see every single
permission is one one one
which is the air the read the right and
the execute
which is seven so if you wanna just to
to to uh to let the owner
to execute dread and right you'd run a
seven
and then a zero and then a zero because
the group and the others are not gonna
be able to see it let's do this
right now um
seven zero zero uh nobody watch
so we do an ls l
here we change the permissions of this
file
if anybody if if this raspberry pi has
more users
the only the pi user can be able to
execute
touch or
i mean read write or execute this file
which is really cool this is
some types of files as we saw uh back
the b c these are these are they are
these are rare you're not gonna see them
frequently you're gonna see directory
and they're probably file symbolic link
and those are basically it and the under
on the under on the right and the
line those are the ones that you're
going to see
mostly so piping and one-liners
this is uh
how you can pass we use this already
with the crap
command i'm going to explain well i'm
going to be explaining what i did piping
is
used uh uh for this we know we we should
know the tip that
the three types of stream of bytes that
you have on the command line
which the std in the standard input is
cd out
which is a standard output and the std
error
which is the standard error these are
these are are
signified by a number zero one two
destiny in we can test this right now as
we saw
is uh we're going to create let's see uh
nano text dot txt
or no let's we don't need to use this
for example if we want to write
something let's just write um
echo is a couple of
i use i use this uh these symbols to
to to confine whatever i'm going to uh
transfer to the to the
text file precise this precisely if i'm
going
and more specifically if i'm writing a
whole sentence
so hello people of the second class
so i'm going to use this sign in order
for me to
to pipe this
command to here
wait okay there you go
so we use cut text you can see that this
the the file contains what i just gave
i'm going to explain
this this symbol in a bit so
um let's do this command which is cat
txt text dot txt
file crap hello
we now are reading this file
right and instead of putting it here
we're going to put this output through
the pipe
and give it as a standard input for the
grab
command grab hello
and it's going to give you wait
here it's going to tell you which is the
line that has the word hello
we could have used web hello
text and this result would have been the
same
but for example if you're doing fine
searches
you can do uh you can do you can do
whole comments
like very big ones and then just
looking for something specific this is
why a standard variable sounder output
are are good to know std out
which is a standard output is uh there's
a uh
typo um an std output is something like
for example
let's do an ls minus l and instead of
putting it on the screen like i said
you can put list of files
dot txt and if we do cut
it off files it's going to give me what
the result of
l when i run this command was so
um this is not executing this command
i'm executing the command and and and
pipe
and and transferring that standard
output to this file
um yes a standard output you d you can
use the pipe example to the standard
output because
whatever is going through here the
standard output of this command
goes to the standard input of this one
this is just putting it in here on on
this on this file
but this is the standard output from
this command is going to the standard
input for this command
you can also see you can also say that
here when i do
when i did this command grab hello the
text this was the standard input for
example this was the input
so the standard error is when you do an
error uh
for example if you want to know if a
command fail and you want to know why
and you don't you're not around to for
for example something that is executed
on the background
you're gonna do um let me do ls
to list a file to list that where i am
grab oh no which is which are not
real um flags this this is on purpose
death
uh this this is to pipe the standard
error to
a file for example error errors
errors txt so there you go
now i should open
and there's not anything there wait
okay apparently it didn't have any
errors but it should
okay there you go now i can see that
there's
there are errors and then telling you
this for example i did i didn't use the
flags correctly or i didn't put any
arguments
okay
lastly we're going to look at the file
the file system hierarchy which is
um what uh what is
how is how's the file system on the on
the linux linux computer
is organized as you can see this is the
path this is similar to windows
so this is a good image i don't know
where i
where it comes from i i got it on the
internet and i tried to find the source
but i didn't find it
but this is a good image
every program that we've been running
it's come it comes from the
by bin uh essential binaries um
file i mean directory all the programs
are there for example ls
cad aura and bin
we can do an ls slash bin
and we're going to be able to find all
the programs that we can do for example
here
is move and probably if we look here ls
so
there there's where it is all the
programs
the basic essential binaries the ones
that are essential for linux
there's some more files boot etc
so on uh this i'm going to show you a
couple of cool ones for example
tmp which if you want to put a a
a a file but you don't want people to
know
what you've been reading there you can
put there because every time
the raspberry pi or the linux uh
whatever linux you're using
is uh re rebooted
it's going to delete every every file
that is going to be there
def is where all the device files are
let's def as you can see
here there's memories um
these are instances of programs running
in the background
for example this instance is running i
don't know
which one is it but this one uh
there's one this is one of the process
that is running the the command line
that i'm using right now
and for example if you put if you have a
camera on this you can see
you're probably going to be able to see
it here
as a device
um there are many more
and and i could spend a day is
explaining uh
how this is this is organized but just
to know
this is the beginning of everything for
example uh
let's do a pw pwd
the bar is the beginning is is the root
that's that's what we mean by the rule
every time we talk about analytics
so this is a little a little bonus this
is bad scripting this is
we every comment that we saw before
we're going to see how
we can do a simple bash script just to
let you know how to do them
and we're going to be touching them in
the next class
uh bigger than this or or
on more or more um
so let's do a simple program right you
either
can do touch
touch uh sh as
a script sh you can either
do this to create the the file or you
can use
nano script
dot sh i'm going to use nano because
it's actually going to
directly open the the text editor called
nano
and we're going to put exactly the
beginning which is
which means this means which
program is going to run this
program on or which channel for example
if you ever want to
run a python program you can either use
you can put for example something like
this something like being
python3 just for you to understand
what are we doing we're going to put
bash because that's the shell that we're
going to be using
or this program is it be running on
and i'm going to put what the program is
going to be a simple hello world
i'm going to click exit i'm going to say
yes here at the at the bottom it says
click y for yes and no n for no
and then click enter so
right now you have two two ways of of
running it either the bash script
and it runs here is echo hello world if
we do an outside
you're gonna you're gonna see
here there you go this i i'm replicating
or run the program that has the the
command inside
or do the command outside or i can do
what we're probably going to be doing
and we also i'm going to be
uh focusing on the next class is giving
this permission to run
for example ssh mod x
script and now if we look for
less script
here you can see that
script has every permission to run which
means that i can do
dot which means here slash
script and it should run so
this is something that that that that
y'all i want you to test because next
next week we're going to be touching on
more detail we're going to be doing
python programs and we're going to be
doing bash scripting
uh i'm going to give you the basics so
you know how to how to handle
uh you and and we also be we are we're
also going to be
teaching the a couple of tools from
linux which
are going to let you to run programs uh
from time to time
this has been this class for today so
i'm going to check if you have
any questions right now