WEBVTT

00:00.690 --> 00:05.340
If you're going to have a modern operating system today you're going to have to have a file and folder

00:05.340 --> 00:06.140
permissions.

00:06.270 --> 00:09.110
And certainly Linux is no exception to that rule.

00:09.300 --> 00:15.360
So in this episode what I want to do is go through linux file and folder permissions and then show you

00:15.360 --> 00:16.910
how we can edit those.

00:16.920 --> 00:22.510
So the best way to get started with this is to die than go into a particular folder and just type LS

00:22.530 --> 00:24.930
minus L.

00:25.040 --> 00:31.250
So if you take a look here on the far left hand side we see all these letters and dashes and that's

00:31.250 --> 00:34.850
really where all the file permission magic takes place.

00:35.120 --> 00:40.550
As you look at this on the far left hand side you're going to see one that has the letter D.

00:40.550 --> 00:43.790
That means it's a directory so that very first value.

00:43.790 --> 00:48.800
I just want you to just ignore it for this episode that's just used to separate files from directories

00:48.800 --> 00:50.590
from links and other stuff like that.

00:50.600 --> 00:54.150
What's important are the next nine values.

00:54.200 --> 01:00.050
So if you take a look here you're going to see individual files have ours and W's and X's and dashes

01:00.050 --> 01:02.910
in different places depending on what's happening here.

01:02.930 --> 01:05.270
Those are the file and folder permissions.

01:05.270 --> 01:09.490
Now to get started on this I want to explain to you how they're organized.

01:09.530 --> 01:13.700
And I'm going to have to wait just a minute then I'm going to tell you what our you x means so bear

01:13.700 --> 01:15.210
with me.

01:15.590 --> 01:18.550
You have three groups of these R.W. exes.

01:18.590 --> 01:24.260
So if we zero in for example down in this bottom five right here called Run me you'll see I have r w

01:24.260 --> 01:26.750
x R W x R W x.

01:26.750 --> 01:32.120
What you're looking at here are three different permissions depending on the entity that you want to

01:32.120 --> 01:33.710
apply permissions to.

01:33.980 --> 01:39.320
The first three values are the permissions that are applied to the creator owner whoever created that

01:39.320 --> 01:44.030
file whoever created that directory usually has very powerful permissions on it.

01:44.090 --> 01:47.390
And that's what the creator owner can do.

01:47.390 --> 01:54.860
The second set in the middle there is for the group every file and folder in a Linux system belongs

01:54.860 --> 01:58.610
to a group and other users can be in that group.

01:58.730 --> 02:03.740
And you can define the permissions for everybody in that group for that particular file or folder simply

02:03.740 --> 02:07.110
by editing those three letters right there.

02:07.700 --> 02:13.730
Now if you're not the creator owner and if you're not in the group well then what permissions do you

02:13.730 --> 02:14.170
get.

02:14.240 --> 02:16.220
And that's what that third set is for.

02:16.220 --> 02:19.940
The third set defines permissions for everybody else.

02:19.940 --> 02:23.670
The rest of the world the universe whatever you might want to look at that as.

02:23.780 --> 02:28.060
So we break it up into these three very distinct groups.

02:28.420 --> 02:31.180
OK now let's go back in.

02:31.220 --> 02:38.180
Except this time I want to take a moment and talk about what exactly are and W and X mean it's going

02:38.180 --> 02:43.040
to vary depending on whether these permissions are applied to a file or to a directory.

02:43.280 --> 02:49.730
R stands for read a readable permission allows the contents of a file to be viewed in other words you

02:49.730 --> 02:57.440
can open a file read permission on a directory allows you to list the contents of that directory right.

02:57.440 --> 03:04.040
Permission allows you to modify the contents of a file but the right permission for a directory allows

03:04.040 --> 03:08.480
you to edit the contents of that directory which is a nice way of saying you can add or delete files

03:08.480 --> 03:10.450
from that particular directory.

03:11.440 --> 03:14.890
Executes a little bit strange for a file it makes sense.

03:14.890 --> 03:21.070
The executable permission allows you to run the file and execute a program or a script for a directory

03:21.070 --> 03:26.620
though the execute permission allows you to change to a different directory and make it your current

03:26.620 --> 03:27.970
working directory.

03:27.970 --> 03:32.860
So if you want to get out of a particular directory and go someplace else make sure it's executable

03:33.040 --> 03:37.270
for your particular user owner group or other.

