WEBVTT - This file was automatically generated by VIMEO

0
00:00:06.900 --> 00:00:09.500
In this video, you'll learn all about groups and how they

1
00:00:09.500 --> 00:00:10.500
 are managed inside Linux.

2
00:00:12.400 --> 00:00:15.400
Our plan is to learn some Basics about groups. You will create

3
00:00:15.400 --> 00:00:18.700
 a new group called engineering for use on your Linux host. You

4
00:00:18.700 --> 00:00:21.500
 will add a Kira from the last video to this new group.

5
00:00:21.500 --> 00:00:24.300
 You would change the group permissions of this directory

6
00:00:24.300 --> 00:00:27.200
 and test group access using the career user.

7
00:00:27.200 --> 00:00:28.700
 Okay, let's get started.

8
00:00:29.800 --> 00:00:32.500
Okay. So here we are back in the terminal and

9
00:00:32.500 --> 00:00:36.600
 we're gonna go ahead and create a new group called engineering and

10
00:00:35.600 --> 00:00:38.600
 we're gonna do some management and

11
00:00:38.600 --> 00:00:41.500
 access control with this group. But before

12
00:00:41.500 --> 00:00:44.700
 we dive into that when you're doing any kind of group management on

13
00:00:44.700 --> 00:00:47.000
 Linux, there are definitely a few commands that you're going

14
00:00:47.100 --> 00:00:50.100
 to use the most so I'm gonna give you a few of them

15
00:00:50.100 --> 00:00:53.300
 this obviously some more but these are the most important. So the

16
00:00:53.300 --> 00:00:56.400
 First Command you're going to use is called group AD and this

17
00:00:56.400 --> 00:00:59.700
 does exactly what it says. It adds a group. The next

18
00:00:59.700 --> 00:01:02.300
 one is group delete. So does the

19
00:01:02.300 --> 00:01:03.900
 opposite of that it removes a group?

20
00:01:04.700 --> 00:01:07.100
And there's the group mod which will allow you

21
00:01:07.100 --> 00:01:10.400
 to modify groups. So this will basically allow to change the group ID,

22
00:01:10.400 --> 00:01:13.000
 or maybe if you mistyped the name and you get

23
00:01:13.200 --> 00:01:16.400
 to redo it, we will not be demoing this command

24
00:01:16.400 --> 00:01:19.400
 in this video, but just to know it's there in case you do actually

25
00:01:19.400 --> 00:01:21.200
 have a typo when you create the group.

26
00:01:22.100 --> 00:01:25.600
The other one of the group commands we're going to use is called group mems and

27
00:01:25.600 --> 00:01:28.100
 this allows you to adjust the

28
00:01:28.100 --> 00:01:31.300
 membership of a group meaning ad and

29
00:01:31.300 --> 00:01:34.700
 removing users and actually being able to view them in the

30
00:01:34.700 --> 00:01:37.600
 last command that we're going to use is called the change

31
00:01:37.600 --> 00:01:40.500
 group command or chtrp and this

32
00:01:40.500 --> 00:01:43.200
 allows you to change the group of a filer directory.

33
00:01:43.900 --> 00:01:46.500
Okay, so just like with creating

34
00:01:46.500 --> 00:01:49.800
 users creating groups requires elevated permissions.

35
00:01:49.800 --> 00:01:52.400
 So we'll be using sudo with a lot of our commands here.

36
00:01:52.400 --> 00:01:56.000
 So if some reason you're going through this tutorial and

37
00:01:55.700 --> 00:01:58.400
 you get a permission denied most likely

38
00:01:58.400 --> 00:02:01.200
 is because when you're running the group command you weren't

39
00:02:01.200 --> 00:02:04.200
 prefacing with sudo. All right, so let's get started. So

40
00:02:04.200 --> 00:02:07.200
 we're gonna create our Engineering Group and we're gonna use

41
00:02:07.200 --> 00:02:10.800
 sudo of course and we're gonna use the group AD command.

42
00:02:11.900 --> 00:02:14.200
Followed by the name of the group. We want to create and this one

43
00:02:14.200 --> 00:02:15.200
 is called engineering.

44
00:02:15.800 --> 00:02:18.600
So as with the password as

45
00:02:18.600 --> 00:02:22.100
 with users that were kept in a password file under

46
00:02:21.100 --> 00:02:24.200
 the Etsy directory groups are the

47
00:02:24.200 --> 00:02:27.500
 same thing and they are kept under a file called

48
00:02:27.800 --> 00:02:30.300
 ET slash Etc slash group. And so

49
00:02:30.300 --> 00:02:31.600
 let's go ahead and look at that now.

50
00:02:32.600 --> 00:02:34.700
And as you see way down here at the bottom.

