1 00:00:00,540 --> 00:00:04,590 Hello everyone in this video we are going to learn. 2 00:00:04,590 --> 00:00:11,390 One of the most interesting and powerful command in our Linux command line is Journey. 3 00:00:11,400 --> 00:00:16,860 We are going to learn how to create and make our own commands ourselves. 4 00:00:17,130 --> 00:00:18,800 How cool is that. 5 00:00:19,180 --> 00:00:26,580 So remember that our Linux commands can be one of four different types. 6 00:00:26,610 --> 00:00:34,830 They can be either a shell script or they can be a shell built in command or they can be an executable 7 00:00:35,100 --> 00:00:36,050 program. 8 00:00:36,420 --> 00:00:39,500 And finally they can be an alias. 9 00:00:39,660 --> 00:00:46,530 And remember that without an alias can be used to define our own commands ourselves. 10 00:00:46,710 --> 00:00:55,650 So right now we are going to learn how to create and make our own commands using the all mighty and 11 00:00:55,650 --> 00:00:58,850 powerful Ilias command. 12 00:00:58,860 --> 00:01:04,860 So before we do this you have to know a couple of facts or a couple of things here. 13 00:01:05,070 --> 00:01:11,970 Every time or the first thing that you do whenever you want to make Eric a new command is you think 14 00:01:11,970 --> 00:01:13,390 of a name right. 15 00:01:13,410 --> 00:01:21,590 It's like a baby so every time a new couple have a baby they think of a name right. 16 00:01:21,600 --> 00:01:26,430 So let's say that someone saying the name test. 17 00:01:26,580 --> 00:01:30,820 So you want to create your new command and you want to call it test. 18 00:01:30,930 --> 00:01:38,760 So before you actually go on and use this new name you have to check whether the system already uses 19 00:01:38,850 --> 00:01:40,170 this name. 20 00:01:40,170 --> 00:01:46,360 So and a very smart way to check for this is to use our command type. 21 00:01:46,590 --> 00:01:53,600 So I will say type test and it tells me that test is already shell built in command. 22 00:01:53,610 --> 00:01:55,430 So I can use it. 23 00:01:55,440 --> 00:02:00,660 I have to think of another name that is not already used by the system. 24 00:02:00,840 --> 00:02:03,390 So I will use something like invent. 25 00:02:03,480 --> 00:02:08,420 So I would say type invent and it tells me that invent is not found. 26 00:02:08,640 --> 00:02:16,080 So now I am able to use invent because it's not already used by the system. 27 00:02:16,470 --> 00:02:25,740 OK so once I figured out my new command name I can go on and create my new command. 28 00:02:25,740 --> 00:02:33,060 So here is the original syntax syntax on how to create a new command. 29 00:02:33,120 --> 00:02:39,020 So you have to use the command Ill use then followed by your new command name. 30 00:02:39,880 --> 00:02:43,380 Followed by an equal sign and there is no whitespace here. 31 00:02:43,520 --> 00:02:45,470 You have to be careful with this. 32 00:02:45,700 --> 00:02:56,040 And then between between double codes you can specify here what ever you want your command to do. 33 00:02:56,920 --> 00:03:05,570 So for example I will call my command invent as we said invent equal between double codes. 34 00:03:05,990 --> 00:03:07,200 I will tell it what to do. 35 00:03:07,220 --> 00:03:13,070 So every time I enter event I wanted to change to my desktop. 36 00:03:13,070 --> 00:03:16,620 I wanted to make a directory called directory one. 37 00:03:16,640 --> 00:03:20,630 I wanted to make a file called file 1. 38 00:03:20,950 --> 00:03:27,250 I wanted also to show the date and the calendar and that's it for now. 39 00:03:27,260 --> 00:03:35,360 So as you can see I separated by every command separated by a semi colon here because we know that we 40 00:03:35,360 --> 00:03:41,900 can execute multiple commands on the same line if we just separate them by a semi-colon. 41 00:03:41,900 --> 00:03:48,110 So here I take advantage of the of combining multiple commands in the same line. 42 00:03:48,190 --> 00:03:48,950 OK. 43 00:03:49,280 --> 00:03:55,450 So now once I'm done I just hit enter. 44 00:03:55,560 --> 00:03:57,000 Here is the magic. 45 00:03:57,400 --> 00:04:02,710 If I type in event and hit enter every thing here will be executed. 46 00:04:02,710 --> 00:04:04,620 So let's see. 47 00:04:05,200 --> 00:04:12,310 As you can see it shows me the date it shows me the calendar and it already created directory 1 and 48 00:04:12,310 --> 00:04:13,010 file 1. 49 00:04:13,090 --> 00:04:15,350 Awesome. 50 00:04:15,390 --> 00:04:19,640 Yeah that's is one example of how to create a new command. 51 00:04:19,690 --> 00:04:23,450 Now let's think of another use. 52 00:04:23,480 --> 00:04:32,440 So imagine that like every day I open my work directory in the morning and then I open my files directory. 53 00:04:32,450 --> 00:04:39,590 Then I have to do directory and then I have a list finally I have a list here that I check regularly 54 00:04:39,590 --> 00:04:40,630 every day. 55 00:04:40,700 --> 00:04:42,430 It's like a to do list. 56 00:04:42,500 --> 00:04:49,730 So for me as a system administrator I have to check this list every day to see what I have to do to 57 00:04:49,760 --> 00:04:56,490 I have to update the system back up the system and the users remove users and change permissions etc.. 58 00:04:56,720 --> 00:05:01,420 So every day it will be very tedious and time consuming too. 59 00:05:01,640 --> 00:05:03,540 So for example let's see. 60 00:05:03,740 --> 00:05:06,010 So first I'll be at my home directory right. 61 00:05:06,110 --> 00:05:11,850 So every day working on my terminal of course I have to go to the desktop. 62 00:05:12,050 --> 00:05:18,560 Then I have to go to my work directory into my files to my to do. 63 00:05:18,560 --> 00:05:24,410 Then finally I'm able to see my list. 64 00:05:24,440 --> 00:05:26,920 OK so I think it is very time consuming. 65 00:05:26,930 --> 00:05:35,250 So instead I can make a command that will open my list with just one word. 66 00:05:35,270 --> 00:05:40,320 So for example I will I want to create my command and I will call it open. 67 00:05:40,540 --> 00:05:47,020 So let's see it open in the really used key open or the read is already used by my system. 68 00:05:47,020 --> 00:05:54,750 So I would think of another name let's say open fire. 69 00:05:56,040 --> 00:06:00,070 And it tells me that open file is not found. 70 00:06:00,210 --> 00:06:01,950 So I can use open file. 71 00:06:01,950 --> 00:06:04,230 Actually I will use another name. 72 00:06:04,230 --> 00:06:11,470 I will say to do want to do is not found awesome. 73 00:06:11,690 --> 00:06:18,850 So now I can use my new command name to do to open my to do list here. 74 00:06:19,100 --> 00:06:19,750 OK. 75 00:06:19,790 --> 00:06:21,280 With just one word. 76 00:06:21,290 --> 00:06:24,450 So it's really easy. 77 00:06:24,920 --> 00:06:34,240 All I need to do is just say Ilias to do because without any spaces then I will change to my desktop. 78 00:06:36,850 --> 00:06:40,910 I'll change to my Or I can do this I can say gee it 79 00:06:48,190 --> 00:06:49,110 my desktop 80 00:06:54,730 --> 00:07:03,710 then my files in my to do and my list. 81 00:07:03,760 --> 00:07:04,920 So right now 82 00:07:08,100 --> 00:07:09,750 if I execute this. 83 00:07:09,930 --> 00:07:16,830 So right now if I say to do it will open my list as you can see it's magic. 84 00:07:17,010 --> 00:07:19,300 Guys it's very very helpful. 85 00:07:19,300 --> 00:07:26,810 So instead of every day I wake I wake up in the morning and then I have to go to work but first and 86 00:07:26,820 --> 00:07:28,090 have to go to desktop. 87 00:07:28,090 --> 00:07:31,950 I have to go to work load of files to do. 88 00:07:32,200 --> 00:07:36,100 And then finally I'm able to open my list. 89 00:07:36,490 --> 00:07:41,030 All these things are just saved when I say 90 00:07:43,630 --> 00:07:51,980 so if I just say to do and hit a this just happened right. 91 00:07:51,980 --> 00:07:55,040 So as you can see you can you have different. 92 00:07:55,040 --> 00:08:04,570 You have like infinite possibilities for the benefits of creating of being able to create a new command. 93 00:08:05,060 --> 00:08:15,290 So I will make another two or three pages and explaining the usefulness and the benefits of creating 94 00:08:15,290 --> 00:08:16,100 an alias command. 95 00:08:16,100 --> 00:08:22,970 But for now I want you guys to practice with the alias commands. 96 00:08:22,970 --> 00:08:24,620 So yeah that's it for this video. 97 00:08:24,630 --> 00:08:25,060 Ciao.