1 00:00:00,000 --> 00:00:03,510 Hello everyone. Now that you have learned how to 2 00:00:03,540 --> 00:00:06,630 assign permissions to file and directories using 3 00:00:06,630 --> 00:00:10,230 letters, but now do you know you could also assign 4 00:00:10,230 --> 00:00:15,750 permissions using numerical values? Yes, so every 5 00:00:15,750 --> 00:00:19,260 time you have a file, you could assign permission 6 00:00:19,260 --> 00:00:24,480 to that file or directory using numerical digits. 7 00:00:25,140 --> 00:00:30,667 And how does it work? So, you know, chmod ugo, 8 00:00:30,667 --> 00:00:34,170 is for user, group, and other, plus r to a FILE 9 00:00:34,170 --> 00:00:37,290 would actually assign a read permission to 10 00:00:37,290 --> 00:00:41,850 everyone. If you want to use in a numerical way, 11 00:00:42,060 --> 00:00:46,680 you could do chmod 444, and the FILE, which 12 00:00:46,680 --> 00:00:50,580 will assign exactly the same permission, as in the 13 00:00:50,580 --> 00:00:54,570 first command. And the end result will be read, 14 00:00:54,840 --> 00:01:00,120 read, and read permission only to everyone for a 15 00:01:00,120 --> 00:01:05,040 file. Now, how does that 444 changes and assign 16 00:01:05,040 --> 00:01:08,940 that permission? Let's look at it by looking at 17 00:01:08,940 --> 00:01:11,520 the structure of a file. So as you all know, 18 00:01:11,550 --> 00:01:13,770 owners assign permissions on every file and 19 00:01:13,770 --> 00:01:16,800 directory, and we have users, and they have three 20 00:01:16,800 --> 00:01:19,980 type of permission read, write, executable. Group has 21 00:01:19,980 --> 00:01:22,950 three type of permissions, and everyone else or 22 00:01:22,950 --> 00:01:26,250 others or all have those three type of permissions 23 00:01:26,250 --> 00:01:30,000 as well, so we all know that. Then let's go more 24 00:01:30,000 --> 00:01:32,670 specifically that the first three bits that we have 25 00:01:32,670 --> 00:01:36,000 already covered are for users, the owner of the 26 00:01:36,000 --> 00:01:39,600 file, the secondary bits are for the group, and 27 00:01:39,600 --> 00:01:42,960 the last three bits are for the others. Now, 28 00:01:43,350 --> 00:01:46,530 moving on, the table below that I'm going to show 29 00:01:46,530 --> 00:01:51,780 you are is actually, assigns numbers or permissions 30 00:01:52,020 --> 00:01:54,840 to the permission types. So let's look at that 31 00:01:54,840 --> 00:01:57,870 table. This is the table is something that you 32 00:01:57,870 --> 00:02:02,730 need to remember. Now, if you have zero assigned, 33 00:02:03,360 --> 00:02:07,320 that means no permission, a one is for executable, 34 00:02:08,070 --> 00:02:12,630 two is for write, three is for execute plus write, 35 00:02:12,990 --> 00:02:17,790 four is to read, five is to read and execute, six 36 00:02:17,790 --> 00:02:21,270 is to read and write, and seven is to read or write 37 00:02:21,390 --> 00:02:24,840 and execute. Now how does these all seven 38 00:02:24,840 --> 00:02:30,420 numbers, all eight numbers work. If I have, if 39 00:02:30,420 --> 00:02:37,590 I do chmod 764 to our file, then it means the 40 00:02:37,590 --> 00:02:43,170 first digit will always be for the user itself. So 41 00:02:43,170 --> 00:02:46,140 seven meanings, if you look at the table, it means 42 00:02:46,620 --> 00:02:50,040 this is going to assign read, write, and executable 43 00:02:50,040 --> 00:02:54,180 permission to the owner of the file. The second 44 00:02:54,210 --> 00:02:58,470 letter, which is in this case is six, it means 45 00:02:58,710 --> 00:03:01,980 that a read and write only and that will be 46 00:03:02,010 --> 00:03:07,080 assigned to the group. And the last one is for 47 00:03:07,290 --> 00:03:11,520 that is for others, and the four means only read, 48 00:03:11,640 --> 00:03:16,560 so only read will be assigned to the file. So 49 00:03:16,560 --> 00:03:19,800 again, first digit is for users, second digit is 50 00:03:19,800 --> 00:03:23,370 for group and third digit is for others. So let's 51 00:03:23,370 --> 00:03:27,120 try in our Linux machine, in our lab machine, and 52 00:03:27,120 --> 00:03:30,630 see how it works. So I'm going to create a file, 53 00:03:30,630 --> 00:03:34,920 let's say, sam, and we're going to touch and 54 00:03:34,920 --> 00:03:38,490 create a file sam. I will do ls -ltr. 55 00:03:39,270 --> 00:03:42,480 and the file is there. By the way, I am logged 56 00:03:42,480 --> 00:03:48,210 in as myself, and I am in my home directory. So 57 00:03:48,210 --> 00:03:50,730 let's clear the screen by typing clear, and do ls 58 00:03:50,730 --> 00:03:54,840 -ltr again, and you will see the sam file is 59 00:03:54,840 --> 00:03:58,080 all the way at the bottom. Now by 60 00:03:58,080 --> 00:04:02,640 default, I have given the permission as read, write, 61 00:04:03,180 --> 00:04:07,440 read, write, and just read. If you want to change 62 00:04:07,440 --> 00:04:12,600 this permission to 764, meaning me as myself would 63 00:04:12,600 --> 00:04:16,410 have read, write, and executable. And group will have 64 00:04:16,440 --> 00:04:19,440 only read, write. And everyone else will just have 65 00:04:19,440 --> 00:04:26,873 read, then all I have to do is chmod 764 sam. 66 00:04:26,873 --> 00:04:31,140 Now when you do ls -ltr, you 67 00:04:31,140 --> 00:04:35,910 will see right at the bottom, I have now read, write, 68 00:04:35,910 --> 00:04:40,260 executable, read, write for the group, and just read 69 00:04:40,560 --> 00:04:45,420 for everyone else. Now if I wanted to remove those 70 00:04:45,420 --> 00:04:48,360 permissions, let's clear the screen and just do ls 71 00:04:48,360 --> 00:04:53,160 -ltr only on sam file so just only that 72 00:04:53,160 --> 00:04:56,130 file shows up on the list. If I wanted to remove 73 00:04:56,130 --> 00:04:58,440 every permission of everyone else, 74 00:04:58,470 --> 00:05:04,410 I will do chmod 000 sam, do ls -ltr by 75 00:05:04,440 --> 00:05:07,650 hitting up arrow key, which will bring the last 76 00:05:07,770 --> 00:05:11,310 ran command, and you hit enter. You will see all 77 00:05:11,310 --> 00:05:15,450 the permissions are gone. Now, if I wanted to, 78 00:05:15,450 --> 00:05:19,410 let's say if I want to assign, read and write 79 00:05:19,410 --> 00:05:24,930 permission only to myself, then how are you going 80 00:05:24,930 --> 00:05:28,380 to do it. Then all you have to do is chmod, 81 00:05:28,590 --> 00:05:31,350 myself would be the first letter, remember, the 82 00:05:31,350 --> 00:05:35,640 first, sorry, the first digit. So I just want read 83 00:05:35,880 --> 00:05:39,210 and write only, so that would go for number six. 84 00:05:39,720 --> 00:05:42,030 Because if you look at the table, number six only 85 00:05:42,030 --> 00:05:45,030 gives read and write. Then the rest, I don't want 86 00:05:45,030 --> 00:05:47,160 to assign anything else. So you cannot leave 87 00:05:47,580 --> 00:05:50,520 anything empty like that, so you have to leave 00. 88 00:05:51,630 --> 00:05:55,290 So no permission at all, type it, sam. Now if you 89 00:05:55,290 --> 00:05:59,190 do ls -ltr on sam, you'll see I only have 90 00:05:59,190 --> 00:06:04,170 read and write. So let's try one more time. What 91 00:06:04,200 --> 00:06:07,470 if I want to keep the permission read and write 92 00:06:08,010 --> 00:06:12,090 and I wanted to assign read permission to the existing 93 00:06:12,090 --> 00:06:16,770 permission for others? Meaning, right here, the 94 00:06:16,770 --> 00:06:21,660 last three bits I want r here. So for that, I 95 00:06:21,660 --> 00:06:25,920 would do first of all chmod, and of course, I 96 00:06:25,920 --> 00:06:29,160 want to keep the permission and that permission is 97 00:06:29,430 --> 00:06:33,480 six. For group, I don't want to assign anything. 98 00:06:33,630 --> 00:06:37,560 And for others, I want only read. And if you look 99 00:06:37,560 --> 00:06:41,460 at the table, the read, number associated with read 100 00:06:41,460 --> 00:06:46,770 is four. So if I do hit four, and type sam, and 101 00:06:46,770 --> 00:06:50,460 now if I do ls -ltr on sam, and you will see 102 00:06:50,460 --> 00:06:56,250 read and write, and read is only given to others in 103 00:06:56,250 --> 00:06:59,460 this case. Let's look at one more, and last one 104 00:06:59,460 --> 00:07:02,820 example, what if I want to assign executable 105 00:07:02,820 --> 00:07:08,160 permission to everyone in the system. So 106 00:07:08,160 --> 00:07:11,880 you do chmod, now what's the executable? The 107 00:07:11,880 --> 00:07:14,850 executable permission, if you look at it, it's 108 00:07:14,850 --> 00:07:18,990 number one from the table. So that means 111. 109 00:07:18,990 --> 00:07:22,410 Because I want to assign executable to myself, to 110 00:07:22,410 --> 00:07:28,080 groups, and to others, so 111 and sam file, done, 111 00:07:28,080 --> 00:07:31,620 let's do ls -ltr, and you will see it's 112 00:07:31,680 --> 00:07:36,330 only given xxx, so now you can only get executable. If 113 00:07:36,330 --> 00:07:40,290 you want it to have executable and read, then you 114 00:07:40,290 --> 00:07:45,934 would have given number five, and 111, which will give you 115 00:07:45,934 --> 00:07:48,670 [No audio] 116 00:07:48,670 --> 00:07:52,680 yourself executable and read, and the rest 117 00:07:52,710 --> 00:07:57,300 only executable. Anyway, that's how you use this 118 00:07:57,300 --> 00:08:01,620 table. Or that's how you use the numerical letters 119 00:08:01,650 --> 00:08:04,260 or sorry in numerical digits to assign permissions. 120 00:08:04,530 --> 00:08:08,520 Also, if you do not remember this, this chart, or 121 00:08:08,520 --> 00:08:11,760 if it's not handy with you, you can also go online 122 00:08:11,760 --> 00:08:14,340 there are many calculators online that you could 123 00:08:14,340 --> 00:08:17,850 use you. All you have to do is type online 124 00:08:17,910 --> 00:08:21,300 chmod calculator and it will come up. A lot 125 00:08:21,300 --> 00:08:23,490 of websites have those free calculators for you, 126 00:08:23,490 --> 00:08:26,490 all you have to do is click on the ownership or 127 00:08:26,490 --> 00:08:28,920 group or public meaning others whatever that you 128 00:08:28,920 --> 00:08:31,830 want to do, check those marks and at the bottom, 129 00:08:31,830 --> 00:08:34,409 you will see Linux permission, it will give you 130 00:08:34,440 --> 00:08:37,020 the exact number that you need to type it in for 131 00:08:37,020 --> 00:08:40,620 chmod, it's very easy. Anyway you could do, 132 00:08:40,980 --> 00:08:44,429 either way you could do using the 133 00:08:44,429 --> 00:08:48,809 letters or you could do using the digits. I just 134 00:08:48,809 --> 00:08:53,039 want to cover both methods so you understand how 135 00:08:53,220 --> 00:08:55,770 the permission works using both methods. 136 00:08:55,770 --> 00:08:57,557 [No audio]