51
00:02:35.600 --> 00:02:38.600
We could see our new group called engineering and so

52
00:02:38.600 --> 00:02:41.200
 not not unlike the

53
00:02:41.200 --> 00:02:44.500
 password file. There's a format here that is called colon separated.

54
00:02:44.500 --> 00:02:47.100
 And if you go in the first field here, it's the name of

55
00:02:47.100 --> 00:02:50.300
 the group, which is engineering. The second field here. Is this

56
00:02:50.300 --> 00:02:53.700
 x which is if there was a password it's not

57
00:02:53.700 --> 00:02:56.000
 really used but it's still here to denote and then that

58
00:02:56.400 --> 00:02:59.900
 X is there for a placeholder. The next field is

59
00:02:59.900 --> 00:03:02.500
 the unique group ID and as you can see there Auto

60
00:03:02.500 --> 00:03:06.300
 incrementing, so if we added another group, maybe 10003 and

61
00:03:05.300 --> 00:03:08.100
 then this last field which you can't see

62
00:03:08.100 --> 00:03:11.200
 is the comma separated list of

63
00:03:11.200 --> 00:03:14.200
 its members and as you can see up here, this is what

64
00:03:14.200 --> 00:03:17.400
 it looks like. If you look at the system D Journal group, you can

65
00:03:17.400 --> 00:03:20.400
 see that ec2 is a member of that group, okay.

66
00:03:21.300 --> 00:03:24.200
So we have an idea of what that looks like. So let's

67
00:03:24.200 --> 00:03:27.200
 go ahead and let's add our first member to

68
00:03:27.200 --> 00:03:30.400
 our new group. So we're going to use the pseudo command once

69
00:03:30.400 --> 00:03:30.600
 again.

70
00:03:31.500 --> 00:03:34.800
And in this case we're going to use the group mems command

71
00:03:34.800 --> 00:03:37.600
 and the group mems command is takes a

72
00:03:37.600 --> 00:03:40.400
 dash a flag with the name of the user and then

73
00:03:40.400 --> 00:03:42.600
 a dash G flag of the group name.

74
00:03:44.100 --> 00:03:47.400
So there's no error, but let's still validate our work and we

75
00:03:47.400 --> 00:03:50.200
 can scroll back up and use the same command. But instead

76
00:03:50.200 --> 00:03:53.600
 of using a dash a Akira we can do a dash L which

77
00:03:53.600 --> 00:03:56.300
 lists the members of the group and as

78
00:03:56.300 --> 00:03:59.800
 you can see here, the member is now Akira of

79
00:03:59.800 --> 00:04:02.500
 this group. We can further validate this

80
00:04:02.500 --> 00:04:05.900
 by looking in our slash Etc slash group file,

81
00:04:05.900 --> 00:04:07.500
 and we could come down here.

82
00:04:08.400 --> 00:04:11.200
And as you can see Akira is now a member

83
00:04:11.200 --> 00:04:14.000
 of this Engineering Group. Okay, so let me

84
00:04:14.100 --> 00:04:17.600
 clear the screen. And now that we have our group and

85
00:04:17.600 --> 00:04:20.300
 the user social group. The next thing to do is we need to apply it

86
00:04:20.300 --> 00:04:24.000
 to something. So what we're going to do is we're gonna reuse the engineering directory

87
00:04:23.300 --> 00:04:26.500
 that is in the home of ec2 user

88
00:04:26.500 --> 00:04:29.100
 that we already created. And so what we're going to do is we're gonna

89
00:04:29.100 --> 00:04:32.400
 move that to a place where a lot

90
00:04:32.400 --> 00:04:35.000
 of common shared executables and other data is

91
00:04:35.400 --> 00:04:37.400
 stored and that is under slash user slash local.

92
00:04:38.200 --> 00:04:41.500
And so once again, we're gonna need elevated privileges. So

93
00:04:41.500 --> 00:04:44.600
 we need to use sudo we're going to use the MV command

94
00:04:44.600 --> 00:04:44.900
 again.

95
00:04:45.700 --> 00:04:48.700
And what we're going to do is we're going to use tell it

96
00:04:48.700 --> 00:04:48.900
 the

97
00:04:49.700 --> 00:04:52.200
Source, which is a file directory that we want to

98
00:04:52.200 --> 00:04:55.400
 move and then now we need a destination. And

99
00:04:55.400 --> 00:04:58.800
 in this case, it is slash user slash local so

100
00:04:58.800 --> 00:04:59.600
 I didn't return.

101
00:05:00.500 --> 00:05:00.700
and

102
00:05:01.600 --> 00:05:04.700
no errors, but let's double check that

