1
00:00:04,230 --> 00:00:11,220
Let's guys now talk about permissions and I'll explain you what is permission and how to modify permissions

2
00:00:11,220 --> 00:00:13,800
for a particular file or directory.

3
00:00:13,800 --> 00:00:19,740
And for example, here in this output for this file, three dot txt, you see that the owner of this

4
00:00:19,740 --> 00:00:21,930
file is Bogdan and group is Bogdan.

5
00:00:21,930 --> 00:00:30,750
And here are permissions first dash means that here you see file next three characters stand for permissions

6
00:00:30,750 --> 00:00:32,400
for particular user.

7
00:00:32,400 --> 00:00:40,050
In this case owner of the file owner is Bogdan Next three characters stand for permissions for other

8
00:00:40,050 --> 00:00:41,910
users in the same group.

9
00:00:41,910 --> 00:00:43,710
In this case, group is Bogdan.

10
00:00:43,710 --> 00:00:51,090
And finally, three last characters stand for permissions for all remaining users that don't belong

11
00:00:51,120 --> 00:00:53,010
to this particular group.

12
00:00:53,500 --> 00:00:54,970
This are permissions.

13
00:00:55,000 --> 00:00:55,650
Great.

14
00:00:55,660 --> 00:01:01,630
Let's now quickly clean up this home directory for this particular user that we have created before.

15
00:01:01,630 --> 00:01:09,490
And let me remove those two files one dot txt and two dot txt and this folder tmp and I'll do that under

16
00:01:09,490 --> 00:01:16,630
bogdan's account and I will be able to do so because now I'm owner of those files here.

17
00:01:16,630 --> 00:01:18,130
You see Bogdan everywhere.

18
00:01:18,160 --> 00:01:18,820
Great.

19
00:01:18,850 --> 00:01:27,970
Let's use command one dot txt or m two dot txt and r m dash r recursive tmp.

20
00:01:28,690 --> 00:01:37,060
Actually I was able to use just a single command with multiple arguments type simply tmp space one dot

21
00:01:37,060 --> 00:01:38,440
txt space to the txt.

22
00:01:38,680 --> 00:01:39,310
All right.

23
00:01:39,340 --> 00:01:46,900
Now I don't have any unnecessary files here in home directory for this user and I see only some hidden

24
00:01:46,900 --> 00:01:47,650
files.

25
00:01:47,680 --> 00:01:48,340
Great.

26
00:01:48,370 --> 00:01:55,880
Now let's go back to root account and create a new file in home directory for this Bogdan user.

27
00:01:55,880 --> 00:01:59,240
Let's go out of here and here as root user.

28
00:01:59,240 --> 00:02:02,360
Let's touch new file in the home.

29
00:02:02,360 --> 00:02:08,000
Bogdan and let's name it new file dot txt like so.

30
00:02:08,090 --> 00:02:12,380
And of course owner of this file will be now root user.

31
00:02:12,380 --> 00:02:13,520
Let's verify that.

32
00:02:13,520 --> 00:02:14,750
Yes, here it is.

33
00:02:14,750 --> 00:02:20,090
Root is owner of this file and here are permissions for this file.

34
00:02:20,090 --> 00:02:25,730
Only owner of this file is able to write this file to modify it.

35
00:02:26,220 --> 00:02:26,820
Great.

36
00:02:26,850 --> 00:02:33,450
Now, let me demonstrate you how you are able to modify permissions for this particular new file dot

37
00:02:33,450 --> 00:02:39,210
txt and recap that if you will try to write this file under other user.

38
00:02:39,210 --> 00:02:39,720
For example.

39
00:02:39,750 --> 00:02:46,450
Bogdan you will definitely get an error file is not writable because of those permissions.

40
00:02:46,470 --> 00:02:54,390
It is not possible to write or execute this file by any other user that doesn't belong to root group.

41
00:02:54,840 --> 00:03:01,170
Before modifying permissions, let me explain you how permissions are actually represented.

42
00:03:02,250 --> 00:03:04,590
Again, there are three different blocks.

43
00:03:04,590 --> 00:03:07,540
Here is the first block with three characters.

44
00:03:07,560 --> 00:03:12,930
Here is the second block, three characters and last block with three characters.

45
00:03:12,930 --> 00:03:20,700
And actually we are able to represent every block with three characters using binary format with zeros

46
00:03:20,700 --> 00:03:21,600
and ones.

47
00:03:21,900 --> 00:03:29,760
And for example, if I want to represent this three characters, I could simply type one, one and zero.

48
00:03:30,790 --> 00:03:33,790
Read, write and not execute.

