WEBVTT - This file was automatically generated by VIMEO

0
00:00:04.000 --> 00:00:05.000
Hi.

1
00:00:05.900 --> 00:00:09.300
So in this lesson, we are going to understand a command

2
00:00:08.300 --> 00:00:11.200
 which is change owner.

3
00:00:12.500 --> 00:00:13.100
CH own

4
00:00:13.700 --> 00:00:16.700
this command is used to change the user and

5
00:00:16.700 --> 00:00:19.400
 the group ownership for any file

6
00:00:19.400 --> 00:00:20.500
 or directory.

7
00:00:21.700 --> 00:00:25.000
The syntax is change owner the username.

8
00:00:25.900 --> 00:00:28.500
That needs to be given to any file

9
00:00:28.500 --> 00:00:30.800
 similarly to a directory.

10
00:00:31.900 --> 00:00:34.900
We can also change the group names which

11
00:00:34.900 --> 00:00:38.200
 can be done using a semicolon.

12
00:00:39.200 --> 00:00:42.500
We'll also see how we can change the owner

13
00:00:42.500 --> 00:00:46.700
 and the group recursively for directories wherein

14
00:00:45.700 --> 00:00:49.200
 there are multiple files inside a

15
00:00:48.200 --> 00:00:49.600
 directory.

16
00:00:51.300 --> 00:00:54.500
So it's the Practical time and let's see how to

17
00:00:54.500 --> 00:00:55.900
 use change owner.

18
00:00:57.300 --> 00:01:00.300
I want to my terminal right now and I have created.

19
00:01:01.200 --> 00:01:04.200
two files called as file 1 File 2 and a

20
00:01:04.200 --> 00:01:05.600
 directory called as directory 1

21
00:01:06.600 --> 00:01:09.800
Let us see the permissions currently the files

22
00:01:09.800 --> 00:01:12.900
 have been created using the user root

23
00:01:12.900 --> 00:01:15.600
 and the group root. Also, the

24
00:01:15.600 --> 00:01:18.700
 directory has been created by the user root

25
00:01:18.700 --> 00:01:20.200
 and the group root.

26
00:01:20.900 --> 00:01:23.700
Now we are going to change the owners

27
00:01:23.700 --> 00:01:26.400
 of odd ownership of this

28
00:01:26.400 --> 00:01:28.400
 files and directories.

29
00:01:29.400 --> 00:01:32.900
when we use the command LS - L are it

30
00:01:32.900 --> 00:01:35.700
 shows us recursively what is

31
00:01:35.700 --> 00:01:38.200
 inside directory 1 as we can

32
00:01:38.200 --> 00:01:41.800
 see inside directory 1 there are two more files called

33
00:01:41.800 --> 00:01:43.400
 as file 1 and file 2

34
00:01:44.300 --> 00:01:44.600
great.

35
00:01:45.700 --> 00:01:49.100
Now, let's change the ownership

36
00:01:48.100 --> 00:01:51.400
 of these files one

37
00:01:51.400 --> 00:01:53.300
 by one and observe.

38
00:01:54.700 --> 00:01:57.700
So the first thing that I'm going to do is I'm

39
00:01:57.700 --> 00:02:00.300
 going to change the owner of file 1

40
00:02:00.300 --> 00:02:03.100
 which is root to another user.

41
00:02:04.200 --> 00:02:08.200
So let's change the ownership of this file from the

42
00:02:07.200 --> 00:02:11.200
 user root to hacktify and

43
00:02:10.200 --> 00:02:13.300
 give the file name as file 1.

44
00:02:14.900 --> 00:02:17.400
Let us verify that our changes

45
00:02:17.400 --> 00:02:21.400
 have been completed or no, and we can see successfully the

46
00:02:20.400 --> 00:02:23.800
 CH own command got executed

47
00:02:23.800 --> 00:02:26.500
 and we have changed the ownership of

48
00:02:26.500 --> 00:02:27.400
 the file one.

49
00:02:30.300 --> 00:02:33.400
Now let us do the same thing for File

50
00:02:33.400 --> 00:02:33.800
 2.

51
00:02:34.600 --> 00:02:38.000
So I'm going to use the command CH own again,

52
00:02:37.500 --> 00:02:40.000
 but this time we're going to

53
00:02:40.300 --> 00:02:41.100
 change the group.

54
00:02:42.200 --> 00:02:46.300
The group is root. We are changing the group to Kali which

55
00:02:45.300 --> 00:02:48.200
 is followed by a semicolon.

56
00:02:49.400 --> 00:02:52.300
Let's see again, and we can see this was

57
00:02:52.300 --> 00:02:56.600
 the first file one now for File 2 this group

58
00:02:55.600 --> 00:02:58.700
 ownership has been changed from

59
00:02:58.700 --> 00:03:00.100
 root to Kali.