03:37.440 --> 03:43.120
The tool we use in Linux to change file and folder permissions is called chmod.

03:43.240 --> 03:47.560
Now chmod is an interesting command and there's a couple of different ways to run it.

03:47.560 --> 03:50.210
And since I don't know how come t is going to tell you how to do it.

03:50.230 --> 03:51.880
We're going to try it both ways.

03:51.890 --> 03:57.310
So first of all what we're going to do is we're going to use chmod to change some permissions on one

03:57.310 --> 04:01.120
particular file a little executable program called Run me.

04:01.120 --> 04:06.430
Now run me is a very dangerous program so I want to be very specific about who can actually run this

04:06.430 --> 04:07.930
particular program.

04:07.960 --> 04:14.430
So I've got my Ls minus l running and you can see right now anybody can execute this program and see

04:14.430 --> 04:15.580
all three x's.

04:15.580 --> 04:19.920
So the creator owner the group and the others can all run this.

04:19.930 --> 04:26.440
So the first thing I am going to do tomorrow is I want to give the other people no rights to do anything

04:26.440 --> 04:32.680
on this thing so to do that I'm going to type in chmod and now I'm going to start typing in some switches.

04:32.680 --> 04:38.830
The switches here are either are going to be a letter followed by an equal sign and then the permissions

04:38.830 --> 04:39.160
I want.

04:39.160 --> 04:45.130
So in this particular case I'm going to say over other equals and I'm going to leave it blank which

04:45.130 --> 04:48.730
means turn off all permissions for the other people.

04:48.880 --> 04:51.880
And then obviously I'm going to type in the name of the file.

04:52.150 --> 05:01.700
So I run this and now you can see if you take a close look you'll see that the other group has absolutely

05:01.760 --> 05:06.770
no rights to this is somebody who isn't the creator owner or member of the group tries to execute this

05:06.770 --> 05:07.360
program.

05:07.430 --> 05:08.230
It's not going to happen.

05:08.240 --> 05:10.460
They don't have permissions.

05:10.460 --> 05:15.360
Now the other thing I want to do is I want to take a look and we can see the group has read right next.

05:15.360 --> 05:18.640
Q permissions since it's really just an executable file.

05:18.710 --> 05:20.450
There's really no reason to write to it.

05:20.450 --> 05:25.310
So what I'm going to do in this case is I'm going to turn off right permissions for the group.

05:25.430 --> 05:33.770
So again I type in chmod and now this time I type G for group and here all I want them to have is read

05:33.770 --> 05:35.430
and execute permissions.

05:35.600 --> 05:44.030
And then once again typing in the name of the file so I typed LS minus ELP and you can see that I've

05:44.030 --> 05:48.530
got rid of the right permissions so you can do a lot of cool stuff with this.

05:48.530 --> 05:52.990
Now there's one more chmod type command I want to show you in this version to run.

05:53.090 --> 05:57.410
And that means when you want to do it to everybody let's just say I'm feeling crazy and I want to give

05:57.470 --> 05:59.940
everybody rights to do everything they want to do.

06:00.080 --> 06:04.270
So in that case I'm going to run chmod and I'm going to use a.

06:04.280 --> 06:13.300
That means everybody creator owner group and other and easy I'm typing in a equals R W X so that means

06:13.300 --> 06:17.830
give everybody all the permissions run make

06:21.360 --> 06:21.960
me type.

06:21.970 --> 06:29.040
LS might well and you can see that I've put back all of the missions for that particular one.

06:29.590 --> 06:31.920
So that's one way to run Tramon.

06:32.020 --> 06:36.580
Now there is a whole other way to run it which is a little bit more old school and guys like me like

06:36.580 --> 06:37.380
to use.

06:37.480 --> 06:44.860
So I want to run Chimay one more time but this time what we're going to do is we're going to use numbers

06:44.920 --> 06:47.200
instead of letters to change things.

06:47.260 --> 06:54.400
Now in order for you to understand these numbers keep in mind that we have three values read write and

06:54.460 --> 06:55.510
execute.

06:55.510 --> 06:59.540
So in a binary world the read is in a four position.

06:59.710 --> 07:05.270
The right is in a two position and the execute is in a one position.

07:05.410 --> 07:12.040
So to explain that a little bit better let me put a little graphic up so that you can correlate the

07:12.040 --> 07:15.700
positions of those three values to binary values.

07:15.700 --> 07:18.040
Take a look at this.