49
00:03:34,900 --> 00:03:40,180
I could represent those three characters using such combination.

50
00:03:40,180 --> 00:03:50,670
1001 stands for Allow read zero stands for Deny, Write, and this zero stands for Deny execution.

51
00:03:50,680 --> 00:03:54,520
Three different binary numbers, zero and one.

52
00:03:55,150 --> 00:04:02,170
And now let's try to convert those three binary numbers into decimal format.

53
00:04:02,320 --> 00:04:06,100
Do you know how to convert binary number to decimal number?

54
00:04:06,280 --> 00:04:07,600
It is very simple.

55
00:04:07,600 --> 00:04:14,890
In this case we need to add powers of two multiplied by 0 or 1.

56
00:04:14,920 --> 00:04:15,970
Let me show you.

57
00:04:15,970 --> 00:04:25,870
In this case, formula will be following one multiplied by two to power of two plus zero, multiplied

58
00:04:25,870 --> 00:04:35,810
by two to power of one plus zero, multiplied by two to power of zero like so.

59
00:04:36,320 --> 00:04:39,590
And in this case we will get four.

60
00:04:39,980 --> 00:04:46,910
Four is the decimal representation of this binary number 100.

61
00:04:47,210 --> 00:04:53,350
Actually, you are able to use any online converter that will convert binary to decimal for you.

62
00:04:53,360 --> 00:04:59,480
Let's quickly find such kind of converter binary to decimal.

63
00:05:00,590 --> 00:05:05,900
And here let's open up for example, this link binary to decimal converter.

64
00:05:07,400 --> 00:05:13,760
Let's enter here 100 and press convert and I get four decimal number.

65
00:05:13,790 --> 00:05:14,380
Great.

66
00:05:14,390 --> 00:05:18,710
That's how you are able to convert binary numbers to decimal numbers.

67
00:05:18,740 --> 00:05:20,320
Now task for you.

68
00:05:20,330 --> 00:05:27,820
Please try to convert to decimal number this representation, read, write and not execute.

69
00:05:27,830 --> 00:05:28,820
I wish you good luck.

70
00:05:32,860 --> 00:05:33,760
Alright, done.

71
00:05:33,940 --> 00:05:41,470
Let's do that together and let me actually remove this formula and read, write and not execute is actually

72
00:05:41,470 --> 00:05:49,450
represented like one, one and zero and it will be equal to one multiplied to two to power of two plus

73
00:05:49,450 --> 00:05:58,030
one multiplied by two to power of one and plus zero multiplied by two to power of zero like so.

74
00:05:58,030 --> 00:06:02,680
And the result will be actually four plus two equal to six.

75
00:06:03,730 --> 00:06:04,270
Great.

76
00:06:04,270 --> 00:06:12,420
And if they are all ones, I mean, read, write and execute, then result will be equal to seven.

77
00:06:12,430 --> 00:06:13,960
Let me modify it here.

78
00:06:13,960 --> 00:06:18,550
Seven here will be one and here will be one.

79
00:06:18,550 --> 00:06:22,750
And it is actually read, write and execute like so.

80
00:06:23,170 --> 00:06:30,370
So you need to convert this representation into binary representation and afterwards to decimal.

81
00:06:30,370 --> 00:06:37,720
And actually there are most popular combinations like read, dash, dash, read, write, dash and read,

82
00:06:37,720 --> 00:06:39,250
write and execute.

83
00:06:39,250 --> 00:06:45,700
And corresponding decimal numbers are seven stands for read, write and execute.

84
00:06:45,730 --> 00:06:48,820
Let me quickly write it down here.

85
00:06:50,450 --> 00:06:52,110
I'll remove this part.

86
00:06:52,130 --> 00:06:54,290
So read, write and execute.

87
00:06:54,290 --> 00:06:55,550
Stands for seven.

88
00:06:55,580 --> 00:06:58,070
Read, write and not execute.

89
00:06:58,070 --> 00:06:59,690
Stands for six.

90
00:06:59,690 --> 00:07:02,330
And read and not write.

91
00:07:02,330 --> 00:07:05,300
And not execute is actually four.

92
00:07:05,390 --> 00:07:06,380
Like so.

93
00:07:06,530 --> 00:07:09,140
Those are most popular numbers.

94
00:07:09,140 --> 00:07:11,690
Decimal numbers for permissions.

95
00:07:12,080 --> 00:07:18,830
And now let me show you how using this knowledge, we are able to modify permissions for a specific

96
00:07:18,830 --> 00:07:19,460
file.

