[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.48,0:00:02.48,Default,,0000,0000,0000,,Okay, can everyone hear me okay? Dialogue: 0,0:00:03.72,0:00:06.16,Default,,0000,0000,0000,,Okay, so welcome back. Dialogue: 0,0:00:06.16,0:00:10.32,Default,,0000,0000,0000,,I'm gonna address a couple of items\Nin kind of the administratrivia. Dialogue: 0,0:00:10.64,0:00:13.08,Default,,0000,0000,0000,,With the end of the first week, Dialogue: 0,0:00:13.18,0:00:16.35,Default,,0000,0000,0000,,we sent an email, noticing you that Dialogue: 0,0:00:16.60,0:00:20.22,Default,,0000,0000,0000,,we have uploaded the videos for the first\Nweek, so you can now find them online. Dialogue: 0,0:00:20.47,0:00:26.67,Default,,0000,0000,0000,,They have all the screen recordings for the things\Nthat we were doing, so you can go back to them. Dialogue: 0,0:00:26.83,0:00:31.44,Default,,0000,0000,0000,,Look if you're were confused about if\Nwe did something quick and, again, Dialogue: 0,0:00:31.44,0:00:37.56,Default,,0000,0000,0000,,feel free to ask us any questions if anything in the\Nlecture notes is not clear. We also sent you a Dialogue: 0,0:00:37.88,0:00:42.36,Default,,0000,0000,0000,,survey so you can give us feedback\Nabout what was not clear, Dialogue: 0,0:00:42.36,0:00:46.28,Default,,0000,0000,0000,,what items you would want a\Nmore thorough explanation or Dialogue: 0,0:00:47.11,0:00:51.75,Default,,0000,0000,0000,,just any other item, if you're finding\Nthe exercises too hard, too easy, Dialogue: 0,0:00:52.24,0:00:55.29,Default,,0000,0000,0000,,go into that URL and we'll really Dialogue: 0,0:00:55.96,0:01:00.04,Default,,0000,0000,0000,,appreciate getting that feedback, because\Nthat will make the course better Dialogue: 0,0:01:00.48,0:01:03.80,Default,,0000,0000,0000,,for the remaining lectures and for\Nfuture iterations of the course. Dialogue: 0,0:01:05.08,0:01:07.08,Default,,0000,0000,0000,,With that out of the way Dialogue: 0,0:01:07.08,0:01:10.84,Default,,0000,0000,0000,,Oh, and we're gonna try to upload the\Nvideos in a more timely manner. Dialogue: 0,0:01:11.20,0:01:16.04,Default,,0000,0000,0000,,We don't want to kind of wait until the end of\Nthe week for that. So keep tuned for that. Dialogue: 0,0:01:18.76,0:01:19.84,Default,,0000,0000,0000,,That out of the way, Dialogue: 0,0:01:19.92,0:01:20.80,Default,,0000,0000,0000,,now I'm gonna Dialogue: 0,0:01:21.12,0:01:24.96,Default,,0000,0000,0000,,This lecture's called command-line\Nenvironment and we're Dialogue: 0,0:01:25.16,0:01:28.44,Default,,0000,0000,0000,,going to cover a few different topics. So the Dialogue: 0,0:01:28.99,0:01:30.99,Default,,0000,0000,0000,,main topics we're gonna Dialogue: 0,0:01:32.04,0:01:34.52,Default,,0000,0000,0000,,cover, so you can keep track, Dialogue: 0,0:01:34.68,0:01:36.40,Default,,0000,0000,0000,,it's probably better here, Dialogue: 0,0:01:36.40,0:01:37.72,Default,,0000,0000,0000,,keep track of what I'm talking. Dialogue: 0,0:01:37.92,0:01:41.56,Default,,0000,0000,0000,,The first is gonna be job control. Dialogue: 0,0:01:42.04,0:01:44.28,Default,,0000,0000,0000,,The second one is going to be Dialogue: 0,0:01:44.60,0:01:46.60,Default,,0000,0000,0000,,terminal multiplexers. Dialogue: 0,0:01:51.72,0:01:57.36,Default,,0000,0000,0000,,Then I'm going to explain what dotfiles\Nare and how to configure your shell. Dialogue: 0,0:01:57.36,0:02:03.24,Default,,0000,0000,0000,,And lastly, how to efficiently work with\Nremote machines. So if things are not Dialogue: 0,0:02:05.11,0:02:07.59,Default,,0000,0000,0000,,fully clear, kind of keep the structure. Dialogue: 0,0:02:08.20,0:02:12.32,Default,,0000,0000,0000,,They all kind of interact in some\Nway, of how you use your terminal, Dialogue: 0,0:02:12.88,0:02:17.28,Default,,0000,0000,0000,,but they are somewhat separate\Ntopics, so keep that in mind. Dialogue: 0,0:02:17.60,0:02:23.80,Default,,0000,0000,0000,,So let's go with job control. So far we have\Nbeen using the shell in a very, kind of Dialogue: 0,0:02:24.80,0:02:27.72,Default,,0000,0000,0000,,mono-command way. Like, you\Nexecute a command and then Dialogue: 0,0:02:27.84,0:02:31.80,Default,,0000,0000,0000,,the command executes, then you get some output,\Nand that's all about what you can do. Dialogue: 0,0:02:32.20,0:02:36.52,Default,,0000,0000,0000,,And if you want to run several\Nthings, it's not clear Dialogue: 0,0:02:36.54,0:02:41.10,Default,,0000,0000,0000,,how you will do it. Or if you want to stop\Nthe execution of a program, it's again, Dialogue: 0,0:02:41.10,0:02:43.77,Default,,0000,0000,0000,,like how do I know how to stop a program? Dialogue: 0,0:02:44.65,0:02:47.94,Default,,0000,0000,0000,,Let's showcase this with a command called sleep. Dialogue: 0,0:02:48.16,0:02:50.32,Default,,0000,0000,0000,,Sleep is a command that takes an argument, Dialogue: 0,0:02:50.32,0:02:54.36,Default,,0000,0000,0000,,and that argument is going to be an\Ninteger number, and it will sleep. Dialogue: 0,0:02:54.36,0:02:58.44,Default,,0000,0000,0000,,It will just kind of be there, on the\Nbackground, for that many seconds. Dialogue: 0,0:02:58.44,0:03:03.54,Default,,0000,0000,0000,,So if we do something like sleep 20, this process\Nis gonna be sleeping for 20 seconds. Dialogue: 0,0:03:03.54,0:03:07.72,Default,,0000,0000,0000,,But we don't want to wait 20 seconds\Nfor the command to complete. Dialogue: 0,0:03:08.04,0:03:10.80,Default,,0000,0000,0000,,So what we can do is type "Ctrl+C". Dialogue: 0,0:03:10.84,0:03:12.58,Default,,0000,0000,0000,,By typing "Ctrl+C" Dialogue: 0,0:03:12.58,0:03:17.84,Default,,0000,0000,0000,,We can see that, here, the terminal let us know, Dialogue: 0,0:03:18.88,0:03:22.84,Default,,0000,0000,0000,,and it's part of the syntax that we covered\Nin the editors / Vim lecture, Dialogue: 0,0:03:23.00,0:03:27.20,Default,,0000,0000,0000,,that we typed "Ctrl+C" and it stopped\Nthe execution of the process. Dialogue: 0,0:03:27.64,0:03:29.64,Default,,0000,0000,0000,,What is actually going on here Dialogue: 0,0:03:29.88,0:03:34.84,Default,,0000,0000,0000,,is that this is using a UNIX communication\Nmechanism called signals. Dialogue: 0,0:03:35.12,0:03:37.36,Default,,0000,0000,0000,,When we type "Ctrl+C", Dialogue: 0,0:03:37.80,0:03:42.08,Default,,0000,0000,0000,,what the terminal did for us,\Nor the shell did for us, Dialogue: 0,0:03:42.16,0:03:45.96,Default,,0000,0000,0000,,is send a signal called SIGINT, Dialogue: 0,0:03:45.96,0:03:51.32,Default,,0000,0000,0000,,that stands for SIGnal INTerrupt, that\Ntells the program to stop itself. Dialogue: 0,0:03:51.68,0:03:57.52,Default,,0000,0000,0000,,And there are many, many, many signals\Nof this kind. If you do man signal, Dialogue: 0,0:03:58.88,0:04:05.06,Default,,0000,0000,0000,,and just go down a little bit,\Nhere you have a list of them. Dialogue: 0,0:04:05.06,0:04:07.04,Default,,0000,0000,0000,,They all have number identifiers, Dialogue: 0,0:04:07.52,0:04:10.64,Default,,0000,0000,0000,,they have kind of a short name\Nand you can find a description. Dialogue: 0,0:04:10.96,0:04:16.40,Default,,0000,0000,0000,,So for example, the one I have just\Ndescribed is here, number 2, SIGINT. Dialogue: 0,0:04:16.52,0:04:22.20,Default,,0000,0000,0000,,This is the signal that a terminal will send to a\Nprogram when it wants to interrupt its execution. Dialogue: 0,0:04:22.52,0:04:25.84,Default,,0000,0000,0000,,A few more to be familiar with Dialogue: 0,0:04:26.46,0:04:28.53,Default,,0000,0000,0000,,is SIGQUIT, this is Dialogue: 0,0:04:29.23,0:04:34.41,Default,,0000,0000,0000,,again, if you work from a terminal and you\Nwant to quit the execution of a program. Dialogue: 0,0:04:34.41,0:04:37.72,Default,,0000,0000,0000,,For most programs it will do the same thing, Dialogue: 0,0:04:37.72,0:04:41.12,Default,,0000,0000,0000,,but we're gonna showcase now a program\Nwhich will be different, Dialogue: 0,0:04:41.44,0:04:43.76,Default,,0000,0000,0000,,and this is the signal that will be sent. Dialogue: 0,0:04:44.68,0:04:49.23,Default,,0000,0000,0000,,It can be confusing sometimes. Looking at\Nthese signals, for example, the SIGTERM is Dialogue: 0,0:04:50.08,0:04:54.10,Default,,0000,0000,0000,,for most cases equivalent to SIGINT and SIGQUIT Dialogue: 0,0:04:54.48,0:04:58.38,Default,,0000,0000,0000,,but it's just when it's not\Nsent through a terminal. Dialogue: 0,0:04:59.68,0:05:01.68,Default,,0000,0000,0000,,A few more that we're gonna Dialogue: 0,0:05:01.90,0:05:06.21,Default,,0000,0000,0000,,cover is SIGHUP, it's when there's\Nlike a hang-up in the terminal. Dialogue: 0,0:05:06.21,0:05:10.20,Default,,0000,0000,0000,,So for example, when you are in your\Nterminal, if you close your terminal Dialogue: 0,0:05:10.20,0:05:13.35,Default,,0000,0000,0000,,and there are still things\Nrunning in the terminal, Dialogue: 0,0:05:13.48,0:05:17.00,Default,,0000,0000,0000,,that's the signal that the program is gonna send Dialogue: 0,0:05:17.00,0:05:19.96,Default,,0000,0000,0000,,to all the processes to tell\Nthat they should close, Dialogue: 0,0:05:19.96,0:05:25.08,Default,,0000,0000,0000,,like there was a hang-up in the\Ncommand line communication Dialogue: 0,0:05:25.08,0:05:26.80,Default,,0000,0000,0000,,and they should close now. Dialogue: 0,0:05:28.40,0:05:34.26,Default,,0000,0000,0000,,Signals can do more things than just stopping, interrupting\Nprograms and asking them to finish. Dialogue: 0,0:05:34.26,0:05:36.84,Default,,0000,0000,0000,,You can for example use the Dialogue: 0,0:05:37.52,0:05:43.84,Default,,0000,0000,0000,,SIGSTOP to pause the execution of the\Nprogram, and then you can use the Dialogue: 0,0:05:44.48,0:05:50.16,Default,,0000,0000,0000,,SIGCONT command for continuing, to continue the execution\Nof the program at a point later in time. Dialogue: 0,0:05:51.16,0:05:55.44,Default,,0000,0000,0000,,Since all of this might be slightly too\Nabstract, let's see a few examples. Dialogue: 0,0:05:58.04,0:06:00.56,Default,,0000,0000,0000,,First, let's showcase a Dialogue: 0,0:06:01.96,0:06:06.24,Default,,0000,0000,0000,,Python program. I'm going to very\Nquickly go through the program. Dialogue: 0,0:06:06.44,0:06:08.36,Default,,0000,0000,0000,,This is a Python program, Dialogue: 0,0:06:08.72,0:06:10.76,Default,,0000,0000,0000,,that like most python programs, Dialogue: 0,0:06:11.52,0:06:13.96,Default,,0000,0000,0000,,is importing this signal library and Dialogue: 0,0:06:14.96,0:06:20.40,Default,,0000,0000,0000,,is defining this handler here.\NAnd this handler is writing, Dialogue: 0,0:06:20.44,0:06:23.04,Default,,0000,0000,0000,,"Oh, I got a SIGINT, but\NI'm not gonna stop here". Dialogue: 0,0:06:23.48,0:06:24.96,Default,,0000,0000,0000,,And after that, Dialogue: 0,0:06:24.96,0:06:30.72,Default,,0000,0000,0000,,we tell Python that we want this program,\Nwhen it gets a SIGINT, to stop. Dialogue: 0,0:06:31.12,0:06:34.88,Default,,0000,0000,0000,,The rest of the program is a very silly program\Nthat is just going to be printing numbers. Dialogue: 0,0:06:35.06,0:06:37.54,Default,,0000,0000,0000,,So let's see this in action. Dialogue: 0,0:06:37.56,0:06:39.56,Default,,0000,0000,0000,,We do Python SIGINT. Dialogue: 0,0:06:39.88,0:06:44.97,Default,,0000,0000,0000,,And it's counting. We try doing\N"Ctrl+C", this sends a SIGINT, Dialogue: 0,0:06:44.97,0:06:50.00,Default,,0000,0000,0000,,but the program didn't actually stop. This\Nis because we have a way in the program of Dialogue: 0,0:06:50.40,0:06:54.60,Default,,0000,0000,0000,,dealing with this exception,\Nand we didn't want to exit. Dialogue: 0,0:06:54.76,0:06:57.60,Default,,0000,0000,0000,,If we send a SIGQUIT, which is done through Dialogue: 0,0:06:57.80,0:07:03.68,Default,,0000,0000,0000,,"Ctrl+\", here, we can see that since the program\Ndoesn't have a way of dealing with SIGQUIT, Dialogue: 0,0:07:03.73,0:07:06.27,Default,,0000,0000,0000,,it does the default operation, which is Dialogue: 0,0:07:06.82,0:07:08.80,Default,,0000,0000,0000,,terminate the program. Dialogue: 0,0:07:09.08,0:07:11.46,Default,,0000,0000,0000,,And you could use this, for example, Dialogue: 0,0:07:11.88,0:07:15.88,Default,,0000,0000,0000,,if someone Ctrl+C's your program, and your\Nprogram is supposed to do something, Dialogue: 0,0:07:16.04,0:07:19.32,Default,,0000,0000,0000,,like you maybe want to save the intermediate\Nstate of your program Dialogue: 0,0:07:19.32,0:07:21.52,Default,,0000,0000,0000,,to a file, so you can recover it for later. Dialogue: 0,0:07:21.60,0:07:25.64,Default,,0000,0000,0000,,This is how you could write a handler like this. Dialogue: 0,0:07:29.52,0:07:30.72,Default,,0000,0000,0000,,Can you repeat the question? Dialogue: 0,0:07:30.88,0:07:32.28,Default,,0000,0000,0000,,What did you type right now, when it stopped? Dialogue: 0,0:07:32.48,0:07:34.48,Default,,0000,0000,0000,,So I... Dialogue: 0,0:07:34.63,0:07:38.88,Default,,0000,0000,0000,,So what I typed is, I type\N"Ctrl+C" to try to stop it Dialogue: 0,0:07:38.88,0:07:42.87,Default,,0000,0000,0000,,but it didn't, because SIGINT is captured\Nby the program. Then I type Dialogue: 0,0:07:43.12,0:07:48.04,Default,,0000,0000,0000,,"Ctrl+\", which sends a SIGQUIT,\Nwhich is a different signal, Dialogue: 0,0:07:49.00,0:07:51.72,Default,,0000,0000,0000,,and this signal is not captured by the program. Dialogue: 0,0:07:52.09,0:07:54.87,Default,,0000,0000,0000,,It's also worth mentioning\Nthat there is a couple of Dialogue: 0,0:07:54.97,0:07:59.97,Default,,0000,0000,0000,,signals that cannot be captured by software.\NThere is a couple of signals Dialogue: 0,0:08:00.82,0:08:02.82,Default,,0000,0000,0000,,like SIGKILL Dialogue: 0,0:08:03.94,0:08:06.60,Default,,0000,0000,0000,,that cannot be captured. Like that, it will Dialogue: 0,0:08:06.66,0:08:09.30,Default,,0000,0000,0000,,terminate the execution of the\Nprocess, no matter what. Dialogue: 0,0:08:09.30,0:08:12.00,Default,,0000,0000,0000,,And it can be sometimes harmful.\NYou do not want to be using it by Dialogue: 0,0:08:12.00,0:08:16.46,Default,,0000,0000,0000,,default, because this can leave for example an\Norphan child, orphaned children processes. Dialogue: 0,0:08:16.47,0:08:20.94,Default,,0000,0000,0000,,Like if a process has other small children\Nprocesses that it started, and you Dialogue: 0,0:08:21.40,0:08:25.47,Default,,0000,0000,0000,,SIGKILL it, all of those will\Nkeep running in there, Dialogue: 0,0:08:25.76,0:08:30.80,Default,,0000,0000,0000,,but they won't have a parent, and you can maybe\Nhave a really weird behavior going on. Dialogue: 0,0:08:32.04,0:08:35.68,Default,,0000,0000,0000,,What signal is given to the\Nprogram if we log off? Dialogue: 0,0:08:35.80,0:08:37.44,Default,,0000,0000,0000,,If you log off? Dialogue: 0,0:08:37.92,0:08:41.92,Default,,0000,0000,0000,,That would be... so for example, if you're in an\NSSH connection and you close the connection, Dialogue: 0,0:08:41.92,0:08:45.60,Default,,0000,0000,0000,,that is the hang-up signal, Dialogue: 0,0:08:45.60,0:08:51.20,Default,,0000,0000,0000,,SIGHUP, which I'm gonna cover in an example.\NSo this is what would be sent up. Dialogue: 0,0:08:51.56,0:08:56.36,Default,,0000,0000,0000,,And you could write for example, if you want\Nthe process to keep working even if you close Dialogue: 0,0:08:56.96,0:09:02.56,Default,,0000,0000,0000,,that, you can write a wrapper around\Nthat to ignore that signal. Dialogue: 0,0:09:04.72,0:09:09.76,Default,,0000,0000,0000,,Let's display what we could do\Nwith the stop and continue. Dialogue: 0,0:09:09.98,0:09:16.39,Default,,0000,0000,0000,,So, for example, we can start a really long process.\NLet's sleep a thousand, we're gonna take forever. Dialogue: 0,0:09:16.96,0:09:18.92,Default,,0000,0000,0000,,We can control-c, Dialogue: 0,0:09:18.92,0:09:20.36,Default,,0000,0000,0000,,"Ctrl+Z", sorry, Dialogue: 0,0:09:20.36,0:09:25.28,Default,,0000,0000,0000,,and if we do "Ctrl+Z" we can see that the\Nterminal is saying "it's suspended". Dialogue: 0,0:09:25.40,0:09:31.52,Default,,0000,0000,0000,,What this actually meant is that this process\Nwas sent a SIGSTOP signal and now is Dialogue: 0,0:09:31.90,0:09:36.90,Default,,0000,0000,0000,,still there, you could continue its execution, but right\Nnow it's completely stopped and in the background Dialogue: 0,0:09:38.58,0:09:41.72,Default,,0000,0000,0000,,and we can launch a different program. Dialogue: 0,0:09:41.72,0:09:43.68,Default,,0000,0000,0000,,When we try to run this program, Dialogue: 0,0:09:43.68,0:09:46.62,Default,,0000,0000,0000,,please notice that I have included\Nan "&" at the end. Dialogue: 0,0:09:46.82,0:09:52.38,Default,,0000,0000,0000,,This tells bash that I want this program\Nto start running in the background. Dialogue: 0,0:09:52.56,0:09:55.66,Default,,0000,0000,0000,,This is kind of related to all these Dialogue: 0,0:09:55.66,0:09:59.72,Default,,0000,0000,0000,,concepts of running programs in\Nthe shell, but backgrounded. Dialogue: 0,0:10:00.35,0:10:04.36,Default,,0000,0000,0000,,And what is gonna happen is\Nthe program is gonna start Dialogue: 0,0:10:04.72,0:10:07.58,Default,,0000,0000,0000,,but it's not gonna take over my prompt. Dialogue: 0,0:10:07.58,0:10:11.54,Default,,0000,0000,0000,,If I just ran this command without\Nthis, I could not do anything. Dialogue: 0,0:10:11.54,0:10:15.82,Default,,0000,0000,0000,,I would have no access to the prompt\Nuntil the command either finished Dialogue: 0,0:10:16.06,0:10:19.38,Default,,0000,0000,0000,,or I ended it abruptly. But if I do this, Dialogue: 0,0:10:19.52,0:10:23.08,Default,,0000,0000,0000,,it's saying "there's a new\Nprocess which is this". Dialogue: 0,0:10:23.08,0:10:25.18,Default,,0000,0000,0000,,This is the process identifying number, Dialogue: 0,0:10:25.18,0:10:26.94,Default,,0000,0000,0000,,we can ignore this for now. Dialogue: 0,0:10:27.80,0:10:32.92,Default,,0000,0000,0000,,If I type the command "jobs", I get the\Noutput that I have a suspended job Dialogue: 0,0:10:32.92,0:10:35.80,Default,,0000,0000,0000,,that is the "sleep 1000" job. Dialogue: 0,0:10:36.04,0:10:38.10,Default,,0000,0000,0000,,And then I have another running job, Dialogue: 0,0:10:38.12,0:10:42.20,Default,,0000,0000,0000,,which is this "NOHUP sleep 2000". Dialogue: 0,0:10:42.64,0:10:45.66,Default,,0000,0000,0000,,Say I want to continue the first job. Dialogue: 0,0:10:45.66,0:10:48.52,Default,,0000,0000,0000,,The first job is suspended,\Nit's not executing anymore. Dialogue: 0,0:10:48.64,0:10:52.60,Default,,0000,0000,0000,,I can continue that doing "BG %1" Dialogue: 0,0:10:53.87,0:10:58.36,Default,,0000,0000,0000,,That "%" is referring to the fact that\NI want to refer to this specific Dialogue: 0,0:11:00.28,0:11:04.28,Default,,0000,0000,0000,,process. And now, if I do that\Nand I look at the jobs, Dialogue: 0,0:11:04.30,0:11:06.46,Default,,0000,0000,0000,,now this job is running again. Now Dialogue: 0,0:11:06.46,0:11:08.94,Default,,0000,0000,0000,,both of them are running. Dialogue: 0,0:11:09.30,0:11:13.82,Default,,0000,0000,0000,,If I wanted to stop these all,\NI can use the kill command. Dialogue: 0,0:11:14.04,0:11:16.06,Default,,0000,0000,0000,,The kill command Dialogue: 0,0:11:16.22,0:11:18.62,Default,,0000,0000,0000,,is for killing jobs, Dialogue: 0,0:11:19.18,0:11:22.08,Default,,0000,0000,0000,,which is just stopping them, intuitively, Dialogue: 0,0:11:22.12,0:11:23.76,Default,,0000,0000,0000,,but actually it's really useful. Dialogue: 0,0:11:23.86,0:11:28.20,Default,,0000,0000,0000,,The kill command just allows you\Nto send any sort of Unix signal. Dialogue: 0,0:11:28.36,0:11:32.22,Default,,0000,0000,0000,,So here for example, instead\Nof killing it completely, Dialogue: 0,0:11:32.22,0:11:34.64,Default,,0000,0000,0000,,we just send a stop signal. Dialogue: 0,0:11:34.64,0:11:39.16,Default,,0000,0000,0000,,Here I'm gonna send a stop signal, which\Nis gonna pause the process again. Dialogue: 0,0:11:39.16,0:11:41.28,Default,,0000,0000,0000,,I still have to include the identifier, Dialogue: 0,0:11:41.60,0:11:46.48,Default,,0000,0000,0000,,because without the identifier the shell wouldn't know\Nwhether to stop the first one or the second one. Dialogue: 0,0:11:47.48,0:11:52.48,Default,,0000,0000,0000,,Now it's said this has been suspended,\Nbecause there was a signal sent. Dialogue: 0,0:11:52.62,0:11:57.36,Default,,0000,0000,0000,,If I do "jobs", again, we can see\Nthat the second one is running Dialogue: 0,0:11:57.46,0:12:00.74,Default,,0000,0000,0000,,and the first one has been stopped. Dialogue: 0,0:12:01.42,0:12:04.30,Default,,0000,0000,0000,,Going back to one of the questions, Dialogue: 0,0:12:04.30,0:12:06.98,Default,,0000,0000,0000,,what happens when you close\Nthe cell, for example, Dialogue: 0,0:12:06.98,0:12:12.86,Default,,0000,0000,0000,,and why sometimes people will say that\Nyou should use this NOHUP command Dialogue: 0,0:12:12.86,0:12:15.96,Default,,0000,0000,0000,,before your run jobs in a remote session. Dialogue: 0,0:12:16.22,0:12:23.12,Default,,0000,0000,0000,,This is because if we try to send\Na hung up command to the first job Dialogue: 0,0:12:23.56,0:12:27.82,Default,,0000,0000,0000,,it's gonna, in a similar fashion\Nas the other signals, Dialogue: 0,0:12:27.82,0:12:32.28,Default,,0000,0000,0000,,it's gonna hang it up and that's\Ngonna terminate the job. Dialogue: 0,0:12:32.80,0:12:35.96,Default,,0000,0000,0000,,And the first job isn't there anymore Dialogue: 0,0:12:36.32,0:12:39.14,Default,,0000,0000,0000,,whereas we have still the second job running. Dialogue: 0,0:12:39.40,0:12:42.92,Default,,0000,0000,0000,,However, if we try to send the\Nsignal to the second job Dialogue: 0,0:12:42.92,0:12:46.06,Default,,0000,0000,0000,,what will happen if we close\Nour terminal right now Dialogue: 0,0:12:47.04,0:12:48.66,Default,,0000,0000,0000,,is it's still running. Dialogue: 0,0:12:48.66,0:12:52.48,Default,,0000,0000,0000,,Like NOHUP, what it's doing\Nis kind of encapsulating Dialogue: 0,0:12:52.48,0:12:54.48,Default,,0000,0000,0000,,whatever command you're executing and Dialogue: 0,0:12:54.74,0:12:58.72,Default,,0000,0000,0000,,ignoring wherever you get a hang up signal, Dialogue: 0,0:12:58.90,0:13:03.68,Default,,0000,0000,0000,,and just ignoring that so it can keep running. Dialogue: 0,0:13:05.06,0:13:08.50,Default,,0000,0000,0000,,And if we send the "kill"\Nsignal to the second job, Dialogue: 0,0:13:08.50,0:13:12.82,Default,,0000,0000,0000,,that one can't be ignored and that\Nwill kill the job, no matter what. Dialogue: 0,0:13:13.28,0:13:15.78,Default,,0000,0000,0000,,And we don't have any jobs anymore. Dialogue: 0,0:13:17.00,0:13:22.54,Default,,0000,0000,0000,,That kind of completes the\Nsection on job control. Dialogue: 0,0:13:22.74,0:13:27.10,Default,,0000,0000,0000,,Any questions so far? Anything\Nthat wasn't fully clear? Dialogue: 0,0:13:29.04,0:13:30.40,Default,,0000,0000,0000,,What does BG do? Dialogue: 0,0:13:30.96,0:13:31.80,Default,,0000,0000,0000,,So BG... Dialogue: 0,0:13:31.80,0:13:36.86,Default,,0000,0000,0000,,There are like two commands. Whenever you\Nhave a command that has been backgrounded Dialogue: 0,0:13:37.20,0:13:41.82,Default,,0000,0000,0000,,and is stopped you can use\NBG (short for background) Dialogue: 0,0:13:41.82,0:13:44.18,Default,,0000,0000,0000,,to continue that process running\Non the background. Dialogue: 0,0:13:44.44,0:13:47.40,Default,,0000,0000,0000,,That's equivalent of just kind of sending it Dialogue: 0,0:13:47.68,0:13:50.82,Default,,0000,0000,0000,,a continue signal, so it keeps running. Dialogue: 0,0:13:50.82,0:13:54.82,Default,,0000,0000,0000,,And then there's another one which\Nis called FG, if you want to Dialogue: 0,0:13:54.86,0:13:59.58,Default,,0000,0000,0000,,recover it to the foreground and you want\Nto reattach your standard output. Dialogue: 0,0:14:04.76,0:14:06.76,Default,,0000,0000,0000,,Okay, good. Dialogue: 0,0:14:07.12,0:14:11.42,Default,,0000,0000,0000,,Jobs are useful and in general, I\Nthink knowing about signals can be Dialogue: 0,0:14:11.42,0:14:14.36,Default,,0000,0000,0000,,really beneficial when dealing\Nwith some part of Unix Dialogue: 0,0:14:14.36,0:14:19.42,Default,,0000,0000,0000,,but most of the time what you actually want\Nto do is something along the lines of Dialogue: 0,0:14:19.67,0:14:24.10,Default,,0000,0000,0000,,having your editor in one side and then\Nthe program in another, and maybe Dialogue: 0,0:14:24.72,0:14:28.28,Default,,0000,0000,0000,,monitoring what the resource\Nconsumption is in our tab. Dialogue: 0,0:14:28.68,0:14:33.64,Default,,0000,0000,0000,,We could achieve this using probably\Nwhat you have seen a lot of the time, Dialogue: 0,0:14:33.64,0:14:35.20,Default,,0000,0000,0000,,which is just opening more windows. Dialogue: 0,0:14:35.20,0:14:37.20,Default,,0000,0000,0000,,We can keep opening terminal windows. Dialogue: 0,0:14:37.32,0:14:41.28,Default,,0000,0000,0000,,But the fact is there are kind of more\Nconvenient solutions to this and Dialogue: 0,0:14:41.28,0:14:43.80,Default,,0000,0000,0000,,this is what a terminal multiplexer does. Dialogue: 0,0:14:44.08,0:14:48.52,Default,,0000,0000,0000,,A terminal multiplexer like tmux Dialogue: 0,0:14:48.84,0:14:52.16,Default,,0000,0000,0000,,will let you create different workspaces\Nthat you can work in, Dialogue: 0,0:14:52.64,0:14:54.28,Default,,0000,0000,0000,,and quickly kind of, Dialogue: 0,0:14:54.28,0:14:56.96,Default,,0000,0000,0000,,this has a huge variety of functionality, Dialogue: 0,0:14:57.32,0:15:02.76,Default,,0000,0000,0000,,It will let you rearrange the environment and\Nit will let you have different sessions. Dialogue: 0,0:15:03.40,0:15:05.40,Default,,0000,0000,0000,,There's another more... Dialogue: 0,0:15:05.60,0:15:07.64,Default,,0000,0000,0000,,older command, which is called "screen", Dialogue: 0,0:15:07.64,0:15:09.36,Default,,0000,0000,0000,,that might be more readily available. Dialogue: 0,0:15:09.36,0:15:12.20,Default,,0000,0000,0000,,But I think the concept kind\Nof extrapolates to both. Dialogue: 0,0:15:12.60,0:15:15.40,Default,,0000,0000,0000,,We recommend tmux, that you go and learn it. Dialogue: 0,0:15:15.40,0:15:17.48,Default,,0000,0000,0000,,And in fact, we have exercises on it. Dialogue: 0,0:15:17.48,0:15:20.24,Default,,0000,0000,0000,,I'm gonna showcase a different\Nscenario right now. Dialogue: 0,0:15:20.32,0:15:22.00,Default,,0000,0000,0000,,So whenever I talked... Dialogue: 0,0:15:22.32,0:15:24.88,Default,,0000,0000,0000,,Oh, let me make a quick note. Dialogue: 0,0:15:25.20,0:15:28.80,Default,,0000,0000,0000,,There are kind of three core concepts\Nin tmux, that I'm gonna go through and Dialogue: 0,0:15:30.11,0:15:33.13,Default,,0000,0000,0000,,the main idea is that there are what is called Dialogue: 0,0:15:35.18,0:15:37.18,Default,,0000,0000,0000,,"sessions". Dialogue: 0,0:15:37.76,0:15:40.51,Default,,0000,0000,0000,,Sessions have "windows" and Dialogue: 0,0:15:42.02,0:15:44.02,Default,,0000,0000,0000,,windows have "panes". Dialogue: 0,0:15:45.71,0:15:49.54,Default,,0000,0000,0000,,It's gonna be kind of useful to\Nkeep this hierarchy in mind. Dialogue: 0,0:15:50.76,0:15:57.28,Default,,0000,0000,0000,,You can pretty much equate "windows" to what\N"tabs" are in other editors and others, Dialogue: 0,0:15:57.28,0:16:00.72,Default,,0000,0000,0000,,like for example your web browser. Dialogue: 0,0:16:01.28,0:16:06.44,Default,,0000,0000,0000,,I'm gonna go through the features, mainly\Nwhat you can do at the different levels. Dialogue: 0,0:16:07.00,0:16:10.48,Default,,0000,0000,0000,,So first, when we do tmux, that starts a session. Dialogue: 0,0:16:11.36,0:16:14.96,Default,,0000,0000,0000,,And here right now it seems like nothing changed Dialogue: 0,0:16:14.96,0:16:20.36,Default,,0000,0000,0000,,but what's happening right now is we're within a shell\Nthat is different from the one we started before. Dialogue: 0,0:16:20.64,0:16:24.84,Default,,0000,0000,0000,,So in our shell we started\Na process, that is tmux Dialogue: 0,0:16:24.84,0:16:28.84,Default,,0000,0000,0000,,and that tmux started a different process,\Nwhich is the shell we're currently in. Dialogue: 0,0:16:28.98,0:16:30.40,Default,,0000,0000,0000,,And the nice thing about this is that Dialogue: 0,0:16:30.58,0:16:34.74,Default,,0000,0000,0000,,that tmux process is separate from\Nthe original shell process. Dialogue: 0,0:16:34.86,0:16:36.86,Default,,0000,0000,0000,,So Dialogue: 0,0:16:40.58,0:16:44.46,Default,,0000,0000,0000,,here, we can do things. Dialogue: 0,0:16:44.48,0:16:48.60,Default,,0000,0000,0000,,We can do "ls -la", for example, to\Ntell us what is going on in here. Dialogue: 0,0:16:48.92,0:16:53.96,Default,,0000,0000,0000,,And then we can start running our program,\Nand it will start running in there Dialogue: 0,0:16:54.16,0:16:57.88,Default,,0000,0000,0000,,and we can do "Ctrl+A d", for example, to detach Dialogue: 0,0:17:12.76,0:17:15.96,Default,,0000,0000,0000,,to detach from the session. Dialogue: 0,0:17:16.14,0:17:19.12,Default,,0000,0000,0000,,And if we do "tmux a" Dialogue: 0,0:17:19.16,0:17:21.56,Default,,0000,0000,0000,,that's gonna reattach us to the session. Dialogue: 0,0:17:21.56,0:17:22.30,Default,,0000,0000,0000,,So the process, Dialogue: 0,0:17:22.30,0:17:25.18,Default,,0000,0000,0000,,we abandon the process counting numbers. Dialogue: 0,0:17:25.18,0:17:28.30,Default,,0000,0000,0000,,This really silly Python program\Nthat was just counting numbers, Dialogue: 0,0:17:28.34,0:17:30.16,Default,,0000,0000,0000,,we left it running there. Dialogue: 0,0:17:30.20,0:17:31.72,Default,,0000,0000,0000,,And if we tmux... Dialogue: 0,0:17:31.72,0:17:33.76,Default,,0000,0000,0000,,Hey, the process is still running there. Dialogue: 0,0:17:33.78,0:17:37.82,Default,,0000,0000,0000,,And we could close this entire\Nterminal and open a new one and Dialogue: 0,0:17:37.88,0:17:41.86,Default,,0000,0000,0000,,we could still reattach because this\Ntmux session is still running. Dialogue: 0,0:17:43.34,0:17:45.34,Default,,0000,0000,0000,,Again, we can... Dialogue: 0,0:17:46.64,0:17:48.64,Default,,0000,0000,0000,,Before I go any further. Dialogue: 0,0:17:48.92,0:17:53.74,Default,,0000,0000,0000,,Pretty much... Unlike Vim, where\Nyou have this notion of modes, Dialogue: 0,0:17:53.96,0:17:58.18,Default,,0000,0000,0000,,tmux will work in a more emacsy way, which is Dialogue: 0,0:17:58.18,0:18:04.14,Default,,0000,0000,0000,,every command, pretty much every command in tmux, Dialogue: 0,0:18:04.22,0:18:06.02,Default,,0000,0000,0000,,you could enter it through the... Dialogue: 0,0:18:06.02,0:18:08.16,Default,,0000,0000,0000,,it has a command line, that we could use. Dialogue: 0,0:18:08.24,0:18:11.32,Default,,0000,0000,0000,,But I recommend you to get familiar\Nwith the key bindings. Dialogue: 0,0:18:11.88,0:18:15.08,Default,,0000,0000,0000,,It can be somehow non intuitive at first, Dialogue: 0,0:18:15.30,0:18:17.88,Default,,0000,0000,0000,,but once you get used to them... Dialogue: 0,0:18:22.14,0:18:23.02,Default,,0000,0000,0000,,"Ctrl+C", yeah Dialogue: 0,0:18:24.44,0:18:30.76,Default,,0000,0000,0000,,When you get familiar with them, you will be much faster\Njust using the key bindings than using the commands. Dialogue: 0,0:18:31.28,0:18:35.98,Default,,0000,0000,0000,,One note about the key bindings: all the\Nkey bindings have a form that is like Dialogue: 0,0:18:36.14,0:18:39.84,Default,,0000,0000,0000,,you type a prefix and then some key. Dialogue: 0,0:18:40.06,0:18:44.00,Default,,0000,0000,0000,,So for example, to detach we\Ndo "Ctrl+A" and then "D". Dialogue: 0,0:18:44.16,0:18:50.14,Default,,0000,0000,0000,,This means you press "Ctrl+A" first, you release\Nthat, and then press "D" to detach. Dialogue: 0,0:18:50.38,0:18:54.20,Default,,0000,0000,0000,,On default tmux, the prefix is "Ctrl+B", Dialogue: 0,0:18:54.20,0:18:58.78,Default,,0000,0000,0000,,but you will find that most people\Nwill have this remapped to "Ctrl+A" Dialogue: 0,0:18:58.78,0:19:02.68,Default,,0000,0000,0000,,because it's a much more ergonomic\Ntype on the keyboard. Dialogue: 0,0:19:02.70,0:19:06.42,Default,,0000,0000,0000,,You can find more about how to do these\Nthings in one of the exercises, Dialogue: 0,0:19:06.96,0:19:12.78,Default,,0000,0000,0000,,where we link you to the basics and how to do some\Nkind of quality of life modifications to tmux. Dialogue: 0,0:19:13.38,0:19:16.72,Default,,0000,0000,0000,,Going back to the concept of sessions, Dialogue: 0,0:19:16.96,0:19:22.12,Default,,0000,0000,0000,,we can create a new session just\Ndoing something like tmux new Dialogue: 0,0:19:22.32,0:19:24.54,Default,,0000,0000,0000,,and we can give sessions names. Dialogue: 0,0:19:24.76,0:19:27.22,Default,,0000,0000,0000,,So we can do like "tmux new -t foobar" Dialogue: 0,0:19:27.22,0:19:30.90,Default,,0000,0000,0000,,and this is a completely different\Nsession, that we have started. Dialogue: 0,0:19:32.24,0:19:36.36,Default,,0000,0000,0000,,We can work here, we can detach from it. Dialogue: 0,0:19:36.36,0:19:40.00,Default,,0000,0000,0000,,"tmux ls" will tell us that we\Nhave two different sessions: Dialogue: 0,0:19:40.00,0:19:43.46,Default,,0000,0000,0000,,the first one is named "0", because\NI didn't give it a name, Dialogue: 0,0:19:43.50,0:19:45.82,Default,,0000,0000,0000,,and the second one is called "foobar". Dialogue: 0,0:19:46.58,0:19:51.02,Default,,0000,0000,0000,,I can attach the foobar session Dialogue: 0,0:19:51.02,0:19:53.70,Default,,0000,0000,0000,,and I can end it. Dialogue: 0,0:19:54.68,0:19:56.34,Default,,0000,0000,0000,,And it's really nice because Dialogue: 0,0:19:56.34,0:20:00.14,Default,,0000,0000,0000,,having this you can kind of work\Nin completely different projects. Dialogue: 0,0:20:00.14,0:20:04.34,Default,,0000,0000,0000,,For example, having two different\Ntmux sessions and different Dialogue: 0,0:20:04.48,0:20:08.44,Default,,0000,0000,0000,,editor sessions, different processes running... Dialogue: 0,0:20:10.16,0:20:15.10,Default,,0000,0000,0000,,When you are within a session, we\Nstart with the concept of windows. Dialogue: 0,0:20:15.10,0:20:21.16,Default,,0000,0000,0000,,Here we have a single window, but we\Ncan use "Ctrl+A c" (for "create") Dialogue: 0,0:20:21.16,0:20:23.72,Default,,0000,0000,0000,,to open a new window. Dialogue: 0,0:20:24.00,0:20:26.34,Default,,0000,0000,0000,,And here nothing is executing. Dialogue: 0,0:20:26.38,0:20:29.42,Default,,0000,0000,0000,,What it's doing is, tmux has\Nopened a new shell for us Dialogue: 0,0:20:30.36,0:20:34.84,Default,,0000,0000,0000,,and we can start running another\None of these programs here. Dialogue: 0,0:20:35.46,0:20:42.46,Default,,0000,0000,0000,,And to quickly jump between the tabs,\Nwe can do "Ctrl+A" and "previous", Dialogue: 0,0:20:42.46,0:20:44.52,Default,,0000,0000,0000,,"p" for "previous", Dialogue: 0,0:20:45.22,0:20:48.02,Default,,0000,0000,0000,,and that will go up to the previous window. Dialogue: 0,0:20:48.02,0:20:50.92,Default,,0000,0000,0000,,"Ctrl+A" "next", to go to the next window. Dialogue: 0,0:20:51.26,0:20:56.06,Default,,0000,0000,0000,,You can also use the numbers. So if we\Nstart opening a lot of these tabs, Dialogue: 0,0:20:56.20,0:21:00.16,Default,,0000,0000,0000,,we could use "Ctrl+A 1", to\Nspecifically jump to the Dialogue: 0,0:21:00.24,0:21:04.40,Default,,0000,0000,0000,,to the window that is number "1". Dialogue: 0,0:21:04.78,0:21:08.62,Default,,0000,0000,0000,,And, lastly, it's also pretty\Nuseful to know sometimes Dialogue: 0,0:21:08.66,0:21:10.40,Default,,0000,0000,0000,,that you can rename them. Dialogue: 0,0:21:10.40,0:21:13.38,Default,,0000,0000,0000,,For example here I'm executing\Nthis Python process, Dialogue: 0,0:21:13.58,0:21:16.80,Default,,0000,0000,0000,,but that might not be really\Ninformative and I want... Dialogue: 0,0:21:16.88,0:21:21.16,Default,,0000,0000,0000,,I maybe want to have something like\Nexecution or something like that and Dialogue: 0,0:21:21.74,0:21:26.84,Default,,0000,0000,0000,,that will rename the name of that window so\Nyou can have this really neatly organized. Dialogue: 0,0:21:27.08,0:21:33.50,Default,,0000,0000,0000,,This still doesn't solve the need when you want to\Nhave two things at the same time in your terminal, Dialogue: 0,0:21:33.68,0:21:35.74,Default,,0000,0000,0000,,like in the same display. Dialogue: 0,0:21:35.74,0:21:38.32,Default,,0000,0000,0000,,This is what panes are for. Right now, here Dialogue: 0,0:21:38.42,0:21:40.42,Default,,0000,0000,0000,,we have a window with a single pane Dialogue: 0,0:21:40.42,0:21:43.54,Default,,0000,0000,0000,,(all the windows that we have opened\Nso far have a single pane). Dialogue: 0,0:21:43.64,0:21:50.80,Default,,0000,0000,0000,,But if we do 'Ctrl+A "' Dialogue: 0,0:21:51.04,0:21:56.54,Default,,0000,0000,0000,,this will split the current display\Ninto two different panes. Dialogue: 0,0:21:56.54,0:22:01.40,Default,,0000,0000,0000,,So, you see, the one we open below is a different\Nshell from the one we have above, Dialogue: 0,0:22:01.64,0:22:05.44,Default,,0000,0000,0000,,and we can run any process that we want here. Dialogue: 0,0:22:05.62,0:22:09.90,Default,,0000,0000,0000,,We can keep splitting this, if we do "Ctrl+A %" Dialogue: 0,0:22:10.08,0:22:15.00,Default,,0000,0000,0000,,that will split vertically. And you can kind of Dialogue: 0,0:22:15.00,0:22:18.22,Default,,0000,0000,0000,,rearrange these tabs using a\Nlot of different commands. Dialogue: 0,0:22:18.22,0:22:22.62,Default,,0000,0000,0000,,One that I find very useful, when you are\Nstarting and it's kind of frustrating, Dialogue: 0,0:22:23.54,0:22:26.00,Default,,0000,0000,0000,,rearranging them. Dialogue: 0,0:22:26.16,0:22:30.16,Default,,0000,0000,0000,,Before I explain that, to move\Nthrough these panes, which is Dialogue: 0,0:22:30.30,0:22:32.28,Default,,0000,0000,0000,,something you want to be doing all the time Dialogue: 0,0:22:32.46,0:22:37.06,Default,,0000,0000,0000,,You just do "Ctrl+A" and the arrow\Nkeys, and that will let you quickly Dialogue: 0,0:22:37.46,0:22:43.96,Default,,0000,0000,0000,,navigate through the different\Nwindows, and execute again... Dialogue: 0,0:22:44.34,0:22:46.30,Default,,0000,0000,0000,,I'm doing a lot of "ls -a" Dialogue: 0,0:22:47.34,0:22:52.78,Default,,0000,0000,0000,,I can do "HTOP", that we'll explain in\Nthe debugging and profiling lecture. Dialogue: 0,0:22:53.54,0:22:55.92,Default,,0000,0000,0000,,And we can just navigate through them, again Dialogue: 0,0:22:55.92,0:22:59.04,Default,,0000,0000,0000,,like to rearrange there's\Nanother slew of commands, Dialogue: 0,0:22:59.08,0:23:01.08,Default,,0000,0000,0000,,you will go through some in the Exercises Dialogue: 0,0:23:02.40,0:23:07.16,Default,,0000,0000,0000,,"Ctrl+A" space is pretty neat, because it\Nwill kind of equispace the current ones Dialogue: 0,0:23:07.16,0:23:10.26,Default,,0000,0000,0000,,and let you through different layouts. Dialogue: 0,0:23:11.48,0:23:14.26,Default,,0000,0000,0000,,Some of them are too small for my current Dialogue: 0,0:23:14.84,0:23:19.22,Default,,0000,0000,0000,,terminal config, but that covers,\NI think, most of it. Dialogue: 0,0:23:19.44,0:23:21.44,Default,,0000,0000,0000,,Oh, there's also, Dialogue: 0,0:23:22.66,0:23:29.20,Default,,0000,0000,0000,,here, for example, this Vim execution\Nthat we have started, Dialogue: 0,0:23:29.20,0:23:33.38,Default,,0000,0000,0000,,is too small for what the current tmux pane is. Dialogue: 0,0:23:33.72,0:23:38.24,Default,,0000,0000,0000,,So one of the things that really is\Nmuch more convenient to do in tmux, Dialogue: 0,0:23:39.18,0:23:42.50,Default,,0000,0000,0000,,in contrast to having multiple\Nterminal windows, is that Dialogue: 0,0:23:42.56,0:23:48.40,Default,,0000,0000,0000,,you can zoom into this, you can ask\Nby doing "Ctrl+A z", for "zoom". Dialogue: 0,0:23:48.40,0:23:52.96,Default,,0000,0000,0000,,It will expand the pane to\Ntake over all the space, Dialogue: 0,0:23:52.96,0:23:56.66,Default,,0000,0000,0000,,and then "Ctrl+A z", again will go back to it. Dialogue: 0,0:24:02.76,0:24:08.08,Default,,0000,0000,0000,,Any questions for terminal multiplexers,\Nor like, tmux concretely? Dialogue: 0,0:24:14.14,0:24:16.78,Default,,0000,0000,0000,,Is it running all the same thing? Dialogue: 0,0:24:18.68,0:24:22.70,Default,,0000,0000,0000,,Like, is there any difference in execution\Nbetween running it in different windows? Dialogue: 0,0:24:24.88,0:24:28.64,Default,,0000,0000,0000,,Is it really just doing it all the\Nsame, so that you can see it? Dialogue: 0,0:24:28.80,0:24:34.90,Default,,0000,0000,0000,,Yeah, it wouldn't be any different from having\Ntwo terminal windows open in your computer. Dialogue: 0,0:24:34.92,0:24:39.22,Default,,0000,0000,0000,,Like both of them are gonna be running.\NOf course, when it gets to the CPU, Dialogue: 0,0:24:39.22,0:24:41.40,Default,,0000,0000,0000,,this is gonna be multiplexed again. Dialogue: 0,0:24:41.46,0:24:44.40,Default,,0000,0000,0000,,Like there's like a timesharing\Nmechanism going there Dialogue: 0,0:24:44.48,0:24:45.92,Default,,0000,0000,0000,,but there's no difference. Dialogue: 0,0:24:46.04,0:24:52.26,Default,,0000,0000,0000,,tmux is just making this much more convenient\Nto use by giving you this visual layout Dialogue: 0,0:24:52.56,0:24:55.02,Default,,0000,0000,0000,,that you can quickly manipulate through. Dialogue: 0,0:24:55.02,0:24:59.86,Default,,0000,0000,0000,,And one of the main advantages will come\Nwhen we reach the remote machines Dialogue: 0,0:24:59.86,0:25:05.30,Default,,0000,0000,0000,,because you can leave one of these, we can\Ndetach from one of these tmux systems, Dialogue: 0,0:25:05.30,0:25:09.12,Default,,0000,0000,0000,,close the connection and even\Nif we close the connection and Dialogue: 0,0:25:09.12,0:25:11.64,Default,,0000,0000,0000,,and the terminal is gonna send a hang-up signal, Dialogue: 0,0:25:11.68,0:25:15.42,Default,,0000,0000,0000,,that's not gonna close all the\Ntmux's that have been started. Dialogue: 0,0:25:17.11,0:25:19.11,Default,,0000,0000,0000,,Any other questions? Dialogue: 0,0:25:23.62,0:25:27.98,Default,,0000,0000,0000,,Let me disable the key-caster. Dialogue: 0,0:25:33.58,0:25:38.04,Default,,0000,0000,0000,,So now we're gonna move into the topic\Nof dotfiles and, in general, Dialogue: 0,0:25:38.04,0:25:42.46,Default,,0000,0000,0000,,how to kind of configure your shell\Nto do the things you want to do Dialogue: 0,0:25:42.46,0:25:45.58,Default,,0000,0000,0000,,and mainly how to do them quicker\Nand in a more convenient way. Dialogue: 0,0:25:46.36,0:25:49.26,Default,,0000,0000,0000,,I'm gonna motivate this using aliases first. Dialogue: 0,0:25:49.38,0:25:51.06,Default,,0000,0000,0000,,So what an alias is, Dialogue: 0,0:25:51.06,0:25:54.26,Default,,0000,0000,0000,,is that by now, you might be\Nstarting to do something like Dialogue: 0,0:25:54.92,0:26:01.68,Default,,0000,0000,0000,,a lot of the time, I just want to LS a directory and\NI want to display all the contents into a list format Dialogue: 0,0:26:02.18,0:26:05.04,Default,,0000,0000,0000,,and in a human readable thing. Dialogue: 0,0:26:05.26,0:26:07.40,Default,,0000,0000,0000,,And it's fine. Like it's not\Nthat long of a command. Dialogue: 0,0:26:07.40,0:26:10.30,Default,,0000,0000,0000,,But as you start building longer\Nand longer commands, Dialogue: 0,0:26:10.32,0:26:14.44,Default,,0000,0000,0000,,it can become kind of bothersome having\Nto retype them again and again. Dialogue: 0,0:26:14.44,0:26:17.54,Default,,0000,0000,0000,,This is one of the reasons\Nwhy aliases are useful. Dialogue: 0,0:26:17.54,0:26:21.74,Default,,0000,0000,0000,,Alias is a command that will\Nbe a built-in in your shell, Dialogue: 0,0:26:21.96,0:26:23.68,Default,,0000,0000,0000,,and what it will do is Dialogue: 0,0:26:23.68,0:26:27.54,Default,,0000,0000,0000,,it will remap a short sequence of\Ncharacters to a longer sequence. Dialogue: 0,0:26:27.78,0:26:31.50,Default,,0000,0000,0000,,So if I do, for example, here Dialogue: 0,0:26:31.50,0:26:36.84,Default,,0000,0000,0000,,alias ll="ls -lah" Dialogue: 0,0:26:37.44,0:26:42.52,Default,,0000,0000,0000,,If I execute this command, this is gonna call\Nthe "alias" command with this argument Dialogue: 0,0:26:42.52,0:26:44.32,Default,,0000,0000,0000,,and the LS is going to update Dialogue: 0,0:26:44.54,0:26:49.04,Default,,0000,0000,0000,,the environment in my shell\Nto be aware of this mapping. Dialogue: 0,0:26:49.32,0:26:52.92,Default,,0000,0000,0000,,So if I now do LL, Dialogue: 0,0:26:52.92,0:26:57.52,Default,,0000,0000,0000,,it's executing that command without me\Nhaving to type the entire command. Dialogue: 0,0:26:57.72,0:27:01.18,Default,,0000,0000,0000,,It can be really handy for many, many reasons. Dialogue: 0,0:27:01.18,0:27:04.74,Default,,0000,0000,0000,,One thing to note before I go any further is that Dialogue: 0,0:27:05.00,0:27:09.96,Default,,0000,0000,0000,,here, alias is not anything special\Ncompared to other commands, Dialogue: 0,0:27:09.96,0:27:11.40,Default,,0000,0000,0000,,it's just taking a single argument. Dialogue: 0,0:27:11.68,0:27:15.60,Default,,0000,0000,0000,,And there is no space around\Nthis equals and that's Dialogue: 0,0:27:16.02,0:27:18.72,Default,,0000,0000,0000,,because alias takes a single argument Dialogue: 0,0:27:18.72,0:27:21.64,Default,,0000,0000,0000,,and if you try doing Dialogue: 0,0:27:21.96,0:27:25.12,Default,,0000,0000,0000,,something like this, that's giving\Nit more than one argument Dialogue: 0,0:27:25.12,0:27:28.36,Default,,0000,0000,0000,,and that's not gonna work because\Nthat's not the format it expects. Dialogue: 0,0:27:29.52,0:27:33.68,Default,,0000,0000,0000,,So other use cases that work for aliases, Dialogue: 0,0:27:34.72,0:27:36.55,Default,,0000,0000,0000,,as I was saying, Dialogue: 0,0:27:36.55,0:27:39.92,Default,,0000,0000,0000,,for some things it may be much more convenient, Dialogue: 0,0:27:40.04,0:27:41.02,Default,,0000,0000,0000,,like Dialogue: 0,0:27:41.02,0:27:43.20,Default,,0000,0000,0000,,one of my favorites is git status. Dialogue: 0,0:27:43.20,0:27:47.50,Default,,0000,0000,0000,,It's extremely long, and I don't like typing\Nthat long of a command every so often, Dialogue: 0,0:27:47.56,0:27:48.96,Default,,0000,0000,0000,,because you end up taking a lot of time. Dialogue: 0,0:27:49.12,0:27:53.00,Default,,0000,0000,0000,,So GS will replace for doing the git status Dialogue: 0,0:27:53.82,0:27:58.62,Default,,0000,0000,0000,,You can also use them to alias\Nthings that you mistype often, Dialogue: 0,0:27:58.62,0:28:01.16,Default,,0000,0000,0000,,so you can do "sl=ls", Dialogue: 0,0:28:01.16,0:28:02.54,Default,,0000,0000,0000,,that will work. Dialogue: 0,0:28:05.80,0:28:10.62,Default,,0000,0000,0000,,Other useful mappings are, Dialogue: 0,0:28:10.68,0:28:15.46,Default,,0000,0000,0000,,you might want to alias a command to itself Dialogue: 0,0:28:15.74,0:28:17.52,Default,,0000,0000,0000,,but with a default flag. Dialogue: 0,0:28:17.52,0:28:21.10,Default,,0000,0000,0000,,So here what is going on is I'm creating an alias Dialogue: 0,0:28:21.10,0:28:23.10,Default,,0000,0000,0000,,which is an alias for the move command, Dialogue: 0,0:28:23.30,0:28:29.78,Default,,0000,0000,0000,,which is MV and I'm aliasing it to the\Nsame command but adding the "-i" flag. Dialogue: 0,0:28:29.98,0:28:34.46,Default,,0000,0000,0000,,And this "-i" flag, if you go through the man page\Nand look at it, it stands for "interactive". Dialogue: 0,0:28:34.78,0:28:39.88,Default,,0000,0000,0000,,And what it will do is it will prompt\Nme before I do an overwrite. Dialogue: 0,0:28:39.88,0:28:44.42,Default,,0000,0000,0000,,So once I have executed this,\NI can do something like Dialogue: 0,0:28:44.70,0:28:47.36,Default,,0000,0000,0000,,I want to move "aliases" into "case". Dialogue: 0,0:28:47.70,0:28:53.14,Default,,0000,0000,0000,,By default "move" won't ask, and if "case"\Nalready exists, it will be over. Dialogue: 0,0:28:53.16,0:28:55.78,Default,,0000,0000,0000,,That's fine, I'm going to overwrite\Nwhatever that's there. Dialogue: 0,0:28:56.02,0:28:58.58,Default,,0000,0000,0000,,But here it's now expanded, Dialogue: 0,0:28:58.58,0:29:01.66,Default,,0000,0000,0000,,"move" has been expanded into this "move -i" Dialogue: 0,0:29:01.66,0:29:03.54,Default,,0000,0000,0000,,and it's using that to ask me Dialogue: 0,0:29:03.54,0:29:07.40,Default,,0000,0000,0000,,"Oh, are you sure you want to overwrite this?" Dialogue: 0,0:29:07.70,0:29:11.78,Default,,0000,0000,0000,,And I can say no, I don't want to lose that file. Dialogue: 0,0:29:12.18,0:29:15.82,Default,,0000,0000,0000,,Lastly, you can use "alias move" Dialogue: 0,0:29:15.82,0:29:18.52,Default,,0000,0000,0000,,to ask for what this alias stands for. Dialogue: 0,0:29:19.10,0:29:22.06,Default,,0000,0000,0000,,So it will tell you so you can quickly make sure Dialogue: 0,0:29:22.08,0:29:25.40,Default,,0000,0000,0000,,what the command that you\Nare executing actually is. Dialogue: 0,0:29:27.04,0:29:31.40,Default,,0000,0000,0000,,One inconvenient part about, for example,\Nhaving aliases is how will you go about Dialogue: 0,0:29:31.76,0:29:35.34,Default,,0000,0000,0000,,persisting them into your current environment? Dialogue: 0,0:29:35.50,0:29:38.12,Default,,0000,0000,0000,,Like, if I were to close this terminal now, Dialogue: 0,0:29:38.28,0:29:40.16,Default,,0000,0000,0000,,all these aliases will go away. Dialogue: 0,0:29:40.16,0:29:43.02,Default,,0000,0000,0000,,And you don't want to be kind\Nof retyping these commands Dialogue: 0,0:29:43.02,0:29:46.76,Default,,0000,0000,0000,,and more generally, if you start configuring\Nyour shell more and more, Dialogue: 0,0:29:46.86,0:29:50.88,Default,,0000,0000,0000,,you want some way of bootstrapping\Nall this configuration. Dialogue: 0,0:29:51.38,0:29:56.78,Default,,0000,0000,0000,,You will find that most shell command programs Dialogue: 0,0:29:56.88,0:30:01.44,Default,,0000,0000,0000,,will use some sort of text\Nbased configuration file. Dialogue: 0,0:30:01.44,0:30:06.74,Default,,0000,0000,0000,,And this is what we usually call "dotfiles", because\Nthey start with a dot for historical reasons. Dialogue: 0,0:30:07.06,0:30:13.16,Default,,0000,0000,0000,,So for bash in our case, which is a shell, Dialogue: 0,0:30:13.16,0:30:15.56,Default,,0000,0000,0000,,we can look at the bashrc. Dialogue: 0,0:30:16.18,0:30:19.84,Default,,0000,0000,0000,,For demonstration purposes,\Nhere I have been using ZSH, Dialogue: 0,0:30:19.90,0:30:24.46,Default,,0000,0000,0000,,which is a different shell, and I'm going\Nto be configuring bash, and starting bash. Dialogue: 0,0:30:24.64,0:30:29.64,Default,,0000,0000,0000,,So if I create an entry here and I say Dialogue: 0,0:30:29.94,0:30:31.96,Default,,0000,0000,0000,,SL maps to LS Dialogue: 0,0:30:32.60,0:30:36.02,Default,,0000,0000,0000,,And I have modified that, and now I start bash. Dialogue: 0,0:30:36.54,0:30:40.66,Default,,0000,0000,0000,,Bash is kind of completely unconfigured,\Nbut now if I do SL... Dialogue: 0,0:30:41.36,0:30:44.04,Default,,0000,0000,0000,,Hm, that's unexpected. Dialogue: 0,0:30:46.28,0:30:48.00,Default,,0000,0000,0000,,Oh, good. Good getting that. Dialogue: 0,0:30:48.30,0:30:52.20,Default,,0000,0000,0000,,So it matters where you config file is, Dialogue: 0,0:30:52.20,0:30:55.26,Default,,0000,0000,0000,,your config file needs to be in your home folder. Dialogue: 0,0:30:55.64,0:31:00.94,Default,,0000,0000,0000,,So your configuration file for\Nbash will live in that "~", Dialogue: 0,0:31:00.94,0:31:03.94,Default,,0000,0000,0000,,which will expand to your home directory, Dialogue: 0,0:31:03.94,0:31:05.56,Default,,0000,0000,0000,,and then bashrc. Dialogue: 0,0:31:06.16,0:31:08.84,Default,,0000,0000,0000,,And here we can create the alias Dialogue: 0,0:31:12.04,0:31:15.84,Default,,0000,0000,0000,,and now we start a bash session and we do SL. Dialogue: 0,0:31:15.84,0:31:21.50,Default,,0000,0000,0000,,Now it has been loaded, and this is\Nloaded at the beginning when this Dialogue: 0,0:31:22.30,0:31:24.30,Default,,0000,0000,0000,,bash program is started. Dialogue: 0,0:31:24.70,0:31:31.20,Default,,0000,0000,0000,,All this configuration is loaded and you can, not only use\Naliases, they can have a lot of parts of configuration. Dialogue: 0,0:31:31.39,0:31:35.73,Default,,0000,0000,0000,,So for example here, I have a prompt\Nwhich is fairly useless. Dialogue: 0,0:31:35.73,0:31:38.43,Default,,0000,0000,0000,,It has just given me the name\Nof the shell, which is bash, Dialogue: 0,0:31:38.64,0:31:43.82,Default,,0000,0000,0000,,and the version, which is 5.0. I don't\Nwant this to be displayed and Dialogue: 0,0:31:44.36,0:31:48.54,Default,,0000,0000,0000,,as with many things in your shell, this\Nis just an environment variable. Dialogue: 0,0:31:48.60,0:31:53.12,Default,,0000,0000,0000,,So the "PS1" is just the prompt string Dialogue: 0,0:31:53.71,0:31:55.48,Default,,0000,0000,0000,,for your prompt and Dialogue: 0,0:31:55.48,0:32:02.52,Default,,0000,0000,0000,,we can actually modify this\Nto just be a "> " symbol. Dialogue: 0,0:32:02.52,0:32:08.28,Default,,0000,0000,0000,,and now that has been modified, and we have\Nthat. But if we exit and call bash again, Dialogue: 0,0:32:08.62,0:32:15.06,Default,,0000,0000,0000,,that was lost. However, if we add this\Nentry and say, oh we want "PS1" Dialogue: 0,0:32:15.76,0:32:17.23,Default,,0000,0000,0000,,to be Dialogue: 0,0:32:17.23,0:32:19.18,Default,,0000,0000,0000,,this and Dialogue: 0,0:32:19.18,0:32:24.69,Default,,0000,0000,0000,,we call bash again, this has been persisted.\NAnd we can keep modifying this configuration. Dialogue: 0,0:32:25.09,0:32:27.21,Default,,0000,0000,0000,,So maybe we want to include Dialogue: 0,0:32:27.88,0:32:29.88,Default,,0000,0000,0000,,where the Dialogue: 0,0:32:30.37,0:32:32.94,Default,,0000,0000,0000,,working directory that we are is in, and Dialogue: 0,0:32:34.14,0:32:37.38,Default,,0000,0000,0000,,that's telling us the same information\Nthat we had in the other shell. Dialogue: 0,0:32:37.38,0:32:40.48,Default,,0000,0000,0000,,And there are many, many options, Dialogue: 0,0:32:40.78,0:32:45.06,Default,,0000,0000,0000,,shells are highly, highly configurable, and Dialogue: 0,0:32:45.70,0:32:49.92,Default,,0000,0000,0000,,it's not only cells that are configured\Nthrough these files, Dialogue: 0,0:32:50.59,0:32:55.74,Default,,0000,0000,0000,,there are many other programs. As we saw for\Nexample in the editors lecture, Vim is also Dialogue: 0,0:32:55.84,0:33:02.90,Default,,0000,0000,0000,,configured this way. We gave you this vimrc\Nfile and told you to put it under your Dialogue: 0,0:33:03.46,0:33:06.38,Default,,0000,0000,0000,,home/.vimrc Dialogue: 0,0:33:06.38,0:33:11.80,Default,,0000,0000,0000,,and this is the same concept, but just\Nfor Vim. It's just giving it a set of Dialogue: 0,0:33:12.16,0:33:18.34,Default,,0000,0000,0000,,instructions that it should load when it's started,\Nso you can keep a configuration that you want. Dialogue: 0,0:33:19.14,0:33:21.24,Default,,0000,0000,0000,,And even non... Dialogue: 0,0:33:21.58,0:33:27.14,Default,,0000,0000,0000,,kind of a lot of programs will support this. For instance,\Nmy terminal emulator, which is another concept, Dialogue: 0,0:33:27.26,0:33:30.16,Default,,0000,0000,0000,,which is the program that is Dialogue: 0,0:33:30.16,0:33:35.46,Default,,0000,0000,0000,,running the shell, in a way, and displaying\Nthis into the screen in my computer. Dialogue: 0,0:33:35.95,0:33:38.61,Default,,0000,0000,0000,,It can also be configured this way, so Dialogue: 0,0:33:39.94,0:33:43.62,Default,,0000,0000,0000,,if I modify this I can Dialogue: 0,0:33:46.51,0:33:53.28,Default,,0000,0000,0000,,change the size of the font. Like right now, for\Nexample, I have increased the font size a lot Dialogue: 0,0:33:53.28,0:33:55.77,Default,,0000,0000,0000,,for demonstration purposes, but Dialogue: 0,0:33:56.44,0:34:00.36,Default,,0000,0000,0000,,if I change this entry and make it for example Dialogue: 0,0:34:01.32,0:34:06.82,Default,,0000,0000,0000,,28 and write this value, you see that\Nthe size of the font has changed, Dialogue: 0,0:34:06.82,0:34:12.92,Default,,0000,0000,0000,,because I edited this text file that specifies\Nhow my terminal emulator should work. Dialogue: 0,0:34:19.48,0:34:20.90,Default,,0000,0000,0000,,Any questions so far? Dialogue: 0,0:34:20.90,0:34:22.28,Default,,0000,0000,0000,,With dotfiles. Dialogue: 0,0:34:28.04,0:34:35.94,Default,,0000,0000,0000,,Okay, it can be a bit daunting knowing that there\Nis like this endless wall of configurations, Dialogue: 0,0:34:35.94,0:34:40.60,Default,,0000,0000,0000,,and how do you go about learning\Nabout what can be configured? Dialogue: 0,0:34:42.02,0:34:44.30,Default,,0000,0000,0000,,The good news is that Dialogue: 0,0:34:44.64,0:34:48.90,Default,,0000,0000,0000,,we have linked you to really good\Nresources in the lecture notes. Dialogue: 0,0:34:48.96,0:34:56.44,Default,,0000,0000,0000,,But the main idea is that a lot of people really like\Njust configuring these tools and have uploaded Dialogue: 0,0:34:56.64,0:35:01.14,Default,,0000,0000,0000,,their configuration files to GitHub, another\Ndifferent kind of repositories online. Dialogue: 0,0:35:01.14,0:35:03.30,Default,,0000,0000,0000,,So for example, here we are on GitHub, Dialogue: 0,0:35:03.30,0:35:06.64,Default,,0000,0000,0000,,we search for dotfiles, and\Ncan see that there are like Dialogue: 0,0:35:06.78,0:35:12.54,Default,,0000,0000,0000,,thousands of repositories of people sharing\Ntheir configuration files. We have also... Dialogue: 0,0:35:12.54,0:35:15.46,Default,,0000,0000,0000,,Like, the class instructors\Nhave linked our dotfiles. Dialogue: 0,0:35:15.46,0:35:19.42,Default,,0000,0000,0000,,So if you really want to know how\Nany part of our setup is working Dialogue: 0,0:35:19.42,0:35:22.22,Default,,0000,0000,0000,,you can go through it and try to figure it out. Dialogue: 0,0:35:22.22,0:35:24.22,Default,,0000,0000,0000,,You can also feel free to ask us. Dialogue: 0,0:35:24.38,0:35:27.06,Default,,0000,0000,0000,,If we go for example to this repository here Dialogue: 0,0:35:27.21,0:35:30.65,Default,,0000,0000,0000,,we can see that there's many, many\Nfiles that you can configure. Dialogue: 0,0:35:30.65,0:35:37.52,Default,,0000,0000,0000,,For example, there is one for bash, the first couple of ones\Nare for git, that will be probably be covered in the Dialogue: 0,0:35:38.61,0:35:40.82,Default,,0000,0000,0000,,version control lecture tomorrow. Dialogue: 0,0:35:41.40,0:35:48.50,Default,,0000,0000,0000,,If we go for example to the bash profile, which is\Na different form of what we saw in the bashrc, Dialogue: 0,0:35:49.40,0:35:52.90,Default,,0000,0000,0000,,it can be really useful because\Nyou can learn through Dialogue: 0,0:35:53.94,0:35:58.32,Default,,0000,0000,0000,,just looking at the manual page, but the\Nmanual pages is, a lot of the time Dialogue: 0,0:35:58.48,0:36:03.52,Default,,0000,0000,0000,,just kind of like a descriptive explanation\Nof all the different options Dialogue: 0,0:36:03.52,0:36:04.88,Default,,0000,0000,0000,,and sometimes it's more helpful Dialogue: 0,0:36:04.88,0:36:09.60,Default,,0000,0000,0000,,going through examples of what people have done\Nand trying to understand why they did it Dialogue: 0,0:36:09.60,0:36:12.20,Default,,0000,0000,0000,,and how it's helping their workflow. Dialogue: 0,0:36:12.96,0:36:17.30,Default,,0000,0000,0000,,We can say here that this person has\Ndone case-insensitive globbing. Dialogue: 0,0:36:17.32,0:36:21.22,Default,,0000,0000,0000,,We covered globbing as this\Nkind of filename expansion Dialogue: 0,0:36:22.10,0:36:25.76,Default,,0000,0000,0000,,trick in the shell scripting and tools. Dialogue: 0,0:36:25.90,0:36:28.80,Default,,0000,0000,0000,,And here you say no, I don't want this to matter, Dialogue: 0,0:36:28.80,0:36:30.76,Default,,0000,0000,0000,,whether using uppercase and lowercase, Dialogue: 0,0:36:30.76,0:36:32.76,Default,,0000,0000,0000,,and just setting this option in the shell\Nfor these things to work this way Dialogue: 0,0:36:35.36,0:36:38.14,Default,,0000,0000,0000,,Similarly, there is for example aliases. Dialogue: 0,0:36:38.14,0:36:42.22,Default,,0000,0000,0000,,Here you can see a lot of aliases that this\Nperson is doing. For example, "d" for Dialogue: 0,0:36:44.20,0:36:47.40,Default,,0000,0000,0000,,"d" for "Dropbox", sorry, because\Nthat's just much shorter. Dialogue: 0,0:36:47.40,0:36:49.20,Default,,0000,0000,0000,,"g" for "git"... Dialogue: 0,0:36:49.74,0:36:54.56,Default,,0000,0000,0000,,Say we go, for example, with vimrc. It\Ncan be actually very, very informative, Dialogue: 0,0:36:54.56,0:36:58.86,Default,,0000,0000,0000,,going through this and trying\Nto extract useful information. Dialogue: 0,0:36:59.00,0:37:06.42,Default,,0000,0000,0000,,We do not recommend just kind of getting one huge blob\Nof this and copying this into your config files, Dialogue: 0,0:37:07.11,0:37:12.44,Default,,0000,0000,0000,,because maybe things are prettier, but you might\Nnot really understand what is going on. Dialogue: 0,0:37:15.15,0:37:19.58,Default,,0000,0000,0000,,Lastly one thing I want to mention\Nabout dotfiles is that Dialogue: 0,0:37:20.46,0:37:23.39,Default,,0000,0000,0000,,people not only try to push these Dialogue: 0,0:37:24.66,0:37:28.85,Default,,0000,0000,0000,,files into GitHub just so other\Npeople can read it, that's Dialogue: 0,0:37:29.40,0:37:33.32,Default,,0000,0000,0000,,one reason. They also make really sure they can Dialogue: 0,0:37:34.14,0:37:39.44,Default,,0000,0000,0000,,reproduce their setup. And to do that\Nthey use a slew of different tools. Dialogue: 0,0:37:39.44,0:37:41.28,Default,,0000,0000,0000,,Oops, went a little too far. Dialogue: 0,0:37:41.28,0:37:44.84,Default,,0000,0000,0000,,So GNU Stow is, for example, one of them Dialogue: 0,0:37:45.72,0:37:49.06,Default,,0000,0000,0000,,and the trick that they are doing is Dialogue: 0,0:37:50.28,0:37:54.52,Default,,0000,0000,0000,,they are kind of putting all their\Ndotfiles in a folder and they are Dialogue: 0,0:37:55.20,0:37:59.52,Default,,0000,0000,0000,,faking to the system, using\Na tool called symlinks, Dialogue: 0,0:37:59.52,0:38:02.44,Default,,0000,0000,0000,,that they are actually what\Nthey're not. I'm gonna Dialogue: 0,0:38:03.15,0:38:05.15,Default,,0000,0000,0000,,draw really quick what I mean by that. Dialogue: 0,0:38:05.79,0:38:10.94,Default,,0000,0000,0000,,So a common folder structure might look\Nlike you have your home folder and Dialogue: 0,0:38:11.67,0:38:14.30,Default,,0000,0000,0000,,in this home folder you might have your Dialogue: 0,0:38:16.05,0:38:21.38,Default,,0000,0000,0000,,bashrc, that contains your bash configuration,\Nyou might have your vimrc and Dialogue: 0,0:38:22.50,0:38:25.76,Default,,0000,0000,0000,,it would be really great if you could\Nkeep this under version control. Dialogue: 0,0:38:26.58,0:38:29.30,Default,,0000,0000,0000,,But the thing is, you might not\Nwant to have a git repository, Dialogue: 0,0:38:29.30,0:38:31.30,Default,,0000,0000,0000,,which will be covered tomorrow, Dialogue: 0,0:38:31.30,0:38:32.30,Default,,0000,0000,0000,,in your home folder. Dialogue: 0,0:38:32.30,0:38:37.36,Default,,0000,0000,0000,,So what people usually do is they\Ncreate a dotfiles repository, Dialogue: 0,0:38:38.28,0:38:42.16,Default,,0000,0000,0000,,and then they have entries here for their Dialogue: 0,0:38:43.05,0:38:47.24,Default,,0000,0000,0000,,bashrc and their vimrc. And\Nthis is where actually Dialogue: 0,0:38:47.82,0:38:49.82,Default,,0000,0000,0000,,the files are Dialogue: 0,0:38:50.10,0:38:52.40,Default,,0000,0000,0000,,and what they are doing is they're just Dialogue: 0,0:38:53.46,0:38:56.51,Default,,0000,0000,0000,,telling the OS to forward, whenever anyone Dialogue: 0,0:38:56.76,0:39:01.85,Default,,0000,0000,0000,,wants to read this file or write to this file,\Njust forward this to this other file. Dialogue: 0,0:39:03.00,0:39:05.72,Default,,0000,0000,0000,,This is a concept called symlinks Dialogue: 0,0:39:06.69,0:39:08.63,Default,,0000,0000,0000,,and it's useful in this scenario, Dialogue: 0,0:39:08.63,0:39:12.60,Default,,0000,0000,0000,,but it in general it's a really\Nuseful tool in UNIX Dialogue: 0,0:39:12.70,0:39:14.70,Default,,0000,0000,0000,,that we haven't covered so far in the lectures Dialogue: 0,0:39:14.96,0:39:16.74,Default,,0000,0000,0000,,but you might be... Dialogue: 0,0:39:16.74,0:39:18.74,Default,,0000,0000,0000,,that you should be familiar with. Dialogue: 0,0:39:19.10,0:39:22.84,Default,,0000,0000,0000,,And in general, the syntax will be "ln -s" Dialogue: 0,0:39:22.84,0:39:29.98,Default,,0000,0000,0000,,for specifying a symbolic link and then\Nyou will put the path to the file Dialogue: 0,0:39:30.57,0:39:33.05,Default,,0000,0000,0000,,that you want to create and then the Dialogue: 0,0:39:33.78,0:39:35.78,Default,,0000,0000,0000,,symlink that you want to create. Dialogue: 0,0:39:39.39,0:39:41.39,Default,,0000,0000,0000,,And Dialogue: 0,0:39:41.88,0:39:45.62,Default,,0000,0000,0000,,All these all these kind of fancy tools\Nthat we're seeing here listed, Dialogue: 0,0:39:45.81,0:39:52.16,Default,,0000,0000,0000,,they all amount to doing some sort of this trick, so\Nthat you can have all your dotfiles neat and tidy Dialogue: 0,0:39:52.68,0:39:57.83,Default,,0000,0000,0000,,into a folder, and then they can be\Nversion-controlled, and they can be Dialogue: 0,0:39:58.35,0:40:02.69,Default,,0000,0000,0000,,symlinked so the rest of the programs can\Nfind them in their default locations. Dialogue: 0,0:40:06.72,0:40:09.02,Default,,0000,0000,0000,,Any questions regarding dotfiles? Dialogue: 0,0:40:13.20,0:40:20.20,Default,,0000,0000,0000,,Do you need to have the dotfiles in your home folder,\Nand then also dotfiles in the version control folder? Dialogue: 0,0:40:20.78,0:40:24.64,Default,,0000,0000,0000,,So what you will have is,\Npretty much every program, Dialogue: 0,0:40:24.64,0:40:26.18,Default,,0000,0000,0000,,for example bash, Dialogue: 0,0:40:26.18,0:40:29.56,Default,,0000,0000,0000,,will always look for "home/.bashrc". Dialogue: 0,0:40:29.56,0:40:33.48,Default,,0000,0000,0000,,That's where the program is going to look for. Dialogue: 0,0:40:33.82,0:40:40.20,Default,,0000,0000,0000,,What you do when you do a symlink\Nis, you place your "home/.bashrc" Dialogue: 0,0:40:40.20,0:40:44.90,Default,,0000,0000,0000,,it's just a file that is kind\Nof a special file in UNIX, Dialogue: 0,0:40:45.15,0:40:49.61,Default,,0000,0000,0000,,that says oh, whenever you want to read\Nthis file go to this other file. Dialogue: 0,0:40:51.50,0:40:53.44,Default,,0000,0000,0000,,There's no content, like there is no... Dialogue: 0,0:40:53.60,0:40:58.10,Default,,0000,0000,0000,,your aliases are not part of this dotfile. That file\Nis just kind of like a pointer, saying now you should Dialogue: 0,0:40:58.10,0:40:59.40,Default,,0000,0000,0000,,go that other way. Dialogue: 0,0:40:59.40,0:41:02.60,Default,,0000,0000,0000,,And by doing that you can have your other file Dialogue: 0,0:41:02.60,0:41:04.40,Default,,0000,0000,0000,,in that other folder. Dialogue: 0,0:41:04.56,0:41:06.36,Default,,0000,0000,0000,,If version controlling is not useful, think about Dialogue: 0,0:41:06.36,0:41:10.74,Default,,0000,0000,0000,,what if you want to have them in your Dropbox\Nfolder, so they're synced to the cloud, Dialogue: 0,0:41:10.76,0:41:15.02,Default,,0000,0000,0000,,for example. That's kind of another use case\Nwhere like symlinks could be really useful Dialogue: 0,0:41:16.24,0:41:21.04,Default,,0000,0000,0000,,So you don't need the folder dotfiles\Nto be in the home directory, right? Dialogue: 0,0:41:21.04,0:41:23.82,Default,,0000,0000,0000,,Because you can just use the symlink,\Nthat points somewhere else. Dialogue: 0,0:41:23.96,0:41:29.76,Default,,0000,0000,0000,,As long as you have a way for the default path\Nto resolve wherever you have it, yeah. Dialogue: 0,0:41:35.10,0:41:38.00,Default,,0000,0000,0000,,Last thing I want to cover in the lecture... Dialogue: 0,0:41:38.00,0:41:40.38,Default,,0000,0000,0000,,Oh, sorry, any other questions about dotfiles? Dialogue: 0,0:41:49.20,0:41:52.58,Default,,0000,0000,0000,,Last thing I want to cover in the lecture\Nis working with remote machines, Dialogue: 0,0:41:52.58,0:41:55.55,Default,,0000,0000,0000,,which is a thing that you will run into, Dialogue: 0,0:41:55.56,0:41:56.90,Default,,0000,0000,0000,,sooner or later. Dialogue: 0,0:41:56.90,0:42:02.24,Default,,0000,0000,0000,,And there are a few things that will make your life\Nmuch easier when dealing with remote machines Dialogue: 0,0:42:03.18,0:42:05.18,Default,,0000,0000,0000,,if you know about them. Dialogue: 0,0:42:05.22,0:42:08.38,Default,,0000,0000,0000,,Right now maybe because you are\Nusing the Athena cluster, Dialogue: 0,0:42:08.38,0:42:10.74,Default,,0000,0000,0000,,but later on, during your programming career, Dialogue: 0,0:42:10.74,0:42:11.96,Default,,0000,0000,0000,,it's pretty sure that Dialogue: 0,0:42:11.96,0:42:15.40,Default,,0000,0000,0000,,there is a fairly ubiquitous\Nconcept of having your Dialogue: 0,0:42:15.40,0:42:20.38,Default,,0000,0000,0000,,local working environment and then having some\Nproduction server that is actually running the Dialogue: 0,0:42:20.97,0:42:23.24,Default,,0000,0000,0000,,code, so it is really good to get familiar Dialogue: 0,0:42:24.48,0:42:26.75,Default,,0000,0000,0000,,about how to work in/with remote machines. Dialogue: 0,0:42:27.42,0:42:35.18,Default,,0000,0000,0000,,So the main command for working\Nwith remote machines is SSH. Dialogue: 0,0:42:37.76,0:42:43.90,Default,,0000,0000,0000,,SSH is just like a secure shell, it's\Njust gonna take the responsibility for Dialogue: 0,0:42:43.90,0:42:46.54,Default,,0000,0000,0000,,reaching wherever we want or tell it to go Dialogue: 0,0:42:47.56,0:42:50.70,Default,,0000,0000,0000,,and trying to open a session there. Dialogue: 0,0:42:50.70,0:42:52.40,Default,,0000,0000,0000,,So here the syntax is: Dialogue: 0,0:42:53.13,0:42:56.66,Default,,0000,0000,0000,,"JJGO" is the user that I want\Nto use in the remote machine, Dialogue: 0,0:42:56.66,0:42:58.43,Default,,0000,0000,0000,,and this is because the user is Dialogue: 0,0:42:58.53,0:43:03.46,Default,,0000,0000,0000,,different from the one I have my local machine,\Nwhich will be the case a lot of the time, Dialogue: 0,0:43:03.46,0:43:07.40,Default,,0000,0000,0000,,then the "@" is telling the\Nterminal that this separates Dialogue: 0,0:43:07.40,0:43:12.54,Default,,0000,0000,0000,,what the user is from what the address is. Dialogue: 0,0:43:12.54,0:43:16.54,Default,,0000,0000,0000,,And here I'm using an IP address because\Nwhat I'm actually doing is Dialogue: 0,0:43:16.54,0:43:20.50,Default,,0000,0000,0000,,I have a virtual machine in my computer, Dialogue: 0,0:43:20.50,0:43:23.24,Default,,0000,0000,0000,,that is the one that is remote right now. Dialogue: 0,0:43:23.24,0:43:26.40,Default,,0000,0000,0000,,And I'm gonna be SSH'ing into it. This is the Dialogue: 0,0:43:26.58,0:43:27.88,Default,,0000,0000,0000,,URL that I'm using, Dialogue: 0,0:43:27.88,0:43:29.86,Default,,0000,0000,0000,,sorry, the IP that I'm using, Dialogue: 0,0:43:29.86,0:43:32.28,Default,,0000,0000,0000,,but you might also see things like Dialogue: 0,0:43:32.36,0:43:36.82,Default,,0000,0000,0000,,oh I want to SSH as "JJGO" Dialogue: 0,0:43:36.82,0:43:39.84,Default,,0000,0000,0000,,at "foobar.mit.edu" Dialogue: 0,0:43:39.84,0:43:42.96,Default,,0000,0000,0000,,That's probably something more\Ncommon, if you are using some Dialogue: 0,0:43:42.96,0:43:47.26,Default,,0000,0000,0000,,remote server that has a DNS name. Dialogue: 0,0:43:48.18,0:43:51.86,Default,,0000,0000,0000,,So going back to a regular command, Dialogue: 0,0:43:53.22,0:43:56.58,Default,,0000,0000,0000,,we try to SSH, it asks us for a password, Dialogue: 0,0:43:56.58,0:43:58.18,Default,,0000,0000,0000,,really common thing. Dialogue: 0,0:43:58.19,0:43:59.48,Default,,0000,0000,0000,,And now we're there. We have... Dialogue: 0,0:43:59.48,0:44:02.63,Default,,0000,0000,0000,,we're still in our same terminal emulator Dialogue: 0,0:44:02.63,0:44:09.53,Default,,0000,0000,0000,,but right now SSH is kind of forwarding the\Nentire virtual display to display what the Dialogue: 0,0:44:09.87,0:44:14.36,Default,,0000,0000,0000,,remote shell is displaying. And\Nwe can execute commands here and Dialogue: 0,0:44:15.63,0:44:17.63,Default,,0000,0000,0000,,we'll see the remote files Dialogue: 0,0:44:18.39,0:44:22.82,Default,,0000,0000,0000,,A couple of handy things to know about\NSSH, that were briefly covered in the Dialogue: 0,0:44:23.22,0:44:27.08,Default,,0000,0000,0000,,data wrangling lecture, is that\NSSH is not only good for just Dialogue: 0,0:44:28.28,0:44:33.76,Default,,0000,0000,0000,,opening connections. It will also let\Nyou just execute commands remotely. Dialogue: 0,0:44:33.77,0:44:36.98,Default,,0000,0000,0000,,So for example, if I do that, it's gonna ask me Dialogue: 0,0:44:37.71,0:44:39.02,Default,,0000,0000,0000,,what is my password?, again. Dialogue: 0,0:44:39.02,0:44:41.06,Default,,0000,0000,0000,,And it's executing this command Dialogue: 0,0:44:41.28,0:44:43.42,Default,,0000,0000,0000,,then coming back to my terminal Dialogue: 0,0:44:43.42,0:44:47.42,Default,,0000,0000,0000,,and piping the output of what that\Ncommand was, in the remote machine, Dialogue: 0,0:44:47.42,0:44:50.48,Default,,0000,0000,0000,,through the standard output in my current cell. Dialogue: 0,0:44:50.48,0:44:53.94,Default,,0000,0000,0000,,And I could have this in... Dialogue: 0,0:44:58.10,0:45:00.48,Default,,0000,0000,0000,,I could have this in a pipe, and Dialogue: 0,0:45:00.98,0:45:03.58,Default,,0000,0000,0000,,this will work and we'll just Dialogue: 0,0:45:03.60,0:45:06.10,Default,,0000,0000,0000,,drop all this output and then have a local pipe Dialogue: 0,0:45:06.10,0:45:07.88,Default,,0000,0000,0000,,where I can keep working. Dialogue: 0,0:45:08.64,0:45:12.14,Default,,0000,0000,0000,,So far, it has been kind of inconvenient,\Nhaving to type our password. Dialogue: 0,0:45:12.63,0:45:14.82,Default,,0000,0000,0000,,There's one really good trick for this. Dialogue: 0,0:45:14.82,0:45:16.88,Default,,0000,0000,0000,,It's we can use something called "SSH keys". Dialogue: 0,0:45:17.14,0:45:20.66,Default,,0000,0000,0000,,SSH keys just use public key encryption Dialogue: 0,0:45:20.66,0:45:24.98,Default,,0000,0000,0000,,to create a pair of SSH keys, a public\Nkey and a private key, and then Dialogue: 0,0:45:25.17,0:45:29.32,Default,,0000,0000,0000,,you can give the server the\Npublic part of the key. Dialogue: 0,0:45:29.32,0:45:32.81,Default,,0000,0000,0000,,So you copy the public key and\Nthen whenever you try to Dialogue: 0,0:45:33.39,0:45:37.13,Default,,0000,0000,0000,,authenticate instead of using your password,\Nit's gonna use the private key to Dialogue: 0,0:45:37.82,0:45:40.80,Default,,0000,0000,0000,,prove to the server that you are\Nactually who you say you are. Dialogue: 0,0:45:43.86,0:45:48.02,Default,,0000,0000,0000,,We can quickly showcase how you will go Dialogue: 0,0:45:48.02,0:45:49.40,Default,,0000,0000,0000,,about doing this. Dialogue: 0,0:45:49.40,0:45:53.18,Default,,0000,0000,0000,,Right now I don't have any SSH keys,\Nso I'm gonna create a couple of them. Dialogue: 0,0:45:53.94,0:45:58.25,Default,,0000,0000,0000,,First thing, it's just gonna ask\Nme where I want this key to live. Dialogue: 0,0:45:58.98,0:46:00.64,Default,,0000,0000,0000,,Unsurprisingly, it's doing this. Dialogue: 0,0:46:00.64,0:46:04.82,Default,,0000,0000,0000,,This is my home folder and then\Nit's using this ".ssh" path, Dialogue: 0,0:46:05.46,0:46:08.75,Default,,0000,0000,0000,,which refers back to the same concept\Nthat we covered earlier about having Dialogue: 0,0:46:08.85,0:46:12.44,Default,,0000,0000,0000,,dotfiles. Like ".ssh" is a folder\Nthat contains a lot of the Dialogue: 0,0:46:13.32,0:46:16.54,Default,,0000,0000,0000,,configuration files for how\Nyou want SSH to behave. Dialogue: 0,0:46:17.06,0:46:19.42,Default,,0000,0000,0000,,So it will ask us a passphrase. Dialogue: 0,0:46:19.68,0:46:23.12,Default,,0000,0000,0000,,The passphrase is to encrypt\Nthe private part of the key Dialogue: 0,0:46:23.12,0:46:27.16,Default,,0000,0000,0000,,because if someone gets your private key,\Nif you don't have a password protected Dialogue: 0,0:46:27.92,0:46:29.58,Default,,0000,0000,0000,,private key, if they get that key Dialogue: 0,0:46:29.58,0:46:32.24,Default,,0000,0000,0000,,they can use that key to impersonate\Nyou in any server. Dialogue: 0,0:46:32.31,0:46:34.36,Default,,0000,0000,0000,,Whereas if you add a passphrase, Dialogue: 0,0:46:34.36,0:46:37.64,Default,,0000,0000,0000,,they will have to know what the passphrase\Nis to actually use the key. Dialogue: 0,0:46:40.80,0:46:51.74,Default,,0000,0000,0000,,It has created a keeper. We can check that\Nthese two files are now under ssh. Dialogue: 0,0:46:51.74,0:46:53.92,Default,,0000,0000,0000,,And we can see... Dialogue: 0,0:46:57.72,0:47:02.96,Default,,0000,0000,0000,,We have these two files: we have\Nthe 25519 and the public key. Dialogue: 0,0:47:03.32,0:47:06.30,Default,,0000,0000,0000,,And if we "cat" through the output, Dialogue: 0,0:47:06.30,0:47:09.76,Default,,0000,0000,0000,,that key is actually not like\Nany fancy binary file, it's Dialogue: 0,0:47:15.43,0:47:20.76,Default,,0000,0000,0000,,just a text file that has the contents\Nof the public key and some Dialogue: 0,0:47:23.05,0:47:26.73,Default,,0000,0000,0000,,alias name for it, so we can\Nknow what this public key is. Dialogue: 0,0:47:26.95,0:47:32.22,Default,,0000,0000,0000,,The way we can tell the server that\Nwe're authorized to SSH there Dialogue: 0,0:47:32.26,0:47:38.40,Default,,0000,0000,0000,,is by just actually copying this file,\Nlike copying this string into a file, Dialogue: 0,0:47:38.40,0:47:41.54,Default,,0000,0000,0000,,that is ".ssh/authorized_keys". Dialogue: 0,0:47:42.10,0:47:46.16,Default,,0000,0000,0000,,So here what I'm doing is I'm Dialogue: 0,0:47:46.96,0:47:49.77,Default,,0000,0000,0000,,catting the output of this file Dialogue: 0,0:47:49.80,0:47:53.92,Default,,0000,0000,0000,,which is just this line of\Ntext that we want to copy Dialogue: 0,0:47:53.92,0:47:57.44,Default,,0000,0000,0000,,and I'm piping that into SSH and then remotely Dialogue: 0,0:47:57.96,0:48:02.08,Default,,0000,0000,0000,,I'm asking "tee" to dump the contents\Nof the standard input Dialogue: 0,0:48:02.08,0:48:05.22,Default,,0000,0000,0000,,into ".ssh/authorized_keys". Dialogue: 0,0:48:05.44,0:48:10.36,Default,,0000,0000,0000,,And if we do that, obviously it's\Ngonna ask us for a password. Dialogue: 0,0:48:14.80,0:48:18.74,Default,,0000,0000,0000,,It was copied, and now we\Ncan check that if we try Dialogue: 0,0:48:19.69,0:48:21.69,Default,,0000,0000,0000,,to SSH again, Dialogue: 0,0:48:21.96,0:48:24.84,Default,,0000,0000,0000,,It's going to first ask us for a passphrase Dialogue: 0,0:48:24.84,0:48:29.10,Default,,0000,0000,0000,,but you can arrange that so that\Nit's saved in the session Dialogue: 0,0:48:29.46,0:48:34.84,Default,,0000,0000,0000,,and we didn't actually have to\Ntype the key for the server. Dialogue: 0,0:48:34.84,0:48:36.84,Default,,0000,0000,0000,,And I can kind of show that again. Dialogue: 0,0:48:45.82,0:48:47.54,Default,,0000,0000,0000,,More things that are useful. Dialogue: 0,0:48:47.54,0:48:49.04,Default,,0000,0000,0000,,Oh, we can do... Dialogue: 0,0:48:49.22,0:48:51.88,Default,,0000,0000,0000,,If that command seemed a little bit janky, Dialogue: 0,0:48:51.98,0:48:55.00,Default,,0000,0000,0000,,you can actually use this command\Nthat is built for this, Dialogue: 0,0:48:55.00,0:49:00.64,Default,,0000,0000,0000,,so you don't have to kind of\Ncraft this "ssh tee" command. Dialogue: 0,0:49:00.64,0:49:03.80,Default,,0000,0000,0000,,That is just called "ssh-copy-id". Dialogue: 0,0:49:05.00,0:49:08.08,Default,,0000,0000,0000,,And we can do the same Dialogue: 0,0:49:08.08,0:49:09.66,Default,,0000,0000,0000,,and it's gonna copy the key. Dialogue: 0,0:49:09.66,0:49:14.28,Default,,0000,0000,0000,,And now, if we try to SSH, Dialogue: 0,0:49:14.50,0:49:18.32,Default,,0000,0000,0000,,we can SSH without actually\Ntyping any key at all, Dialogue: 0,0:49:18.86,0:49:20.32,Default,,0000,0000,0000,,or any password. Dialogue: 0,0:49:20.66,0:49:21.52,Default,,0000,0000,0000,,More things. Dialogue: 0,0:49:21.52,0:49:23.52,Default,,0000,0000,0000,,We will probably want to copy files. Dialogue: 0,0:49:23.74,0:49:25.31,Default,,0000,0000,0000,,You cannot use "CP" Dialogue: 0,0:49:25.31,0:49:29.72,Default,,0000,0000,0000,,but you can use "SCP", for "SSH copy". Dialogue: 0,0:49:29.72,0:49:34.50,Default,,0000,0000,0000,,And here we can specify that we want\Nto copy this local file called notes Dialogue: 0,0:49:34.50,0:49:36.88,Default,,0000,0000,0000,,and the syntax is kind of similar. Dialogue: 0,0:49:36.88,0:49:39.76,Default,,0000,0000,0000,,We want to copy to this remote and Dialogue: 0,0:49:39.92,0:49:44.02,Default,,0000,0000,0000,,then we have a semicolon to separate\Nwhat the path is going to be. Dialogue: 0,0:49:44.02,0:49:45.04,Default,,0000,0000,0000,,And then we have Dialogue: 0,0:49:45.04,0:49:46.62,Default,,0000,0000,0000,,oh, we want to copy this as notes Dialogue: 0,0:49:46.62,0:49:51.00,Default,,0000,0000,0000,,but we could also copy this as foobar. Dialogue: 0,0:49:51.74,0:49:55.60,Default,,0000,0000,0000,,And if we do that, it has been executed Dialogue: 0,0:49:55.78,0:49:59.28,Default,,0000,0000,0000,,and it's telling us that all the\Ncontents have been copied there. Dialogue: 0,0:49:59.54,0:50:02.20,Default,,0000,0000,0000,,If you're gonna be copying a lot of files, Dialogue: 0,0:50:02.20,0:50:05.10,Default,,0000,0000,0000,,there is a better command\Nthat you should be using Dialogue: 0,0:50:05.10,0:50:07.74,Default,,0000,0000,0000,,that is called "RSYNC". For example, here Dialogue: 0,0:50:07.90,0:50:10.78,Default,,0000,0000,0000,,just by specifying these three flags, Dialogue: 0,0:50:10.82,0:50:15.96,Default,,0000,0000,0000,,I'm telling RSYNC to kind of preserve\Nall the permissions whenever possible Dialogue: 0,0:50:16.24,0:50:19.74,Default,,0000,0000,0000,,to try to check if the file\Nhas already been copied. Dialogue: 0,0:50:19.74,0:50:24.10,Default,,0000,0000,0000,,For example, SCP will try to copy\Nfiles that are already there. Dialogue: 0,0:50:24.20,0:50:26.44,Default,,0000,0000,0000,,This will happen for example\Nif you are trying to copy Dialogue: 0,0:50:26.44,0:50:29.06,Default,,0000,0000,0000,,and the connection interrupts\Nin the middle of it. Dialogue: 0,0:50:29.12,0:50:32.06,Default,,0000,0000,0000,,SCP will start from the very beginning,\Ntrying to copy every file, Dialogue: 0,0:50:32.08,0:50:36.60,Default,,0000,0000,0000,,whereas RSYNC will continue\Nfrom where it stopped. Dialogue: 0,0:50:37.24,0:50:38.44,Default,,0000,0000,0000,,And here, Dialogue: 0,0:50:39.06,0:50:42.76,Default,,0000,0000,0000,,we ask it to copy the entire folder and Dialogue: 0,0:50:43.78,0:50:46.56,Default,,0000,0000,0000,,it's just really quickly\Ncopied the entire folder. Dialogue: 0,0:50:48.08,0:50:54.10,Default,,0000,0000,0000,,One of the other things to know about SSH is that Dialogue: 0,0:50:54.32,0:50:59.86,Default,,0000,0000,0000,,the equivalent of the dot file\Nfor SSH is the "SSH config". Dialogue: 0,0:50:59.86,0:51:06.34,Default,,0000,0000,0000,,So if we edit the SSH config to be Dialogue: 0,0:51:13.12,0:51:17.94,Default,,0000,0000,0000,,If I edit the SSH config to\Nlook something like this, Dialogue: 0,0:51:17.94,0:51:22.90,Default,,0000,0000,0000,,instead of having to, every\Ntime, type "ssh jjgo", Dialogue: 0,0:51:23.04,0:51:27.76,Default,,0000,0000,0000,,having this really long string so I can\Nlike refer to this specific remote, Dialogue: 0,0:51:27.76,0:51:30.14,Default,,0000,0000,0000,,I want to refer, with the specific user name, Dialogue: 0,0:51:30.14,0:51:32.76,Default,,0000,0000,0000,,I can have something here that says Dialogue: 0,0:51:33.16,0:51:35.68,Default,,0000,0000,0000,,this is the username, this\Nis the host name, that this Dialogue: 0,0:51:36.86,0:51:40.54,Default,,0000,0000,0000,,host is referring to and you should\Nuse this identity file. Dialogue: 0,0:51:41.46,0:51:43.96,Default,,0000,0000,0000,,And if I copy this, Dialogue: 0,0:51:43.96,0:51:46.10,Default,,0000,0000,0000,,this is right now in my local folder, Dialogue: 0,0:51:46.10,0:51:49.00,Default,,0000,0000,0000,,I can copy this into ssh. Dialogue: 0,0:51:49.60,0:51:53.52,Default,,0000,0000,0000,,Now, instead of having to do this really\Nlong command, I can just say Dialogue: 0,0:51:53.52,0:51:57.10,Default,,0000,0000,0000,,I just want to SSH into the host called VM. Dialogue: 0,0:51:58.26,0:52:03.22,Default,,0000,0000,0000,,And by doing that, it's grabbing all that\Nconfiguration from the SSH config Dialogue: 0,0:52:03.22,0:52:05.22,Default,,0000,0000,0000,,and applying it here. Dialogue: 0,0:52:05.24,0:52:10.06,Default,,0000,0000,0000,,This solution is much better than something\Nlike creating an alias for SSH, Dialogue: 0,0:52:10.36,0:52:13.36,Default,,0000,0000,0000,,because other programs like SCP and RSYNC Dialogue: 0,0:52:13.36,0:52:19.44,Default,,0000,0000,0000,,also know about the dotfiles for SSH and\Nwill use them whenever they are there. Dialogue: 0,0:52:22.82,0:52:30.40,Default,,0000,0000,0000,,Last thing I want to cover about remote machines is\Nthat here, for example, we'll have tmux and we can, Dialogue: 0,0:52:31.76,0:52:35.78,Default,,0000,0000,0000,,like I was saying before, we\Ncan start editing some file Dialogue: 0,0:52:39.16,0:52:44.50,Default,,0000,0000,0000,,and we can start running some job. Dialogue: 0,0:52:54.20,0:52:56.18,Default,,0000,0000,0000,,For example, something like HTOP. Dialogue: 0,0:52:56.18,0:52:58.72,Default,,0000,0000,0000,,And this is running here, we can Dialogue: 0,0:52:59.32,0:53:01.32,Default,,0000,0000,0000,,detach from it, Dialogue: 0,0:53:01.43,0:53:03.43,Default,,0000,0000,0000,,close the connection and Dialogue: 0,0:53:03.74,0:53:07.78,Default,,0000,0000,0000,,then SSH back. And then, if you do "tmux a", Dialogue: 0,0:53:07.78,0:53:11.34,Default,,0000,0000,0000,,everything is as you left it, like\Nnothing has really changed. Dialogue: 0,0:53:11.34,0:53:15.22,Default,,0000,0000,0000,,And if you have things executing there in\Nthe background, they will keep executing. Dialogue: 0,0:53:17.50,0:53:23.30,Default,,0000,0000,0000,,I think that, pretty much, ends\Nall I have to say for this tool. Dialogue: 0,0:53:23.30,0:53:26.42,Default,,0000,0000,0000,,Any questions related to remote machines? Dialogue: 0,0:53:32.86,0:53:36.78,Default,,0000,0000,0000,,That's a really good question.\NSo what I do for that, Dialogue: 0,0:53:38.70,0:53:39.46,Default,,0000,0000,0000,,Oh, yes, sorry. Dialogue: 0,0:53:39.46,0:53:44.88,Default,,0000,0000,0000,,So the question is, how do you deal with\Ntrying to use tmux in your local machine, Dialogue: 0,0:53:44.88,0:53:47.64,Default,,0000,0000,0000,,and also trying to use tmux\Nin the remote machine? Dialogue: 0,0:53:48.40,0:53:50.76,Default,,0000,0000,0000,,There are a couple of tricks\Nfor dealing with that. Dialogue: 0,0:53:50.76,0:53:53.22,Default,,0000,0000,0000,,The first one is changing the prefix. Dialogue: 0,0:53:53.36,0:53:55.34,Default,,0000,0000,0000,,So what I do, for example, is Dialogue: 0,0:53:55.34,0:54:00.02,Default,,0000,0000,0000,,in my local machine the prefix I have\Nchanged from "Ctrl+B" to "Ctrl+A" and Dialogue: 0,0:54:00.22,0:54:02.58,Default,,0000,0000,0000,,then in remove machines this is still "Ctrl+B". Dialogue: 0,0:54:02.80,0:54:05.58,Default,,0000,0000,0000,,So I can kind of swap between, Dialogue: 0,0:54:05.58,0:54:09.84,Default,,0000,0000,0000,,if I want to do things to the\Nlocal tmux I will do "Ctrl+A" Dialogue: 0,0:54:09.84,0:54:13.46,Default,,0000,0000,0000,,and if I want to do things to the\Nremote tmux I would do "Ctrl+B". Dialogue: 0,0:54:15.08,0:54:19.90,Default,,0000,0000,0000,,Another thing is that you\Ncan have separate configs, Dialogue: 0,0:54:20.08,0:54:24.10,Default,,0000,0000,0000,,so I can do something like this, and then... Dialogue: 0,0:54:27.26,0:54:31.04,Default,,0000,0000,0000,,Ah, because I don't have my own ssh config, yeah. Dialogue: 0,0:54:32.24,0:54:33.00,Default,,0000,0000,0000,,But if you... Dialogue: 0,0:54:33.00,0:54:34.42,Default,,0000,0000,0000,,Um, I can SSH "VM". Dialogue: 0,0:54:36.82,0:54:38.90,Default,,0000,0000,0000,,Here, what you see, Dialogue: 0,0:54:38.90,0:54:41.00,Default,,0000,0000,0000,,the difference between these\Ntwo bars, for example, Dialogue: 0,0:54:41.00,0:54:43.68,Default,,0000,0000,0000,,is because the tmux config is different. Dialogue: 0,0:54:44.38,0:54:48.50,Default,,0000,0000,0000,,As you will see in the exercises,\Nthe tmux configuration is in Dialogue: 0,0:54:50.32,0:54:53.78,Default,,0000,0000,0000,,the tmux.conf Dialogue: 0,0:54:56.72,0:54:58.14,Default,,0000,0000,0000,,And in tmux.conf, Dialogue: 0,0:54:58.14,0:55:02.02,Default,,0000,0000,0000,,here you can do a lot of things like changing\Nthe color depending on the host you are Dialogue: 0,0:55:02.21,0:55:06.88,Default,,0000,0000,0000,,so you can get like quick visual\Nfeedback about where you are, or Dialogue: 0,0:55:06.88,0:55:10.24,Default,,0000,0000,0000,,if you have a nested session. Also, tmux will, Dialogue: 0,0:55:10.52,0:55:15.28,Default,,0000,0000,0000,,if you're in the same host and you\Ntry to tmux within a tmux session, Dialogue: 0,0:55:15.29,0:55:18.76,Default,,0000,0000,0000,,it will kind of prevent you from doing\Nit so you don't run into issues. Dialogue: 0,0:55:21.70,0:55:25.40,Default,,0000,0000,0000,,Any other questions related, to kind\Nof all the topics we have covered. Dialogue: 0,0:55:29.10,0:55:32.72,Default,,0000,0000,0000,,Another answer to that question is\Nalso, if you type the prefix twice, Dialogue: 0,0:55:32.88,0:55:35.76,Default,,0000,0000,0000,,it sends it once to the underlying shell. Dialogue: 0,0:55:35.92,0:55:40.10,Default,,0000,0000,0000,,So the local binding is "Ctrl+A" and\Nthe remote binding is "Ctrl+A", Dialogue: 0,0:55:40.10,0:55:45.26,Default,,0000,0000,0000,,You could type "Ctrl+A", "Ctrl+A" and then "D", for\Nexample, detaches from the remote, basically. Dialogue: 0,0:55:52.48,0:55:59.66,Default,,0000,0000,0000,,I think that ends the class for today, there's a bunch\Nof exercises related to all these main topics and Dialogue: 0,0:56:00.38,0:56:05.41,Default,,0000,0000,0000,,we're gonna be holding office hours today, too.\NSo feel free to come and ask us any questions.