07:18.250 --> 07:26.620
So we know that every linux file has read write and execute permissions for the creator owner the group

07:26.890 --> 07:28.600
and then the rest of the world.

07:28.600 --> 07:32.860
Now we've seen chmod used one way but let me show you this other way.

07:32.860 --> 07:38.200
So first thing I want to do is let's just pick on any one of these three so we'll just pick this one

07:38.200 --> 07:39.730
that's as good as anting.

07:39.980 --> 07:46.640
Now we understand that setting a permission basically turns it on or off.

07:46.660 --> 07:52.840
So there is kind of a binary thing to this if you think about this for a minute like for example we

07:52.840 --> 07:57.940
could turn off the read permission we could turn off the right permission and just turn on the execute

07:57.940 --> 07:58.990
permission.

07:58.990 --> 08:06.940
Equally we could turn on the read and the right permission and turn on the exit turn off the execute

08:06.940 --> 08:15.250
permission or we could turn on all of these permissions so really what you've got is three binary digits

08:15.850 --> 08:21.790
that we can convert to decimal Let's go ahead and go through all this real quick so all zeros and binary

08:21.790 --> 08:30.960
equals zero in decimal 0 0 1 equals 1 in decimal 0 1 0 equals 2 in decimal 0 1 1 equals 3.

08:30.960 --> 08:32.620
Here I'll just keep going through the rest of these.

08:32.620 --> 08:35.010
I think you can figure this out.

08:35.020 --> 08:43.600
So basically three binary values can have 1 2 3 4 5 6 7 8 different combinations going from zero to

08:43.600 --> 08:44.880
7 in decimal.

08:44.980 --> 08:49.630
And understanding that we can actually do something really cool with Jamaah to make our lives a lot

08:49.630 --> 08:50.470
easier.

08:50.470 --> 08:59.770
So for example on this particular one if we just want to set this particular one to read only all we

08:59.770 --> 09:03.310
have to do is type in 1 0 0 which is going to equal 4.

09:03.310 --> 09:12.890
So in essence we just say for if we want to set it to just write permission we would say to and if we

09:12.890 --> 09:15.750
want to say execute permission we say one.

09:15.770 --> 09:21.730
So really what it boils down to when you look at read write execute read gets the value of for right

09:21.740 --> 09:25.880
gets the value of two and execute gets the value of one.

09:26.000 --> 09:30.260
And we can use this combination which Hamada do cool things for example.

09:30.290 --> 09:35.730
So if I wanted to set the read permission I would just say four and that would turn off right and execute

09:36.140 --> 09:37.810
if I want to just the right permission.

09:37.820 --> 09:43.370
I would say to if I want to just execute permission I would say 1 but it also works for combinations

09:43.730 --> 09:47.300
if I want the read and right combination it will be a 6.

09:47.390 --> 09:52.920
And if I want everything it's going to be a 7 and we can use that to work with chmod.

09:53.300 --> 09:56.390
So let's go through one quick example of this.

09:56.390 --> 10:00.770
Now keep in mind we have three read write and executes to deal with not just one.

10:00.770 --> 10:09.740
So if I wanted to for example set everybody to read write and execute I would type chmod 7 7 7 and that

10:09.740 --> 10:12.640
would give everybody read right next cue permissions.

10:12.740 --> 10:18.800
But then again if I wanted to give the creator owner complete permission and then I wanted to give the

10:18.800 --> 10:20.810
group just read and write permission.

10:20.930 --> 10:30.980
And then if I wanted to give everybody else no permission at all that would be 7 6 0 OK.

10:31.620 --> 10:36.330
Now that you have a least rough idea of how this works what we're going to do is we're going to use

10:36.330 --> 10:39.820
Tamada again except this time we're just going to use numbers now.

10:39.930 --> 10:44.610
The downside of using Shimada like this is that you've got to be really really comfortable with binary

10:44.610 --> 10:48.240
and well luckily I am but you may not be so.

10:48.270 --> 10:53.580
If there's one thing you might want to rehearse a little bit are using these number of days for Chameides

10:53.610 --> 10:57.810
as opposed to what I think is the well now easier way of just using the letters.

10:57.810 --> 10:59.520
Anyway let's go through an example.

11:00.700 --> 11:04.420
If you take a look up on the screen you'll see that I have this run me right now.

11:04.420 --> 11:11.220
So I'm going to type chmod and I'm going to type in the number 7.

11:11.220 --> 11:14.580
Now think about this for a minute four plus two plus one equals seven.

