1 00:00:00,000 --> 00:00:04,600 [Intro Music] 2 00:00:04,650 --> 00:00:06,540 We have just explored how to create 3 00:00:06,570 --> 00:00:08,880 new users using such command as 4 00:00:08,910 --> 00:00:11,850 'useradd', and using corresponding 5 00:00:11,880 --> 00:00:14,040 'userdel' command, we have deleted 6 00:00:14,040 --> 00:00:16,350 users. Now let me explain you how 7 00:00:16,350 --> 00:00:18,210 you could create a new user using 8 00:00:18,240 --> 00:00:21,030 command 'adduser'. And also 9 00:00:21,030 --> 00:00:22,680 afterwards, I'll tell you how to 10 00:00:22,680 --> 00:00:25,620 create new groups and assign users 11 00:00:25,740 --> 00:00:28,050 to some custom groups. Because by 12 00:00:28,050 --> 00:00:30,600 default, Linux creates a group with 13 00:00:30,600 --> 00:00:32,700 the same name as username you 14 00:00:32,700 --> 00:00:35,580 create. Alright, let's now enter, 15 00:00:35,640 --> 00:00:37,980 'adduser' command; and next, 16 00:00:38,010 --> 00:00:40,830 let's type username of the user I 17 00:00:40,830 --> 00:00:42,930 want to create. And here you'll see 18 00:00:42,960 --> 00:00:45,450 some prompts. First of all, you'll 19 00:00:45,450 --> 00:00:49,050 see that new user was added. After 20 00:00:49,050 --> 00:00:51,900 that new group, 'bogdan' was created. 21 00:00:52,200 --> 00:00:54,060 And here in parenthesis, you'll see 22 00:00:54,060 --> 00:00:56,880 actually ID for specific user, 23 00:00:57,060 --> 00:00:59,130 because every user has specific 24 00:00:59,130 --> 00:01:02,280 ID. Next, you see that new user 25 00:01:02,280 --> 00:01:05,250 'bogdan' was assigned to 'bogdan' 26 00:01:05,310 --> 00:01:08,520 group. Afterwards new home directory 27 00:01:08,550 --> 00:01:11,340 was created automatically, and path 28 00:01:11,370 --> 00:01:13,061 to this directory is here, 29 00:01:13,061 --> 00:01:15,540 '/home/bogdan'. And next, after 30 00:01:15,540 --> 00:01:17,670 this step, you new files were 31 00:01:17,670 --> 00:01:19,800 copied into the home directory for 32 00:01:19,830 --> 00:01:22,350 this user. And basically here after 33 00:01:22,350 --> 00:01:23,970 this command, you will see the same 34 00:01:24,030 --> 00:01:25,920 three files that we have seen in 35 00:01:25,920 --> 00:01:28,140 the previous lecture after 'useradd' 36 00:01:28,140 --> 00:01:29,940 command. And here, we are 37 00:01:29,970 --> 00:01:31,620 immediately prompted to create a 38 00:01:31,650 --> 00:01:34,140 new password for this user. And you 39 00:01:34,140 --> 00:01:36,120 see that this command 'adduser' is 40 00:01:36,120 --> 00:01:38,310 actually interactive conversation 41 00:01:38,430 --> 00:01:40,590 for creation of the new user. All 42 00:01:40,590 --> 00:01:42,060 right, let's enter here new 43 00:01:42,060 --> 00:01:43,770 password. Again, let me choose some 44 00:01:43,770 --> 00:01:47,160 something really strong, '123'; retype '123'. 45 00:01:47,370 --> 00:01:49,170 And you'll see that password was 46 00:01:49,200 --> 00:01:51,210 updated successfully. Afterwards, 47 00:01:51,240 --> 00:01:53,640 you could set such parameters as 48 00:01:53,670 --> 00:01:56,310 'Full Name', 'Room Number', 'Work Phone', 49 00:01:56,340 --> 00:01:58,620 'Home Phone', 'Other'; and if this 50 00:01:58,620 --> 00:02:00,420 information is correct, just simply 51 00:02:00,420 --> 00:02:03,060 type Yes, and press Enter; or just 52 00:02:03,060 --> 00:02:05,520 press Enter. And now we're all set, 53 00:02:05,580 --> 00:02:07,950 new user 'bogdan' was successfully 54 00:02:07,950 --> 00:02:10,440 created. Let's verify that. Let's 55 00:02:10,440 --> 00:02:11,940 clear terminal. And first let's 56 00:02:11,940 --> 00:02:13,650 have a look at contents of the home 57 00:02:13,680 --> 00:02:15,810 directory. And here I see new 58 00:02:15,810 --> 00:02:18,300 folder 'bogdan'. And it's a good 59 00:02:18,300 --> 00:02:20,490 sign, it seems that this new home 60 00:02:20,490 --> 00:02:21,750 directory was created 61 00:02:21,780 --> 00:02:23,520 automatically. Let's have a look at 62 00:02:23,520 --> 00:02:26,040 contents of this directory; and 63 00:02:26,040 --> 00:02:29,400 let's add here options '-la'; and 64 00:02:29,400 --> 00:02:32,752 I'll see three hidden files, '.bash_logout', 65 00:02:32,752 --> 00:02:35,490 '.bashrc', and '.profile'; and 66 00:02:35,490 --> 00:02:38,190 notice username and group for 67 00:02:38,220 --> 00:02:40,800 those three files. You see that 68 00:02:40,860 --> 00:02:43,470 owner and group for all files is 69 00:02:43,470 --> 00:02:46,530 set to new user, 'bogdan'; and 70 00:02:46,530 --> 00:02:48,960 that means that this user has full 71 00:02:48,960 --> 00:02:51,240 access to those files. Actually, 72 00:02:51,240 --> 00:02:52,740 here you see permissions for every 73 00:02:52,740 --> 00:02:55,440 file; and this user 'bogdan' is 74 00:02:55,470 --> 00:02:58,770 able to read, write, but not execute; 75 00:02:59,220 --> 00:03:01,980 other group users are able only to 76 00:03:01,980 --> 00:03:04,560 read those files; and remaining users 77 00:03:04,590 --> 00:03:07,230 are also able only to read those 78 00:03:07,230 --> 00:03:09,780 files. And that means that any 79 00:03:09,810 --> 00:03:13,140 other users will not be able to modify 80 00:03:13,200 --> 00:03:16,200 those files like '.bash_logout', '.bashrc', 81 00:03:16,200 --> 00:03:19,500 and profile. Alright, that's how 82 00:03:19,590 --> 00:03:21,660 this home directory looks like for 83 00:03:21,690 --> 00:03:24,180 this particular newly created user. 84 00:03:24,480 --> 00:03:26,190 Let me now clear terminal and enter 85 00:03:26,190 --> 00:03:28,980 following command, 'cat /etc/ 86 00:03:29,340 --> 00:03:32,550 passwd', let's press Enter, and here 87 00:03:32,550 --> 00:03:34,290 in output of this command at the 88 00:03:34,290 --> 00:03:36,690 very end, I'll see information 89 00:03:36,720 --> 00:03:40,140 about newly created user. Here I 90 00:03:40,140 --> 00:03:43,530 see username, here is User ID, it is 91 00:03:43,530 --> 00:03:46,500 1000, next comes path to home 92 00:03:46,500 --> 00:03:48,480 directory for this particular user, 93 00:03:48,630 --> 00:03:51,630 and finally, you see default shell 94 00:03:51,660 --> 00:03:54,180 for this user. And here in this 95 00:03:54,180 --> 00:03:56,160 case, you see that this default 96 00:03:56,190 --> 00:03:59,670 shell was set to 'bash' shell. And 97 00:03:59,670 --> 00:04:01,931 that is the difference between 'adduser' 98 00:04:01,931 --> 00:04:04,380 and 'useradd' command. We have 99 00:04:04,380 --> 00:04:06,330 seen that in 'useradd' command 100 00:04:06,360 --> 00:04:09,870 default shell is set to 'sh', but when 101 00:04:09,870 --> 00:04:11,499 you create a new user using 102 00:04:11,499 --> 00:04:14,220 'adduser' command, then default shell 103 00:04:14,250 --> 00:04:16,800 will be set to 'bash', and the reason 104 00:04:16,800 --> 00:04:18,660 for that is that initial default 105 00:04:18,660 --> 00:04:20,760 configuration settings are located 106 00:04:20,760 --> 00:04:23,220 in other file if you use 'adduser' 107 00:04:23,220 --> 00:04:25,140 command. Let me show you location 108 00:04:25,170 --> 00:04:27,240 of this file. Let me clear terminal 109 00:04:27,269 --> 00:04:32,160 and type 'cat /etc/adduser' first 110 00:04:32,160 --> 00:04:34,350 step, and you'll see that file name 111 00:04:34,380 --> 00:04:35,807 will be autocompleted to 112 00:04:35,807 --> 00:04:38,490 'adduser.conf'. Let's have a look at the 113 00:04:38,490 --> 00:04:40,140 contents of this configuration 114 00:04:40,140 --> 00:04:42,600 file. And here in this output let's 115 00:04:42,600 --> 00:04:45,660 find the setting for bash shell, it 116 00:04:45,660 --> 00:04:46,980 should be somewhere at the 117 00:04:46,980 --> 00:04:49,050 beginning. And yes, here is the 118 00:04:49,050 --> 00:04:51,750 setting 'DSHELL=/bin/ 119 00:04:51,780 --> 00:04:54,090 bash'; and that means that default 120 00:04:54,120 --> 00:04:55,950 shell for all users that are 121 00:04:55,950 --> 00:05:00,375 created using 'adduser' command will be set to 'bash'. 122 00:05:01,140 --> 00:05:02,790 And actually, you're able to modify 123 00:05:02,820 --> 00:05:05,040 this configuration file, same as we 124 00:05:05,040 --> 00:05:06,740 did with configuration file for 125 00:05:06,740 --> 00:05:08,670 'useradd' command, if you want, of 126 00:05:08,670 --> 00:05:11,190 course. Alright, that's how this 127 00:05:11,190 --> 00:05:13,500 configuration file looks like. And 128 00:05:13,530 --> 00:05:15,720 that's how we have just created a 129 00:05:15,750 --> 00:05:18,180 new user using 'adduser' command. 130 00:05:18,570 --> 00:05:21,210 Great. Let's now try to login as 131 00:05:21,210 --> 00:05:23,490 'bogdan' user. Let's type 'su 132 00:05:23,520 --> 00:05:25,560 -', and next comes 'bogdan', 133 00:05:25,650 --> 00:05:27,540 please recap that '-' stands for 134 00:05:27,540 --> 00:05:30,360 '-' option or '-l' or '-- 135 00:05:30,360 --> 00:05:32,490 login' option. And with this option, 136 00:05:32,520 --> 00:05:34,530 we will login into the home 137 00:05:34,530 --> 00:05:36,360 directory for a particular user. 138 00:05:36,630 --> 00:05:40,080 Let's press Enter, type 'pwd', and yes, 139 00:05:40,110 --> 00:05:41,850 now I'm inside of the home 140 00:05:41,850 --> 00:05:43,950 directory for 'bogdan' user. And 141 00:05:43,950 --> 00:05:45,780 here you see that the command prompt was 142 00:05:45,780 --> 00:05:47,850 changed. And here now I see new 143 00:05:47,850 --> 00:05:50,949 user 'bogdan'. If I enter 'whoami', 144 00:05:50,949 --> 00:05:53,010 I'll see same output here. 145 00:05:53,700 --> 00:05:55,620 Great. That is how we were able to 146 00:05:55,620 --> 00:05:58,560 login under custom user that we 147 00:05:58,560 --> 00:06:00,510 have just created. And of course, 148 00:06:00,510 --> 00:06:02,790 now I'm able to create some files 149 00:06:02,790 --> 00:06:04,470 in this home directory. Let's 150 00:06:04,470 --> 00:06:07,869 create a new file, let's say '1.txt', 151 00:06:07,869 --> 00:06:09,450 and let's list contents 152 00:06:09,480 --> 00:06:11,520 of home directory. And I'll see 153 00:06:11,550 --> 00:06:13,920 newly created file. And you'll see 154 00:06:13,920 --> 00:06:16,410 that owner of this file is of course 155 00:06:16,410 --> 00:06:18,630 'bogdan'. And here you see 156 00:06:18,630 --> 00:06:20,250 'bogdan' because it is the name of the 157 00:06:20,250 --> 00:06:21,510 group that was automatically 158 00:06:21,510 --> 00:06:23,580 created for new user 'bogdan'. 159 00:06:23,940 --> 00:06:25,800 And here are permissions for this 160 00:06:25,830 --> 00:06:29,070 newly created file. Alright, that's 161 00:06:29,070 --> 00:06:31,470 how we are able to interact with 162 00:06:31,470 --> 00:06:34,590 system under custom user. And next 163 00:06:34,620 --> 00:06:37,050 let's talk a bit about permissions 164 00:06:37,080 --> 00:06:39,270 for files. And in the next lecture, 165 00:06:39,300 --> 00:06:42,120 I'll try to create a new file as 166 00:06:42,120 --> 00:06:44,400 root user, and afterwards try to 167 00:06:44,400 --> 00:06:46,710 modify this file under 'bogdan's' 168 00:06:46,710 --> 00:06:48,420 account. Let's try that in the next 169 00:06:48,420 --> 00:06:49,400 lecture. Bye-Bye. 170 00:06:49,400 --> 00:06:51,221 [no audio]