1
00:00:00,630 --> 00:00:01,350
Hi.

2
00:00:01,800 --> 00:00:09,180
So in this lesson we are going to understand a command which is change owner c h own.

3
00:00:09,630 --> 00:00:16,770
This command is used to change the user and the group ownership for any file or directory.

4
00:00:17,670 --> 00:00:24,750
The syntax is change owner the user name that needs to be given to any file.

5
00:00:24,780 --> 00:00:34,080
Similarly to a directory, we can also change the group names which can be done using a semicolon.

6
00:00:35,130 --> 00:00:42,660
We'll also see how we can change the owner and the group recursively for directories wherein there are

7
00:00:42,660 --> 00:00:45,720
multiple files inside a directory.

8
00:00:47,160 --> 00:00:51,900
So it's the practical time and let's see how we use change owner.

9
00:00:53,250 --> 00:01:00,300
I'm onto my terminal right now and I have created two files called this file one, file two and a directory

10
00:01:00,300 --> 00:01:01,650
called a directory one.

11
00:01:02,550 --> 00:01:04,020
Let us see the permissions.

12
00:01:04,260 --> 00:01:10,170
Currently the files have been created using the user root and the group root.

13
00:01:10,560 --> 00:01:16,170
Also, the directory has been created by the user route and the group route.

14
00:01:16,860 --> 00:01:26,010
Now we're going to change the owners of or ownership of these files and directories when we use the

15
00:01:26,010 --> 00:01:28,350
command ls hyphen l r.

16
00:01:28,440 --> 00:01:36,510
It shows us recursively what is inside directory one as we can see inside directory one there are two

17
00:01:36,510 --> 00:01:39,600
more files called as file one and file two.

18
00:01:40,320 --> 00:01:40,830
Great.

19
00:01:41,670 --> 00:01:49,380
Now let us change the ownership of these files one by one and observe.

20
00:01:50,630 --> 00:01:57,560
So the first thing that I'm going to do is I'm going to change the owner of file one, which is route

21
00:01:57,590 --> 00:01:59,300
to another user.

22
00:02:00,080 --> 00:02:08,150
So let's change the ownership of this file from the user route to hacked ify and give the file name

23
00:02:08,150 --> 00:02:09,530
as file one.

24
00:02:10,970 --> 00:02:14,990
Let us verify that our changes have been completed or no.

25
00:02:15,170 --> 00:02:22,640
And we can see successfully the C own command got executed and we have changed the ownership of the

26
00:02:22,640 --> 00:02:23,600
file one.

27
00:02:26,190 --> 00:02:29,970
Now let us do the same thing for file two.

28
00:02:30,510 --> 00:02:37,410
So I'm going to use the command C zone again, but this time we're going to change the group.

29
00:02:37,950 --> 00:02:39,510
The group is root.

30
00:02:39,540 --> 00:02:44,310
We are changing the group to Curly, which is followed by a semicolon.

31
00:02:45,330 --> 00:02:46,650
Let's see again.

32
00:02:46,650 --> 00:02:49,560
And we can see this was the first file one.

33
00:02:49,950 --> 00:02:56,100
Now for file two, this group ownership has been changed from root to curly.

34
00:02:56,730 --> 00:02:57,210
Great.

35
00:02:58,500 --> 00:02:59,560
Let us do one thing.

36
00:02:59,580 --> 00:03:04,920
Let us create an empty file using the command touch, which is file three.

37
00:03:05,430 --> 00:03:12,330
As we can see, the user and the group both are root because currently the root user is logged in,

38
00:03:12,330 --> 00:03:16,800
which has created this empty file known as file three.

39
00:03:17,920 --> 00:03:20,500
Let's change the ownership of this file.

40
00:03:21,070 --> 00:03:24,400
Let's say the user be hacked ify.

41
00:03:24,430 --> 00:03:27,730
So the command is going to be c h own rectify.

42
00:03:28,030 --> 00:03:34,660
Also change the group ownership to another which is Kali for file three.

43
00:03:35,200 --> 00:03:41,860
Now as we can see, when we ran the command, the user and group both have changed.

44
00:03:42,010 --> 00:03:49,750
We can verify that also with hyphen V, which stands for Verbose, which gives us more output of what

45
00:03:49,750 --> 00:03:51,880
the command is doing in the background.

46
00:03:52,570 --> 00:03:58,780
As here we can see the ownership of file three retained as hacked ify and Kali.

47
00:04:00,490 --> 00:04:03,400
Now let us again run this command.

48
00:04:03,730 --> 00:04:10,330
This time you're going to change the ownership of the user of file two.

49
00:04:10,690 --> 00:04:12,820
We are going to say C own.

50
00:04:13,060 --> 00:04:20,650
The user should be curly and hyphen V, which is verbose, which shows the message that the ownership

51
00:04:20,650 --> 00:04:22,810
changed from root to curly.

52
00:04:24,680 --> 00:04:25,520
Let us see.

53
00:04:25,520 --> 00:04:27,590
Now the directory.

54
00:04:28,010 --> 00:04:32,900
As you can see, the directory has the user route and group route.

55
00:04:33,620 --> 00:04:38,960
Let's go inside that directory by using the command change directory city.

56
00:04:39,320 --> 00:04:46,220
Here we can see that there are two files called this file one, file two, which has the same user and

57
00:04:46,220 --> 00:04:48,740
group which was applied to directory one.

58
00:04:50,120 --> 00:04:58,160
This time we will see how we can recursively change the user and the group ownership of directories

59
00:04:58,160 --> 00:04:59,180
and files.

60
00:05:00,040 --> 00:05:07,210
So for that you're going to use the command C phone hyphen capital R, which stands for recursive.

61
00:05:07,780 --> 00:05:15,400
Let's give the user ownership as Rectify and group as Kali to directory one before.

62
00:05:15,400 --> 00:05:18,910
As we can see, it was root and root.

63
00:05:19,150 --> 00:05:27,550
Now let's hit enter with hyphen V, which will show us what is happening in the background and we can

64
00:05:27,550 --> 00:05:31,120
see the changed ownership has successfully completed.

65
00:05:31,210 --> 00:05:39,760
Let's verify using the command ls hyphen l capital r which shows us the list and we can see successfully

66
00:05:39,760 --> 00:05:46,960
the directory user and group ownership and the files inside that directories has also been changed.

67
00:05:47,320 --> 00:05:49,360
So I hope you guys understood this.

68
00:05:49,390 --> 00:05:50,200
Thank you.