103
00:05:04.700 --> 00:05:07.000
 it is actually there. So we'll go

104
00:05:07.200 --> 00:05:10.700
 ahead and look under our user local again. And so as you

105
00:05:10.700 --> 00:05:12.300
 can see it moved it here.

106
00:05:14.300 --> 00:05:17.200
this time though it carried the permissions that it already had

107
00:05:17.200 --> 00:05:20.700
 from it, which was the group was ec2 user and the

108
00:05:20.700 --> 00:05:23.400
 owner was ec2 user and

109
00:05:23.400 --> 00:05:24.000
 as you remember

110
00:05:24.800 --> 00:05:27.600
By looking here the permissions on User Group

111
00:05:27.600 --> 00:05:30.500
 means that they have full permissions. They can read right next cute

112
00:05:30.500 --> 00:05:33.700
 for user and group. So that is

113
00:05:33.700 --> 00:05:36.400
 a good start. But obviously we want to lock this

114
00:05:36.400 --> 00:05:39.200
 directory down. So one things we're gonna do is we're gonna

115
00:05:39.200 --> 00:05:42.500
 change the user and we're gonna change the group

116
00:05:42.500 --> 00:05:45.600
 of this directory. So

117
00:05:45.600 --> 00:05:48.200
 we'll change the group first. I'm gonna show you two ways to

118
00:05:48.200 --> 00:05:51.200
 do this we could do with just one command, but I'll show you two is

119
00:05:51.200 --> 00:05:54.800
 so the first thing we're gonna do is we're gonna use the CH grp

120
00:05:54.800 --> 00:05:56.100
 command which is change group.

121
00:05:57.100 --> 00:06:00.100
We give it the group name. We want to

122
00:06:00.100 --> 00:06:03.400
 what we want to change to and then we give it a path to

123
00:06:03.400 --> 00:06:04.500
 the file or directory.

124
00:06:05.300 --> 00:06:06.500
And we do that.

125
00:06:07.400 --> 00:06:10.100
And if we turn we have no errors and so

126
00:06:10.100 --> 00:06:14.400
 let's go ahead and look again. And as you can see now engineering

127
00:06:13.400 --> 00:06:16.800
 is now the group of the

128
00:06:16.800 --> 00:06:19.400
 engineering directory. So this basically

129
00:06:19.400 --> 00:06:22.300
 means anybody in the engineering directory can now read write

130
00:06:22.300 --> 00:06:25.100
 or execute any files in there. But we still have a

131
00:06:25.100 --> 00:06:28.100
 problem ec2 user is still a owner of this

132
00:06:28.100 --> 00:06:31.100
 directory is still the user and we want it to be a little bit

133
00:06:31.100 --> 00:06:34.300
 more locked down. We want the Akira user to be able to be able

134
00:06:34.300 --> 00:06:37.000
 to read right and execute this directory, but not the ec2 user.

135
00:06:37.600 --> 00:06:40.400
So to do that we're going to use this command called change

136
00:06:40.400 --> 00:06:44.200
 ownership or Chown chowm and

137
00:06:43.200 --> 00:06:46.900
 what this does is it takes a user and

138
00:06:46.900 --> 00:06:49.800
 then a group with the colon separated

139
00:06:49.800 --> 00:06:52.100
 between them and then a path to

140
00:06:52.100 --> 00:06:55.600
 a file or directory in our case. It'd be the engineering.

141
00:06:56.500 --> 00:06:59.500
and so what we want to do here is we want

142
00:06:59.500 --> 00:07:00.400
 to change everything that

143
00:07:01.300 --> 00:07:03.500
this also takes a flag.

144
00:07:04.300 --> 00:07:07.000
That is worth doing and this is the capital r and this is

145
00:07:07.700 --> 00:07:10.800
 recursive. So not only will it change all the

146
00:07:10.800 --> 00:07:13.300
 permissions of the directory, but it'll change

147
00:07:13.300 --> 00:07:16.700
 all the permissions the ownership. Sorry the ownership and group

148
00:07:16.700 --> 00:07:19.500
 of the file under the files inside

149
00:07:19.500 --> 00:07:20.300
 the directory.

150
00:07:20.800 --> 00:07:23.500
So we'll go ahead and do that. And so let's

151
00:07:23.500 --> 00:07:26.100
 go ahead and look at it now and as you

152
00:07:26.100 --> 00:07:26.400
 can see

153
00:07:27.800 --> 00:07:31.000
root is now the user of this directory engineering

154
00:07:30.200 --> 00:07:33.900
 is the group of this directory and Engineering itself.

155
00:07:33.900 --> 00:07:36.300
 And so if I tried to peek into the

156
00:07:36.300 --> 00:07:39.400
 directory itself, let's see the files and

