0 1 00:00:00,570 --> 00:00:05,190 All right, guys. In this module, I'm going to teach you something really, really cool and really useful 1 2 00:00:05,190 --> 00:00:11,940 as well, not just in iOS development, but in your future life as a developer for any other technology, 2 3 00:00:11,940 --> 00:00:16,640 web development, or back end development. The command line is going to be your friend. 3 4 00:00:16,830 --> 00:00:19,330 So let us introduce you to your friend. 4 5 00:00:19,350 --> 00:00:26,670 So in order to use the command line on a Mac, we will be using the Terminal application. And the Terminal 5 6 00:00:26,760 --> 00:00:30,800 is a way of accessing something called the Bash Shell. 6 7 00:00:30,810 --> 00:00:35,610 So when you're a beginner and you're getting to grips with the command line, there's a whole load of 7 8 00:00:35,610 --> 00:00:40,650 new words that you will come across. And I'm going to try and debunk some of the most common ones you'll 8 9 00:00:40,650 --> 00:00:41,820 come across. 9 10 00:00:41,820 --> 00:00:43,180 So what does the Bash Shell? 10 11 00:00:43,200 --> 00:00:46,980 Well, to understand the Bash Shell, we first have to know what a shell is. 11 12 00:00:46,980 --> 00:00:50,290 And this graphic is a good way of tackling that. 12 13 00:00:50,310 --> 00:00:57,590 So if you think about your operating system as a pistachio nut, then the kernels, so the actual pistachio, 13 14 00:00:57,590 --> 00:00:58,970 the thing that you're going to eat. 14 15 00:00:58,980 --> 00:01:01,080 I'm really sorry about all the food analogies. 15 16 00:01:01,080 --> 00:01:05,760 You can clearly tell I'm pretty much hungry most of the time when I'm recording these videos. 16 17 00:01:05,760 --> 00:01:07,290 But let's get back to the topic. 17 18 00:01:07,290 --> 00:01:15,540 So if your operating system macOS is a pistachio, then the actual nut is the kernel. And in computing, 18 19 00:01:15,570 --> 00:01:21,110 the kernel refers to the actual program that interfaces with the hardware. 19 20 00:01:21,120 --> 00:01:24,630 So it's the core of your operating system. 20 21 00:01:24,630 --> 00:01:32,370 Now, the shell of your pistachio or the shell in computing refers to the user interface for you as a 21 22 00:01:32,370 --> 00:01:39,860 human to be able to interact with the kernel, and in turn with the hardware of your computer. 22 23 00:01:40,020 --> 00:01:42,870 And there's two variants to the shell, 23 24 00:01:42,960 --> 00:01:46,080 there are graphical user interface shells. 24 25 00:01:46,080 --> 00:01:52,770 So, for example, when you open up Finder, you're using a graphical user interface to access and find your 25 26 00:01:52,770 --> 00:01:53,680 files. 26 27 00:01:53,790 --> 00:01:59,100 But there's also a command-line interface which is what we're going to be talking about and what we're 27 28 00:01:59,100 --> 00:02:01,410 going to be learning about in this module. 28 29 00:02:01,410 --> 00:02:05,580 So this is an alternative way of interfacing with the kernel. 29 30 00:02:05,760 --> 00:02:08,340 Now, it can seem intimidating at first. 30 31 00:02:08,370 --> 00:02:14,280 Now, as a beginner, it can seem quite intimidating. But I want to show you that it's actually super simple, 31 32 00:02:14,550 --> 00:02:20,700 and once you understand it, you're going to see that it's actually a really, really useful tool at your disposal. 32 33 00:02:20,700 --> 00:02:26,400 So coming back to the shell that we're going to be using which is a Bash Shell and it stands for the 33 34 00:02:26,400 --> 00:02:34,320 Bourne-again shell, and it's named after a Mr. Bourne, but not this Mr. Bourne, but this Mr. Bourne. And I can 34 35 00:02:34,320 --> 00:02:42,420 attest that they are equally badass. And the Bourne-again shell or the Bash Shell is a CLI or a Command 35 36 00:02:42,420 --> 00:02:51,390 Line Interpreter for the UNIX system. And you find UNIX-based systems or UNIX-like systems all over the 36 37 00:02:51,390 --> 00:02:51,860 place. 37 38 00:02:51,870 --> 00:02:59,970 So, for example, Linux is a UNIX-like system and a lot of servers will run on UNIX. and even the Mac that 38 39 00:02:59,970 --> 00:03:01,770 you're using right now, 39 40 00:03:01,920 --> 00:03:12,150 macOS 10 or the newly named macOS runs on a UNIX-like operating system. And this is a completely different 40 41 00:03:12,150 --> 00:03:17,750 family from the Windows side of things which uses DOS and Windows. 41 42 00:03:17,760 --> 00:03:19,560 So why is any of this interesting? 42 43 00:03:19,560 --> 00:03:24,210 Well, once you're familiar with the Bash Shell, you're going to find the skills that you acquire to be 43 44 00:03:24,210 --> 00:03:31,080 useful, not just for installing libraries on macOS, like we did in Clima, but you're going to be able 44 45 00:03:31,080 --> 00:03:36,280 to use it in other projects, other cases, other operating systems as well. 45 46 00:03:36,300 --> 00:03:41,300 A lot of things that you can do with the command line can be done using the graphical user interface. 46 47 00:03:41,400 --> 00:03:45,180 So why use the command line at all? At the end of the day, 47 48 00:03:45,180 --> 00:03:49,500 what it all boils down to is about greater control. 48 49 00:03:49,500 --> 00:03:57,450 And in your journey of becoming a better developer, you will need to understand and exert more power 49 50 00:03:57,540 --> 00:03:58,900 over your tools, 50 51 00:03:58,920 --> 00:04:00,740 that is the computer hardware. 51 52 00:04:00,870 --> 00:04:07,110 But on a more day to day basis, you will find that if you're a regular command-line user that it's actually 52 53 00:04:07,290 --> 00:04:14,280 easier and faster to do a lot of really common things. For example, inside the Terminal if I wanted to 53 54 00:04:14,280 --> 00:04:19,720 make a music folder, then it's as simple as mkdir Music. 54 55 00:04:19,890 --> 00:04:21,700 And now there it is, 55 56 00:04:21,720 --> 00:04:23,130 there's my music folder. 56 57 00:04:23,280 --> 00:04:28,090 But if I want to do it inside Finder, for example, I first have to go to Finder, 57 58 00:04:28,230 --> 00:04:36,150 I have to navigate to my desktop or whichever directory I want to create it inside, and then I have to maybe 58 59 00:04:36,200 --> 00:04:41,610 right-click New Folder, and then type something like Music, 59 60 00:04:41,640 --> 00:04:42,300 right? 60 61 00:04:42,600 --> 00:04:48,610 And that takes a lot of effort, whereas, you know, say, if I wanted to create Music2, right, make another folder, 61 62 00:04:48,730 --> 00:04:51,930 it's as simple as hitting the up arrow and hitting 2. 62 63 00:04:51,930 --> 00:04:57,590 So for me, it's a lot about speed and a lot about control. 63 64 00:04:57,600 --> 00:05:05,540 The other thing that you notice that is very prevalent with the Mac sort of environment or the Apple 64 65 00:05:05,570 --> 00:05:14,330 Ethos is to try and hide a lot of the unnecessary things from the common user. 65 66 00:05:14,420 --> 00:05:19,640 So that includes things like files and folders as well. 66 67 00:05:19,910 --> 00:05:25,970 For example, by default, your library inside your Mac is actually hidden. 67 68 00:05:25,970 --> 00:05:26,810 Now, of course, I haven't 68 69 00:05:26,810 --> 00:05:32,690 been able to show students how to navigate to certain places using the graphical user interface. But by default, 69 70 00:05:32,810 --> 00:05:40,610 Apple's stance is to make the user interface as simple and avoid confusion as much as possible, 70 71 00:05:40,640 --> 00:05:46,790 but it's slightly paternalistic. But with the command line, you have full control and you have a lot of 71 72 00:05:46,790 --> 00:05:48,130 flexibility. 72 73 00:05:48,140 --> 00:05:55,070 So, for example, right now, let's just delete these two folders that I won't need. 73 74 00:05:55,070 --> 00:05:58,820 On my desktop, you can only see one folder with no files, called App Development, right? 74 75 00:05:58,830 --> 00:06:05,810 So I'm on my desktop at the moment inside Finder. But, actually, if you use Terminal, you can actually list 75 76 00:06:05,840 --> 00:06:06,930 all the files. 76 77 00:06:07,020 --> 00:06:09,940 And if I just add this dash a flag, you would actually see that 77 78 00:06:09,940 --> 00:06:16,250 I've also got a folder called SecretStuff, and you can create these hidden folders by simply writing 78 79 00:06:16,250 --> 00:06:18,980 mkdir., say, Secrets. 79 80 00:06:19,310 --> 00:06:25,620 And now if I list again, I've now got two secret folders. And later on, what we're going to teach you 80 81 00:06:25,970 --> 00:06:32,420 Git and version control. We're going to be using the command line really heavily to show you the easiest 81 82 00:06:32,540 --> 00:06:39,720 and, probably, the most popular way amongst developers at least of using Git and version control. 82 83 00:06:39,770 --> 00:06:43,850 So I hope I've sold you on the virtues of the command line. 83 84 00:06:43,850 --> 00:06:48,490 So without further ado, let's get started learning how to use it, 84 85 00:06:48,620 --> 00:06:52,860 what are some of the most common commands, and some tips and tricks as well.