97
00:07:20,240 --> 00:07:21,950
Let's remove this part.

98
00:07:21,950 --> 00:07:27,800
And here for modification of permissions, we will use command mode like this.

99
00:07:27,920 --> 00:07:32,540
And next, we could supply number as first argument.

100
00:07:32,540 --> 00:07:36,980
And let's type here number, let's say 000.

101
00:07:36,980 --> 00:07:39,500
And here let's type path to the file.

102
00:07:39,500 --> 00:07:44,960
We want to change permissions home work done, new file like this.

103
00:07:45,050 --> 00:07:46,250
Let's press enter.

104
00:07:46,250 --> 00:07:49,910
And now let's list contents of the home work done user.

105
00:07:49,910 --> 00:07:58,400
And now I see following permissions because zero in decimal represents 000 in binary format.

106
00:07:58,430 --> 00:08:05,300
That's why now there are actually empty permissions and we are not able to read, write or execute this

107
00:08:05,300 --> 00:08:06,410
new file dot txt.

108
00:08:07,260 --> 00:08:12,030
Let's now modify permissions to following change mode.

109
00:08:12,030 --> 00:08:17,060
And here will be, let's say, 400.

110
00:08:17,190 --> 00:08:18,360
Press Enter.

111
00:08:18,390 --> 00:08:20,430
Let's verify settings now.

112
00:08:20,430 --> 00:08:26,970
And now I see that it is possible to read this file only by owner of this file.

113
00:08:28,440 --> 00:08:29,010
Great.

114
00:08:29,010 --> 00:08:30,840
Let's modify permissions again.

115
00:08:30,840 --> 00:08:35,640
And now here, I'll set permission 700.

116
00:08:35,669 --> 00:08:44,100
That stands for Read, write and execute for particular user, but no other permissions for other users.

117
00:08:45,170 --> 00:08:46,700
And now let's verify it.

118
00:08:46,700 --> 00:08:51,890
And actually now you see that permissions were changed to read, write and execute.

119
00:08:51,890 --> 00:08:55,310
And color of the file was changed as well.

120
00:08:55,490 --> 00:09:02,780
And the reason for that is that I have just made this file executable and all executable files in Bash

121
00:09:02,780 --> 00:09:06,920
Shell will be marked with green color like you see here.

122
00:09:07,550 --> 00:09:08,210
Great.

123
00:09:08,240 --> 00:09:09,470
Now task for you.

124
00:09:09,470 --> 00:09:14,420
Please modify permissions for this file and make it executable.

125
00:09:14,420 --> 00:09:22,550
Writable and readable for owner and readable and executable for remaining users in group and for other

126
00:09:22,550 --> 00:09:24,590
users in other groups.

127
00:09:29,200 --> 00:09:29,950
All right.

128
00:09:29,980 --> 00:09:32,470
First, let's try to write permissions.

129
00:09:32,470 --> 00:09:36,580
We want to assign to this new file in text format.

130
00:09:36,580 --> 00:09:44,020
So permissions will be following, read, write, execute by owner, read, not write and execute by

131
00:09:44,020 --> 00:09:47,160
all other users in group and read.

132
00:09:47,200 --> 00:09:52,330
Not write and execute by all remaining users in other groups.

133
00:09:52,330 --> 00:09:57,850
And we already know that this section is represented by number seven in decimal format.

134
00:09:57,880 --> 00:10:05,770
We have just used this number here and we have not yet calculated this section and if represent this

135
00:10:05,770 --> 00:10:15,370
section in binary format, I'll get 101 where this one is four in decimal and this one is one in decimal

136
00:10:15,370 --> 00:10:16,870
four plus one.

137
00:10:17,630 --> 00:10:25,340
Four plus one is equal to five, and that is the permission for all other users in group and for all

138
00:10:25,340 --> 00:10:27,560
other users in other groups.

139
00:10:27,590 --> 00:10:32,480
It means that final command will be 755 like this.

140
00:10:32,750 --> 00:10:34,160
Let's verify that.

141
00:10:34,250 --> 00:10:37,220
Let's list files and folders here and now.

142
00:10:37,220 --> 00:10:37,730
I see.

143
00:10:37,770 --> 00:10:39,050
Desired result.

144
00:10:39,080 --> 00:10:47,840
Now this new file dot txt is writable, readable and executable by owner and only readable and executable

145
00:10:47,870 --> 00:10:49,820
by all remaining users.

146
00:10:50,180 --> 00:10:53,930
And if you want to set full permissions, you need to type here.

147
00:10:53,930 --> 00:10:55,760
Seven, seven, seven.