157
00:07:39.400 --> 00:07:42.300
 if you remember we had the config Dot yaml and the contributors file

158
00:07:42.300 --> 00:07:45.400
 now, they're both owned by root and group

159
00:07:45.400 --> 00:07:46.000
 engineering.

160
00:07:47.200 --> 00:07:50.800
So if to test this out, we

161
00:07:50.800 --> 00:07:54.200
 would want to see you know, clear the screen really quick. We'd want

162
00:07:54.200 --> 00:07:57.400
 to see if the ec2 user could actually create a file in there. And so

163
00:07:57.400 --> 00:08:00.700
 what we're gonna do is we're gonna just try to touch a file touch

164
00:08:00.700 --> 00:08:03.500
 a file inside engineering and I'm

165
00:08:03.500 --> 00:08:05.800
 gonna just call this one ec2 user.

166
00:08:06.900 --> 00:08:08.300
for a lack of imagination

167
00:08:09.500 --> 00:08:12.200
and what you see here is a permission denied and that

168
00:08:12.200 --> 00:08:13.100
 makes sense because

169
00:08:14.900 --> 00:08:17.100
Are engineering directory?

170
00:08:18.400 --> 00:08:21.700
Is now gated by a user and

171
00:08:21.700 --> 00:08:24.700
 a group. So if you're not that user or that group, you can't

172
00:08:24.700 --> 00:08:27.200
 do much but read or list the

173
00:08:27.200 --> 00:08:30.600
 files basically inside that directory. That's the rnx right

174
00:08:30.600 --> 00:08:30.800
 there.

175
00:08:31.500 --> 00:08:34.400
Okay, so to test this out that we've fully made

176
00:08:34.400 --> 00:08:37.200
 this gated we'll need to log back in as

177
00:08:37.200 --> 00:08:40.100
 the carry user and test that this works and we're

178
00:08:40.100 --> 00:08:43.200
 gonna back we'll have to use the sudo and we'll use the SE. I mean,

179
00:08:43.200 --> 00:08:46.200
 sorry, we're gonna use the Su command and make sure you have the password handy.

180
00:08:46.700 --> 00:08:48.100
Okay, so clear the screen.

181
00:08:49.200 --> 00:08:51.700
And then we are going to say Akira.

182
00:08:52.400 --> 00:08:55.100
We're gonna use the Su command Dash secure and then

183
00:08:55.100 --> 00:08:58.300
 prompted for our password for Kira and to

184
00:08:58.300 --> 00:09:00.600
 that in and of course I mistyped it.

185
00:09:01.600 --> 00:09:03.200
So we'll try it one more time.

186
00:09:05.800 --> 00:09:08.200
And here I am there I am

187
00:09:08.200 --> 00:09:11.100
 logged back in a secure. And so what we're going to try to

188
00:09:11.100 --> 00:09:15.200
 do is we're gonna touch a file inside the engineering directory called

189
00:09:14.200 --> 00:09:15.800
 Akira.

190
00:09:16.400 --> 00:09:20.000
And as you see we don't get the permission denied because

191
00:09:19.900 --> 00:09:22.600
 Akira is a member of the Engineering Group.

192
00:09:22.600 --> 00:09:25.600
 Okay. So let me log back out

193
00:09:25.600 --> 00:09:28.200
 of the Akira user. I'll clear the screen once

194
00:09:28.200 --> 00:09:31.700
 again and there we have it. So we have our our crash

195
00:09:31.700 --> 00:09:34.200
 course on group management inside Lenox. So let's

196
00:09:34.200 --> 00:09:36.800
 jump back over and we'll do a quick recap of what we did.

197
00:09:37.700 --> 00:09:40.100
Okay, so we did quite a bit

198
00:09:40.100 --> 00:09:43.500
 in this video you learned about groups and how

199
00:09:43.500 --> 00:09:46.700
 you can manage them inside Linux you use different commands

200
00:09:46.700 --> 00:09:49.800
 like group AD change ownership change

201
00:09:49.800 --> 00:09:52.200
 group and then the group

202
00:09:52.200 --> 00:09:55.400
 mod command we didn't use but you could use that to modify and we

203
00:09:55.400 --> 00:09:58.100
 didn't use the group to lead as well because obviously we wanted to

204
00:09:58.100 --> 00:10:01.200
 keep the group around you added the Akira user to

205
00:10:01.200 --> 00:10:04.600
 the engineering group and you change permissions on a directory to

206
00:10:04.600 --> 00:10:05.300
 test access.

207
00:10:06.800 --> 00:10:09.600
In the next video, you will learn about software management

208
00:10:09.600 --> 00:10:11.600
 inside Linux. See you soon.