60
00:03:00.700 --> 00:03:01.000
Great.

61
00:03:02.400 --> 00:03:05.300
Let us do one thing. Let us create an empty file

62
00:03:05.300 --> 00:03:08.700
 using the command touch, which is file 3.

63
00:03:09.500 --> 00:03:12.500
As we can see the user and the group both

64
00:03:12.500 --> 00:03:15.700
 are root because currently the root user

65
00:03:15.700 --> 00:03:18.400
 is logged in which has created this empty file.

66
00:03:19.200 --> 00:03:20.600
known as file 3

67
00:03:21.900 --> 00:03:24.300
Let's change the ownership of this file.

68
00:03:25.200 --> 00:03:28.800
Let's say the user be hackedify. So

69
00:03:28.800 --> 00:03:32.400
 the command is going to be CH on actify all

70
00:03:31.400 --> 00:03:34.900
 so change the group ownership

71
00:03:34.900 --> 00:03:37.900
 to another which is Kali for

72
00:03:37.900 --> 00:03:38.500
 file 3.

73
00:03:39.400 --> 00:03:42.200
Now as we can see when we ran the command.

74
00:03:43.100 --> 00:03:46.400
The user and group both have changed we can

75
00:03:46.400 --> 00:03:49.100
 verify that also with hyphen V

76
00:03:49.100 --> 00:03:52.900
 which stands for verbose which gives us more output

77
00:03:52.900 --> 00:03:55.100
 of what the command is doing in the

78
00:03:55.100 --> 00:03:55.600
 background.

79
00:03:56.600 --> 00:03:59.300
As here, we can see the ownership of file 3

80
00:03:59.300 --> 00:04:01.000
 retained as hactify.

81
00:04:01.900 --> 00:04:02.800
and Kali

82
00:04:04.600 --> 00:04:04.700
now

83
00:04:05.600 --> 00:04:07.200
let us again run this command.

84
00:04:07.800 --> 00:04:11.900
This time we're going to change the ownership

85
00:04:10.900 --> 00:04:13.800
 of the user of file

86
00:04:13.800 --> 00:04:16.800
 2. We are going to say CH on

87
00:04:16.800 --> 00:04:19.800
 the user should be Kali and hyphen

88
00:04:19.800 --> 00:04:22.600
 V which is verbose which shows

89
00:04:22.600 --> 00:04:25.500
 the message that the ownership changed from

90
00:04:25.500 --> 00:04:26.800
 root to Kali.

91
00:04:28.800 --> 00:04:31.500
Let us see now the directory.

92
00:04:32.100 --> 00:04:35.600
As you can see the directory has the user root

93
00:04:35.600 --> 00:04:36.800
 and group root.

94
00:04:37.700 --> 00:04:39.400
Let's go inside the directory.

95
00:04:40.300 --> 00:04:43.900
By using the command change directory CD here. We

96
00:04:43.900 --> 00:04:46.400
 can see that there are two files called as file

97
00:04:46.400 --> 00:04:50.000
 one file to which has the same user

98
00:04:49.200 --> 00:04:52.600
 and group which was applied to directory 1

99
00:04:54.200 --> 00:04:58.200
This time we will see how we can recursively change

100
00:04:57.200 --> 00:05:00.300
 the user and the group

101
00:05:00.300 --> 00:05:02.900
 ownership of directories and files.

102
00:05:04.100 --> 00:05:08.700
So for that we are going to use the command ch1 capital

103
00:05:07.700 --> 00:05:10.300
 r which stands for

104
00:05:10.300 --> 00:05:11.100
 recursive.

105
00:05:11.800 --> 00:05:14.900
Let's give the user ownership as hackedify

106
00:05:14.900 --> 00:05:17.600
 and group as Kali to directory 1.

107
00:05:18.700 --> 00:05:21.200
Before as we can see it was

108
00:05:21.200 --> 00:05:24.900
 root and root now. Let's hit enter

109
00:05:24.900 --> 00:05:27.700
 with hyphen V which will

110
00:05:27.700 --> 00:05:30.200
 show us what is happening in the background?

111
00:05:31.100 --> 00:05:34.600
And we can see the changed ownership has successfully completed.

112
00:05:34.600 --> 00:05:37.300
 Let's verify using the command

113
00:05:37.300 --> 00:05:40.800
 LS hyphen L capital r which shows

114
00:05:40.800 --> 00:05:44.300
 us the list and we can see successfully the

115
00:05:43.300 --> 00:05:46.800
 directory user and group ownership and

116
00:05:46.800 --> 00:05:49.600
 the files inside that directories has

117
00:05:49.600 --> 00:05:50.500
 also been changed.

118
00:05:51.400 --> 00:05:53.900
So I hope you guys understood this. Thank you.