148
00:10:56,830 --> 00:10:57,670
Like so.

149
00:10:58,630 --> 00:10:59,170
Great.

150
00:10:59,170 --> 00:11:03,930
That's how you're able to modify permissions using decimal representation.

151
00:11:03,940 --> 00:11:10,810
Also, you are able to add some permissions and to remove some permissions using following syntax.

152
00:11:10,810 --> 00:11:11,740
Let me show you.

153
00:11:11,770 --> 00:11:13,810
Let's go back to this command.

154
00:11:13,810 --> 00:11:19,330
And here, instead of 3/7, I'll write following dash x.

155
00:11:19,510 --> 00:11:20,860
Let's press enter.

156
00:11:20,860 --> 00:11:24,010
And now let's verify what was changed for permissions.

157
00:11:24,010 --> 00:11:29,470
And now I see that execution permission was removed from all three parts.

158
00:11:29,470 --> 00:11:31,180
Here, here and here.

159
00:11:31,360 --> 00:11:38,620
This what this minus X does, it has removed execution permissions for particular file.

160
00:11:38,770 --> 00:11:39,520
All right.

161
00:11:39,520 --> 00:11:41,470
Let's try to go back to this command.

162
00:11:41,470 --> 00:11:45,760
And instead of minus x, let's use plus x like so.

163
00:11:45,760 --> 00:11:48,700
And let's have a look again at settings.

164
00:11:48,700 --> 00:11:52,240
And now I see that X was added again everywhere.

165
00:11:53,060 --> 00:11:53,690
All right.

166
00:11:53,690 --> 00:11:59,680
You are also able to remove or add some permissions for particular groups.

167
00:11:59,690 --> 00:12:06,420
For example, if you want to remove execution permission only for group, you could use following command.

168
00:12:06,440 --> 00:12:17,360
Let's go back here and here will be J then will be minus and x j minus x for group, remove execution

169
00:12:17,360 --> 00:12:18,090
permission.

170
00:12:18,110 --> 00:12:19,430
Let's verify that.

171
00:12:20,330 --> 00:12:24,560
And now I see that x was removed here in group part.

172
00:12:24,710 --> 00:12:32,690
All right, let's now try to remove also read access for group users and here will be J minus R.

173
00:12:32,720 --> 00:12:35,090
Let's try that list.

174
00:12:35,090 --> 00:12:40,220
And now I see that R was removed here as well for group users.

175
00:12:40,670 --> 00:12:46,370
That's how you could very quickly add or remove some permissions if you want to.

176
00:12:46,370 --> 00:12:54,330
But I personally usually use decimal numbers like seven, seven, 7 or 7 zero 0 or 7 five five that

177
00:12:54,330 --> 00:12:56,130
are most commonly used.

178
00:12:56,190 --> 00:12:56,880
All right.

179
00:12:56,880 --> 00:12:58,200
That's all for permissions.

180
00:12:58,200 --> 00:13:01,920
And that's how you are able to modify permissions for specific files.

181
00:13:01,920 --> 00:13:09,360
And actually now we see that this new file dot txt is writable and executable by all users.

182
00:13:09,360 --> 00:13:11,810
And let's actually now quickly verify that.

183
00:13:11,820 --> 00:13:16,470
Let's change user to Bogdan list files here.

184
00:13:16,620 --> 00:13:19,410
I see new file dot txt here in this list.

185
00:13:19,410 --> 00:13:21,210
And now let's try to modify it.

186
00:13:21,240 --> 00:13:23,250
Nano new file dot txt.

187
00:13:23,400 --> 00:13:28,500
And yes, I'm able to modify it because now permissions allow it.

188
00:13:30,140 --> 00:13:34,340
That's what permissions do and that's how you are able to modify permissions.

189
00:13:34,340 --> 00:13:38,200
And that's what actually will be changed when you modify permissions.

190
00:13:38,210 --> 00:13:45,500
But my personal recommendation to you is to be very careful with permissions and not assign very broad

191
00:13:45,500 --> 00:13:51,850
permissions that will make some files readable, writable and executable by all users in the systems.

192
00:13:51,860 --> 00:13:56,420
Please assign only necessary permissions that you really need.

193
00:13:56,540 --> 00:13:57,170
All right.

194
00:13:57,170 --> 00:13:58,400
That's all for this lecture.

195
00:13:58,400 --> 00:14:04,230
And in the next one, I'll tell you how to create executable shell script using terminal.

196
00:14:04,250 --> 00:14:05,570
I'll see you in the next lecture.

197
00:14:05,570 --> 00:14:06,080
Bye bye.

