Hello and welcome to Command Line.
This is Linux file commands Part
two, I'm Christopher Handler.
And let's begin
with learning objectives for this
video. You're going to learn to
touch command, understand the chmod
command, understand the choke
command as well.
And these are very important in
order to execute files on your
Linux machines and change
these permissions, in order to keep
them secure as well
as reassessment, you need to execute
a file but lack the permissions
which mods which will allow you
to execute this file.
Is it A plus W,
B, minus W, C,
plus or minus
X,
and the answer is C
plus X..
This is the execute bit in order
to execute a file,
the W and
the minus W, what that
does is it is the right permission,
not the execute permission
and the minus X permission
takes away the
execute permission for a file
we want to add in order to be able
to execute it.
All right. So first is the touch.
Come in. Now what this does is
we can use it in order to update the
files modification time in
our Linux Shell and it
can also be used to create files as
well. So this is a useful command
if you need to create a file or kind
of update something in
the file modification, time for a
specific file.
So it's good to have in your arsenal
when you need it.
So let's go ahead.
Pull up my legs machine.
I'm going to
show all of these files inside of
this folder.
And if we take a look, we can see
we have the my program file.
And it was last
August, thirty first at fourteen
fifty five.
So let's say I want to touch
my program.
That way we can update the
timestamps and
I'm going to use up Arrow twice
if I can get back to the Elvis to
come in and
check it out. Now we have it updated
and it is September 14th
at thirteen fifty two.
So this is a good way to
update
the timestamps on the file.
Now we can also use this to create a
new file. So let's say touch
new dot file
and we're going to do this
again.
And as you can see, we have our new
dot file with nothing in it
because there is nothing in
there. We were just touching it to
create the file.
So this is useful to be able to know
and we'll be able to use it to
manipulate new things in the show.
Now we have the Linux file
permissions.
If you're not aware with it, I
highly recommend looking up on your
own. And this is just a very quick
refresher.
So we have the file bits that you
see done a long listing.
The art of doing the X are the read,
write and execute bits for
these specific files and the
permission classes should the user
group and then the other in that
order.
So these
also get
you can use the numeric mode, the
octal mode in the bottom
right here, where it'll show
the bits from each of these
symbolic modes for the read,
write and execute into this
format.
And when you use the HTML command,
you can use the symbolic mode or
the numeric mode, whatever's easier
for you.
So it's important to keep in mind
while looking at files, we can
understand exactly who has access
to them and what
we need to do when we're
manipulating these files.
So the chmod command, this changes
the file mode bit.
So like we were learning about with
the Linux permissions, if we need to
be able to execute a file, we
need to have that execute
permission.
So with the symbolic mode, we can
use the RWA as we just
learned. We can also use the auto
mode to change all of the
file bits as well.
And you need to have the
ownership permission of the
ownership of the file in order to
change the permissions.
And if you don't have ownership,
you can usually do this with route,
with the pseudo command as well.
So that's important to keep in mind.
Now, let me give you a demonstration.
So I have this my program file.
This is a program I wrote very
quickly, spits out some text.
So in order to run a Linux
program, when I use the dart forward
slash and my
program
and as you can see, permission is
denied.
And if we look over here, we
can see that nobody has
execute permission for
this program.
So makes sense why we
have the permission denied because
we don't have that permission to
execute.
So I'm going to type CHMOD plus
X and
my program.
And now let's do another long
listing. And as you can see, the
my program is green that two, which
means that I can execute it.
We have this execute permission now.
So if I do the forward slide.
Doug Ford slashed my program,
you can see that my program ran
properly, so this is
how we know that we
were able to change the permissions
and execute it properly.
And we have the chown comen.
This is to change the file
ownership.
So let's say we want
to change the final ownership to
root for the program.
We can do chown root and
then the final.
We can also change the group
ownership as well.
So we can do route colon
group and the
the group is always
after the colon, so it will change
the group ownership for that file
as well.
And it's useful to keep in mind,
just like the the chmod command,
it may require permissions for what
you need to do.
So let's do a quick demonstration.
Let's say I want to change this to
root for the my program.
And now let's do another long
listing.
And as you can see, the owner
is root for my
program now.
So that can be useful if you need to
change ownership.
Files are
a post assessment which
can be used to create files.
Is it A, Joan, B,
chmod, C touch
or D or him.
The answer is C touch.
Like we learned the touch command.
We can create files or
just go ahead and change the
last modified time for the files
as well.
The home command and the command
commander used to change permissions
and ownership of files,
not to create files.
The R.M. Command will remove
files, not create them.
Right. So in this video we learn to
touch command, understood that
Chamar Command, understood that
the Chelm command and I hope to
see you in the next video.