1
00:00:00,270 --> 00:00:02,130
In this lesson, we're going to discuss

2
00:00:02,130 --> 00:00:05,490
how you can assign ownership to files and directories.

3
00:00:05,490 --> 00:00:08,100
In Linux, ownership refers to the property

4
00:00:08,100 --> 00:00:10,740
by which a user can apply and modify permissions

5
00:00:10,740 --> 00:00:12,540
of a file or directory.

6
00:00:12,540 --> 00:00:14,850
By default, the owner of the file or directory

7
00:00:14,850 --> 00:00:17,520
is the user who created the file or directory.

8
00:00:17,520 --> 00:00:20,370
Other than the superuser who's known as our root user,

9
00:00:20,370 --> 00:00:23,040
no other user can change their permissions of an object

10
00:00:23,040 --> 00:00:24,930
that's owned by somebody else.

11
00:00:24,930 --> 00:00:26,850
While the most common application of ownership

12
00:00:26,850 --> 00:00:28,890
is going to be the changing of the read, right,

13
00:00:28,890 --> 00:00:30,810
or execute permission attributes,

14
00:00:30,810 --> 00:00:33,690
owners can also alter advanced and special permissions

15
00:00:33,690 --> 00:00:35,130
of the objects they own.

16
00:00:35,130 --> 00:00:37,620
These objects are files and directories.

17
00:00:37,620 --> 00:00:40,650
Now, remember, every file is owned by a specific user

18
00:00:40,650 --> 00:00:42,210
or a specific group.

19
00:00:42,210 --> 00:00:44,640
If you need to change the owner of the file or directory,

20
00:00:44,640 --> 00:00:47,160
you can use the chown command.

21
00:00:47,160 --> 00:00:49,950
Now, the chown command is used to change the owner,

22
00:00:49,950 --> 00:00:53,100
the group, or both for a file or directory.

23
00:00:53,100 --> 00:00:55,260
At times, you may wish that somebody else

24
00:00:55,260 --> 00:00:57,360
is going to manage an object's permissions

25
00:00:57,360 --> 00:00:59,730
other than the user who created that object.

26
00:00:59,730 --> 00:01:02,400
To do that, just enter the chown command

27
00:01:02,400 --> 00:01:06,330
by doing chown username and the file or directory name.

28
00:01:06,330 --> 00:01:09,060
This will change the owner, but not the group.

29
00:01:09,060 --> 00:01:10,890
If you want to change the owner and the group

30
00:01:10,890 --> 00:01:12,300
for a file or directory,

31
00:01:12,300 --> 00:01:16,410
you can enter chown username : group name

32
00:01:16,410 --> 00:01:18,570
and then the file or directory name.

33
00:01:18,570 --> 00:01:20,700
If you want to change the owner and then assign the group

34
00:01:20,700 --> 00:01:23,280
to the new owner's login group, you can do that

35
00:01:23,280 --> 00:01:28,110
by using chown username : file or directory name.

36
00:01:28,110 --> 00:01:30,450
If you need to change the group, but not the owner

37
00:01:30,450 --> 00:01:31,933
you can do that by typing in

38
00:01:31,933 --> 00:01:36,120
chown : group name file or directory name.

39
00:01:36,120 --> 00:01:39,060
Did you notice there's always the same basic format here?

40
00:01:39,060 --> 00:01:42,810
It's chown username : group name

41
00:01:42,810 --> 00:01:44,790
and then file or directory name.

42
00:01:44,790 --> 00:01:47,850
This way we can assign either part or both parts

43
00:01:47,850 --> 00:01:50,250
depending on which ones we put in as our options.

44
00:01:50,250 --> 00:01:52,290
We simply leave the username or group blank

45
00:01:52,290 --> 00:01:53,850
if we don't want to change those things

46
00:01:53,850 --> 00:01:54,900
and we add the other one in

47
00:01:54,900 --> 00:01:57,720
if we want to change the username or group name.

48
00:01:57,720 --> 00:02:00,150
You can also use the chown command recursively

49
00:02:00,150 --> 00:02:02,580
to change ownership throughout a directory structure

50
00:02:02,580 --> 00:02:05,310
if you add the dash R option.

51
00:02:05,310 --> 00:02:08,340
The next command we have is known as chgrp.

52
00:02:08,340 --> 00:02:11,430
The chgrp command or C-H-G-R-P

53
00:02:11,430 --> 00:02:13,500
is going to be used to change the group ownership

54
00:02:13,500 --> 00:02:15,240
of a file or directory.

55
00:02:15,240 --> 00:02:17,130
Changing the group ownership of an object

56
00:02:17,130 --> 00:02:18,330
ensures the group permissions

57
00:02:18,330 --> 00:02:20,520
are applied to the specific group.

58
00:02:20,520 --> 00:02:22,530
The proper way to enter the chgrp command

59
00:02:22,530 --> 00:02:24,690
is to enter chgrp the group name

60
00:02:24,690 --> 00:02:26,240
and the file or directory name.

