1 00:00:00,000 --> 00:00:04,400 [Intro Music] 2 00:00:04,410 --> 00:00:05,880 I hope you were able to easily 3 00:00:05,880 --> 00:00:07,680 correct this challenge. Let's now 4 00:00:07,680 --> 00:00:09,270 do that together. Let's first 5 00:00:09,270 --> 00:00:12,594 export new variable, 'export MY_NAME', 6 00:00:12,594 --> 00:00:14,280 and the value will 7 00:00:14,280 --> 00:00:16,739 be in my case 'Bogdan'. Now, let's 8 00:00:16,739 --> 00:00:19,920 create a new file called name.sh. 9 00:00:20,310 --> 00:00:24,570 'touch name.sh'. And now let's edit 10 00:00:24,570 --> 00:00:28,110 it using Nano Editor, 'nano name.sh'. 11 00:00:28,410 --> 00:00:30,540 Here on the first line will be '#' 12 00:00:30,540 --> 00:00:32,520 sign, next comes '!', 13 00:00:32,520 --> 00:00:34,650 and afterwards will be path to 14 00:00:34,650 --> 00:00:36,570 corresponding executable that will 15 00:00:36,570 --> 00:00:39,570 launch this executable file '/bin/bash', 16 00:00:40,020 --> 00:00:42,270 and on next line, I'll simply use 17 00:00:42,300 --> 00:00:46,290 'echo $MY_NAME', like this. 18 00:00:46,560 --> 00:00:49,470 Very simple. Let's save this file. 19 00:00:49,920 --> 00:00:51,540 And now let's list files and 20 00:00:51,540 --> 00:00:53,400 folders here in home directory, 'ls 21 00:00:53,400 --> 00:00:55,860 -la'; and I see this newly 22 00:00:55,860 --> 00:00:59,490 created file, name.sh. But now this 23 00:00:59,490 --> 00:01:01,710 file is not executable. You see 24 00:01:01,710 --> 00:01:04,200 here those permissions. I am able 25 00:01:04,200 --> 00:01:06,629 to read, write this file as owner, 26 00:01:06,810 --> 00:01:09,570 and other users in the same group 27 00:01:09,600 --> 00:01:11,580 'bogdan' are also able to read and 28 00:01:11,580 --> 00:01:14,040 write file. All the remaining users 29 00:01:14,100 --> 00:01:16,620 in other groups are able only to 30 00:01:16,620 --> 00:01:18,930 read this file. Now let's add 31 00:01:18,990 --> 00:01:21,150 execution permission for this file. 32 00:01:21,360 --> 00:01:23,880 And I could do that using 'chmod' 33 00:01:23,880 --> 00:01:25,710 command. And here I could use 34 00:01:25,740 --> 00:01:28,830 simply syntax '+x', add execution 35 00:01:28,830 --> 00:01:30,930 permission. And next will come 36 00:01:30,960 --> 00:01:34,050 name of the file, name.sh. Let's 37 00:01:34,050 --> 00:01:36,030 press Enter. Let's verify now 38 00:01:36,030 --> 00:01:38,250 permissions. And now you see that 39 00:01:38,250 --> 00:01:40,590 everyone is able to execute this 40 00:01:40,590 --> 00:01:43,710 file. If you don't want that anyone 41 00:01:43,710 --> 00:01:45,750 else will be able to execute it, you 42 00:01:45,750 --> 00:01:47,910 could of course remove 'x', for all 43 00:01:47,910 --> 00:01:50,010 remaining users and leave 'x' only 44 00:01:50,010 --> 00:01:51,840 for this user. For that you could 45 00:01:51,840 --> 00:01:55,230 use either 'u+x' syntax, first 46 00:01:55,230 --> 00:01:56,940 remove 'x'. Let me show you it 47 00:01:56,940 --> 00:01:58,950 actually quickly. Let's go back and 48 00:01:58,980 --> 00:02:00,900 remove execution permission like 49 00:02:00,900 --> 00:02:04,740 this. And next let's add '+x' 50 00:02:04,770 --> 00:02:07,830 only for user, 'u+x', like so. And now 51 00:02:07,830 --> 00:02:10,020 let's verify permissions. And 52 00:02:10,020 --> 00:02:11,940 you'll see that now only the owner 53 00:02:11,940 --> 00:02:14,550 of this file is able to execute it. 54 00:02:15,120 --> 00:02:17,535 Now let's run it. I could use either 55 00:02:17,535 --> 00:02:19,531 absolute path to this file, 56 00:02:19,531 --> 00:02:22,950 name.sh or relative path. Let's use, 57 00:02:23,100 --> 00:02:25,800 let's say relative path, './', 58 00:02:25,860 --> 00:02:29,580 and name of the file, 'name.sh'; and I 59 00:02:29,580 --> 00:02:31,410 see my name here in the terminal. 60 00:02:31,680 --> 00:02:33,660 That means that this script works 61 00:02:33,660 --> 00:02:36,210 correctly, and this script is able 62 00:02:36,240 --> 00:02:38,070 to get access to environment 63 00:02:38,070 --> 00:02:39,750 variables. Let's quickly have a 64 00:02:39,750 --> 00:02:41,040 look at the contents of this 65 00:02:41,040 --> 00:02:44,100 script. And here's this line that 66 00:02:44,100 --> 00:02:46,800 accesses MY_NAME variable that we 67 00:02:46,800 --> 00:02:48,690 have created before with 'export' 68 00:02:48,690 --> 00:02:51,000 command. Alright, that's all for 69 00:02:51,000 --> 00:02:52,260 solution for this challenge. And 70 00:02:52,260 --> 00:02:53,820 that's all actually for this section. 71 00:02:53,820 --> 00:02:55,978 [no audio]