11:14.580 --> 11:21.210
So if I give a value of seven that means I want read and write and execute the order that I put these

11:21.210 --> 11:24.910
numbers in depends on whether it's for the creator owner the group or other.

11:24.900 --> 11:30.670
So the first value seven means makes your creator owner has read write and execute.

11:30.690 --> 11:32.940
Now it's often common to do the same thing.

11:32.970 --> 11:38.350
So I'm going to type in a second seven so that the group has read write and execute permissions that

11:38.360 --> 11:41.160
the third one I'm going to do is I'm going to put in the number five.

11:41.160 --> 11:45.270
Now with the number five in there now I'm really speculate for a minute.

11:45.630 --> 11:48.660
What permission am I turning off by doing that.

11:48.660 --> 11:49.660
I'll give you a clue.

11:49.710 --> 11:52.660
Seven minus two equals five.

11:52.800 --> 11:55.400
So let's go ahead and run this.

11:55.470 --> 12:01.060
They can see I type chmod and a number and then the actual file that I want to change I hit enter.

12:01.080 --> 12:06.660
Now if I type LS minus L right now if I've done it right there it is.

12:06.660 --> 12:10.020
The w is not in for other.

12:10.020 --> 12:15.530
So what I did by typing a five in that third position as I said turn off right.

12:15.540 --> 12:19.380
Permission for that particular file.

12:19.410 --> 12:21.360
So which my you can have a lot of fun.

12:21.360 --> 12:25.260
In fact you'll see people with Jamaah they'll say chmod 777.

12:25.260 --> 12:27.740
And what they're saying is just turn everything on.

12:28.010 --> 12:28.490
OK.

12:28.530 --> 12:29.440
Now that's Tramon.

12:29.460 --> 12:30.690
So Juds pretty cool.

12:30.730 --> 12:31.780
And I like it.

12:31.860 --> 12:39.660
But what I want to do now is go from dealing with who has what type of file and folder permissions to

12:39.780 --> 12:41.790
who owns a particular file.

12:41.790 --> 12:44.530
And to do that we're going to use tcha own.

12:44.670 --> 12:45.630
OK.

12:45.800 --> 12:48.710
So CHONE simply allows us to change ownership.

12:48.720 --> 12:49.830
Let me show you how that works.

12:49.860 --> 12:57.210
If you take a look at my Ls minus L here you'll see that right now the file run me has student as the

12:57.210 --> 12:57.480
owner.

12:57.480 --> 13:01.160
And what we're going to do right now is we're going to change that to route.

13:01.170 --> 13:04.400
So Joe needs sudo in order to work.

13:04.400 --> 13:10.230
So we're going to type sudo shown and we're going to type in truly want to change ownership to and then

13:10.230 --> 13:12.930
we type in the name of the file.

13:14.340 --> 13:20.040
Now look very carefully here you can see that the owner is now root.

13:20.070 --> 13:22.100
And that's what CHONE is all about.

13:22.110 --> 13:28.290
It's a quick way for you to be able to change the owner of a particular file or folder.

13:28.290 --> 13:28.610
All right.

13:28.620 --> 13:35.880
So we've messed with our file and folder permissions we have changed the ownership.

13:35.880 --> 13:42.000
Now the last thing I want to talk about is changing a password and to do that we use the S S W D command.

13:42.000 --> 13:47.860
Now again this one needs sudo so I'm going to type in pseudo SSW D.

13:47.970 --> 13:52.560
Now right now if I just hit enter it's going to change the password for the account I'm logged in on

13:52.560 --> 13:53.940
currently which is student.

13:54.030 --> 13:55.470
So I'm going to do that.

13:55.950 --> 13:57.930
So I'm going to enter a new Unix password

14:02.840 --> 14:05.980
and I have now changed the password successfully.

14:05.980 --> 14:11.280
So if you need to change a password make sure you know how to use p s s w d.

14:12.230 --> 14:15.000
On the plus objectives they do something very strange here.

14:15.150 --> 14:22.410
They actually in the objectives they put ph s s w d which is change passwords right with the command

14:22.410 --> 14:26.770
P W D which means for just show me the current working directory.

14:26.850 --> 14:31.350
I'm not quite sure why Campania does that but it might be a clue on something you're going to see on

14:31.350 --> 14:35.270
the exam on

14:37.910 --> 14:41.300
in

14:45.520 --> 14:49.090
an.
