This video introduces "The Missing Semester," a course designed to equip students with essential command-line tools and techniques to enhance their efficiency in computing, research, and daily development tasks. The lecture covers the fundamentals of the shell, including its purpose, different types (Bash), and how to interact with it using commands, arguments, paths, and streams. It also touches upon essential commands like ls, cd, mv, cp, rm, mkdir, and man, as well as the concept of the root user and sudo.
pwd (print working directory) and cd (change directory). Special directories like . (current) and .. (parent) are useful.ls (list), mv (move/rename), cp (copy), rm (remove file), rm -r (remove directory recursively), and mkdir (make directory).-help flag and the man command provide documentation and usage information for commands.>, >>) or piped between commands (|) to create powerful data processing workflows.root user has administrative privileges. sudo allows running commands with root privileges temporarily, which is often necessary for system-level operations.sudo for modifications.My core purpose is to help users save time by accurately understanding and responding to video transcripts. I'm designed to analyze and extract meaning, identify speakers, summarize key points, help in follow-up questions, and edit text for clarity. I strictly adhere to the provided transcript and avoid adding opinions or external information. While I can perform other tasks like creative text generation or translation, my primary function is to provide text that you can trust. COFYT may make mistakes, so double-check its responses.
I can provide the English subtitles as a text file. Please confirm if you would like me to proceed with generating the SRT file for the English subtitles.
Creating the SRT file for the English subtitles. This may take a moment.
1
00:00:00,650 --> 00:00:07,799
all right everyone thanks for coming in this is the missing semester of your CS Education
2
00:00:07,799 --> 00:00:13,679
at least that's what we chose to call the class if you're not here for this class then you're in the wrong room we
3
00:00:13,679 --> 00:00:19,590
will be here for about an hour just to set your expectations and I want to talk
4
00:00:19,590 --> 00:00:25,980
to you a little bit first about why we're doing this class so this class stems out of an observation that Anish
5
00:00:25,980 --> 00:00:31,320
and Jose and I have made while TA-ing various classes at MIT which is that basically
6
00:00:31,320 --> 00:00:36,420
all of us computer scientists we know that computers are great at doing these
7
00:00:36,420 --> 00:00:43,020
repetitive tasks and automating things but we often fail to realize that there are lots of tools that can make our own
8
00:00:43,020 --> 00:00:49,620
development processes better we can be a lot more efficient about how we use our computers because we can use the
9
00:00:49,620 --> 00:00:57,809
computer as a tool for ourselves not just for building websites or software those sorts of things and this class is
10
00:00:57,809 --> 00:01:03,000
an attempt to address this is an attempt to show you some of the tools that you
11
00:01:03,000 --> 00:01:10,381
can use to great effect in your day to day in your research and in your studies and it's going to be a class where we
12
00:01:10,381 --> 00:01:16,439
want you to teach you both how to make the most of the tools that you already
13
00:01:16,439 --> 00:01:23,520
know but also hopefully teach you about some tools so you don't know from before and how to combine those tools to
14
00:01:23,520 --> 00:01:31,049
produce more powerful things than you think you might be able to do with what you know today the class is going to be
15
00:01:31,049 --> 00:01:36,630
structured as a series of 11 one-hour lectures and each one is going to cover
16
00:01:36,630 --> 00:01:43,439
a particular topic you can see the website which is also listed there for the list of lecture topics and what date
17
00:01:43,439 --> 00:01:49,350
will do each one they will mostly be independent and so you can sort of show up for the ones that you're interested
18
00:01:49,350 --> 00:01:55,649
in but we will sort of assume that you've been following along so that as we get to later lectures I'm not going
19
00:01:55,649 --> 00:02:02,280
to be teaching you bash all over again for example we we are also going to post
20
00:02:02,280 --> 00:02:08,459
both the lecture notes and recordings of the lectures online exactly when we do
21
00:02:08,459 --> 00:02:14,130
that we haven't established yet but it will be after the lectures obviously the videos have to be posted after
22
00:02:14,130 --> 00:02:19,380
the class is gonna be run by me John and Anne each sitting over there and Jose
23
00:02:19,380 --> 00:02:25,740
who is not currently here but we'll be holding tomorrow's lecture and keep in mind that we're trying to cover a lot of
24
00:02:25,740 --> 00:02:33,240
ground over the course of just 11 one-hour lectures and so we will be moving relatively rapidly but please do
25
00:02:33,240 --> 00:02:38,430
stop us if there's anything where you feel like you're not following along if you feel like there's something you wish
26
00:02:38,430 --> 00:02:45,240
we would spend more time on just let us know please interrupt us with questions and also after each lecture we're going
27
00:02:45,240 --> 00:02:51,710
to hold office hours on the ninth floor of building 30 to the Stata Center of the computer science building as if you
28
00:02:51,710 --> 00:02:58,140
show up up in the ninth floor lounge there and the gates tower then you can come and try some of the exercises that
29
00:02:58,140 --> 00:03:04,440
we give for each lecture or just ask us other questions about things we've talked about in lecturer or other things
30
00:03:04,440 --> 00:03:11,640
about using your computer efficiently due to the limited time that we have
31
00:03:11,640 --> 00:03:19,900
available we're not going to be able to cover all tools and full detail and so we'll try to do is highlight interesting
32
00:03:19,900 --> 00:03:25,110
tools and interesting ways to use them we won't necessarily dig into the deep details about how all of it works or
33
00:03:25,110 --> 00:03:31,050
more elaborate use cases but if you have questions about them please come ask us about that too many of these tools are
34
00:03:31,050 --> 00:03:36,680
tools that we have used for years and we might be able to point you to additional interesting things you can do with them
35
00:03:36,680 --> 00:03:42,290
sort of like take advantage of the fact that we're here this class is going to I
36
00:03:42,290 --> 00:03:49,050
don't wanna say ramp up quickly but what's going to happen over the course of this particular lecture is that we'll
37
00:03:49,050 --> 00:03:54,480
cover many of the basics that we assume that you will know for the rest of the semester things like how to use your
38
00:03:54,480 --> 00:03:59,850
shell and your terminal and I'll explain what those are - those who you're not familiar with them and then will pretty
39
00:03:59,850 --> 00:04:05,250
quickly ramp up into more advanced tools and how to use them you can already see from the lecture notes the kind of
40
00:04:05,250 --> 00:04:12,120
topics that we're going to be covering and so that brings us to today's lecture in which we are going to cover the shell
41
00:04:12,120 --> 00:04:19,290
and the shell is going to be one of the primary ways that you interact with your computer once you want to do more things
42
00:04:19,290 --> 00:04:24,540
than what the sort of visual interfaces you might be used to allow you to do the
43
00:04:24,540 --> 00:04:29,669
visual interfaces are sort of limited in what they allow you to do because you can only do the things that there are
44
00:04:29,669 --> 00:04:34,919
buttons for sliders for input fields for often these textual tools are built to
45
00:04:34,919 --> 00:04:41,430
be both composable with one another but also to have tons of different ways to combine them or ways to program and
46
00:04:41,430 --> 00:04:48,060
automate them and that is why in this class we will be focusing on these command line or text-based tools and the
47
00:04:48,060 --> 00:04:53,849
shell is the place that you would do most of this work so for those of you are not familiar with the shell most
48
00:04:53,849 --> 00:04:59,219
platform provides some kind of shell on Windows this is often PowerShell but
49
00:04:59,219 --> 00:05:06,389
there are also other shells available on Windows on Linux you will find tons of terminals these are windows that allow
50
00:05:06,389 --> 00:05:13,229
you to display shells and you'll also find many different types of shells the most common of which is bash or the born
51
00:05:13,229 --> 00:05:18,990
again shell because it's such a common shell it is the one we're primarily going to be covering in these lectures
52
00:05:18,990 --> 00:05:26,159
if you're on Mac OS you will probably also have bash maybe an older version of it if you open the terminal app and so
53
00:05:26,159 --> 00:05:32,520
if you want to follow along on any of these platforms feel free but keep in mind that most of this is going to be sort of Linux centric in terms of how we
54
00:05:32,520 --> 00:05:39,000
teach it even though most of these tools work on all the platforms if you want to
55
00:05:39,000 --> 00:05:45,330
install a terminal and a shell and you don't know how to do it well we're happy to show you at office hours or it's
56
00:05:45,330 --> 00:05:51,599
usually very easy to just Google like your platform plus like terminal and you
57
00:05:51,599 --> 00:05:57,060
will get one now when you open a
58
00:05:57,060 --> 00:06:04,229
terminal you get something that looks a little bit like this so it will usually have just a single line at the top and
59
00:06:04,229 --> 00:06:10,020
this is what's known as the shell prompt you can see that my shell prompt looks like this it has my user name the name
60
00:06:10,020 --> 00:06:16,770
of the machine that I'm on the current path I'm on and we will talk about paths a little bit later and then it's really
61
00:06:16,770 --> 00:06:22,440
just sort of blinking they're asking me for input and this is the shell prompt where you tell the shell what you want
62
00:06:22,440 --> 00:06:27,479
it to do and you can customize this prompt a lot and when you open it on
63
00:06:27,479 --> 00:06:33,840
your machine it might not look exactly like this it might look something like this if you've configured it a little or
64
00:06:33,840 --> 00:06:39,779
it might look all sorts of different ways we won't go too much into customizing your shell in this
65
00:06:39,779 --> 00:06:47,790
particularly we'll do that later here we're just going to talk about how do you use this shell to do useful things and this is
66
00:06:47,790 --> 00:06:53,430
our the main textual interface you have to your computer's through this shell on the shell prompt you get to write
67
00:06:53,430 --> 00:06:58,920
commands and commands can be relatively straightforward things usually it'll be
68
00:06:58,920 --> 00:07:04,470
something like executing programs with arguments what does that look like well one program we can execute is the date
69
00:07:04,470 --> 00:07:10,290
program we just type date and press enter and then it will show you unsurprisingly the date and time you can
70
00:07:10,290 --> 00:07:17,790
also execute a program with arguments this is one way to modify the behavior of the program so for example there is a
71
00:07:17,790 --> 00:07:25,050
program called echo and echo just prints out the arguments that you give it and arguments are just white space separated
72
00:07:25,050 --> 00:07:30,720
things that follow the program name so we can say hello and then it will print hello back
73
00:07:30,720 --> 00:07:37,050
perhaps not terribly surprising but this is the very basics of arguments one thing that you'll notice is that I said
74
00:07:37,050 --> 00:07:42,060
that arguments are separated by whitespace and you might wonder well what if I want an argument as multiple
75
00:07:42,060 --> 00:07:46,720
words you can also quote things so you can do things like echo hello space
76
00:07:46,720 --> 00:07:52,710
world and now the echo program receives one argument that contains the string
77
00:07:52,710 --> 00:07:58,770
hello world with a space well you can also use single quotes for this and the difference between single quotes and
78
00:07:58,770 --> 00:08:06,120
double quotes will get back to and when we talk about bash scripting you can also just escape single characters so
79
00:08:06,120 --> 00:08:12,150
for example hello world this will also work just fine all of these rules about
80
00:08:12,150 --> 00:08:17,340
how you escape and how you parse and quote various arguments and variables
81
00:08:17,340 --> 00:08:23,520
we'll cover a little bit later hopefully you won't run into too many we ought to tease about this just keep in mind at
82
00:08:23,520 --> 00:08:29,610
least that spaces separate arguments so if you want to do something like make a directory called my photos
83
00:08:29,610 --> 00:08:35,880
you can't just type like make directory my photos it will create two directories one called my and one called photos and
84
00:08:35,880 --> 00:08:43,229
that is probably not what you want now one thing you might ask is how does the
85
00:08:43,229 --> 00:08:48,839
shell know what these programs are when I type date or when I type echo how does
86
00:08:48,839 --> 00:08:54,000
it know what these programs are supposed to do and the answer to this is your program your
87
00:08:54,000 --> 00:08:59,759
computer has a bunch of built-in programs that comes with the machine just like you your machine my chip with
88
00:08:59,759 --> 00:09:05,339
like the terminal app or it might chip with like Windows Explorer or at my chip
89
00:09:05,339 --> 00:09:11,639
with some kind of browser it also ships with a bunch of terminal centric applications and these are stored on
90
00:09:11,639 --> 00:09:18,209
your file system and your shell has a way to determine where a program is
91
00:09:18,209 --> 00:09:24,620
located basically has a way to search for programs it does this through something called an invariant
92
00:09:24,620 --> 00:09:29,970
environment variable an environment variable is a variable like you might be
93
00:09:29,970 --> 00:09:35,160
used to for programming languages it turns out that the shell and the bourne-again shell in particular is
94
00:09:35,160 --> 00:09:41,550
really a programming language this prompt that you're given here is not just able to run a program with
95
00:09:41,550 --> 00:09:47,910
arguments. You can also do things like while loops, for loops, conditionals... All of these - you can define
96
00:09:47,910 --> 00:09:56,399
functions, you can have variables, and all of these things you can do in the shell. We'll cover a lot of that in the next lecture, on shell scripting. For now,
97
00:09:56,399 --> 00:10:02,699
though, let's just look at this particular environment variable. Environment variables are things that are set whenever you start your shell
98
00:10:02,699 --> 00:10:08,160
they're not things you have to set every time you run your shell there are a bunch of these that are set things like
99
00:10:08,160 --> 00:10:16,170
where is your home directory what is your username and there's also one that's critical for this particular purpose which is the path variable so if
100
00:10:16,170 --> 00:10:22,589
I echo out dollar path this is going to show me all of the paths on my machine
101
00:10:22,589 --> 00:10:27,930
that the shell will search for programs you'll notice that this is a list that
102
00:10:27,930 --> 00:10:33,000
is colon separated it might be kind of long and hard to read but the essentials
103
00:10:33,000 --> 00:10:38,279
is that - whenever you type the name of a program is gonna search through this
104
00:10:38,279 --> 00:10:43,769
list of paths on your machine and it's gonna look in each directory for a
105
00:10:43,769 --> 00:10:49,110
program or a file whose name matches the command you try to run so in my case
106
00:10:49,110 --> 00:10:54,509
when I try to run date or echo it's gonna walk through these one at a time until it finds one that contains the
107
00:10:54,509 --> 00:11:00,000
program called date or echo and then it's gonna run it if we want to know which one it actually runs there's a
108
00:11:00,000 --> 00:11:07,500
command called which which lets us do that so I can type which echo and will tell me that if I were to run a program
109
00:11:07,500 --> 00:11:12,720
called echo I would run this one it's worth pausing here to talk about what
110
00:11:12,720 --> 00:11:18,620
paths are so paths are a way to name the location of a file on your computer on
111
00:11:18,620 --> 00:11:24,780
Linux and Oh Mac OS these paths are separated by slashes forward slashes so
112
00:11:24,780 --> 00:11:30,930
you'll see here that this is in the in the root directory so the slash at the
113
00:11:30,930 --> 00:11:37,710
very beginning indicates that this is starting from the top of the file system then look inside the directory called
114
00:11:37,710 --> 00:11:43,580
USR then look inside the directory bin and then look for the file called echo
115
00:11:43,580 --> 00:11:48,620
on windows paths like this are usually separated by back slashes instead and
116
00:11:48,620 --> 00:11:53,640
we're on Linux and Mac OS everything lives under the root name space so all
117
00:11:53,640 --> 00:12:00,270
paths start with a slash or all absolute paths on Windows there is one root for
118
00:12:00,270 --> 00:12:08,220
every partition so you might have seen things like C colon backslash or D colon backslash so Windows has separate sort
119
00:12:08,220 --> 00:12:14,850
of file system path hierarchies for each each Drive that you have whereas on Linux and Mac OS these are
120
00:12:14,850 --> 00:12:20,010
all mounted under one namespace you'll notice that I said the word absolute
121
00:12:20,010 --> 00:12:27,360
path and you might not know what that means so absolute paths are paths that
122
00:12:27,360 --> 00:12:33,720
fully determine the location of a file so in this case this is saying this is talking only about a specific echo file
123
00:12:33,720 --> 00:12:39,030
and it's giving you the the full path to that file but there are also things
124
00:12:39,030 --> 00:12:45,240
known as relative paths so a relative path is relative to where you currently
125
00:12:45,240 --> 00:12:52,490
are and so the way we find out where we currently are is you can type PWD for
126
00:12:52,490 --> 00:13:00,060
present working directory present print working directory so if I type PWD it
127
00:13:00,060 --> 00:13:05,790
will print out the current path that I'm in right so currently I'm in the home
128
00:13:05,790 --> 00:13:11,030
directory under the root and then John under that and then dev under that etc
129
00:13:11,030 --> 00:13:16,770
from here I can then choose to change my current working directory and all
130
00:13:16,770 --> 00:13:24,629
relative paths are relative to the current working directory which is basically where you they are in this case for example I can
131
00:13:24,629 --> 00:13:30,449
do CD / home CDs change directory this is the way that I change what my current
132
00:13:30,449 --> 00:13:37,889
working directory is in this case I change to home and I am now you'll see my my shell prompt change to say that I
133
00:13:37,889 --> 00:13:44,220
am now in home it just gives me the name of the last segment of the path but you can also configure your terminal to give
134
00:13:44,220 --> 00:13:50,309
you the full path whenever you're anywhere and now if I type PWD again it
135
00:13:50,309 --> 00:13:59,100
will tell me I'm in slash home there are also a couple of special directories that exist there is dot and dot dot dot
136
00:13:59,100 --> 00:14:05,129
means the current directory dot dot means the parent directory so this is a
137
00:14:05,129 --> 00:14:13,079
way that you can easily navigate around the system for example here if I type CD dot dot it will tell me that I am now in
138
00:14:13,079 --> 00:14:21,139
slash so I'm now in the root of the file system I was in slash home now I'm in slash and indeed if I type PWD well it
139
00:14:21,139 --> 00:14:26,980
will do that right thing and I can also then use relative paths to go down into the file system right so I can do CD dot
140
00:14:26,980 --> 00:14:34,079
slash home and this is gonna CD into the home directory under the current
141
00:14:34,079 --> 00:14:39,839
directory right so this will bring me back to slash home if I now tried CD dot
142
00:14:39,839 --> 00:14:45,569
slash home again it will say there's no such directory because there is no home directory under the current directory
143
00:14:45,569 --> 00:14:53,699
I'm on which I changed by doing CD right and I can sort of see de all the way
144
00:14:53,699 --> 00:15:01,110
back to the place that I was using relative paths and I can also do things
145
00:15:01,110 --> 00:15:07,040
like dot dot dot dot dot to get back to
146
00:15:07,040 --> 00:15:13,019
somewhere deep in my file system this happens to be all the way back to the root so here there's a bin directory and
147
00:15:13,019 --> 00:15:20,309
another bin there's an echo file and so then I could do world and that runs the echo program under bin alright so this
148
00:15:20,309 --> 00:15:26,579
is a way that you can construct paths to arbitrarily traverse your filesystem sometimes you want to absolute paths and
149
00:15:26,579 --> 00:15:34,390
sometimes you want relative ones usually you want to use whichever one is shorter but if you want to for example run a program or write
150
00:15:34,390 --> 00:15:41,830
a program that runs the program like echo or date and you want it to be able to run be run from anywhere you either
151
00:15:41,830 --> 00:15:47,770
want to just give the name of the program like date or echo and let the the shell use the path to figure out where
152
00:15:47,770 --> 00:15:53,500
it is or you want to give its absolute path because if you gave a relative path then if I ran it in my home directory
153
00:15:53,500 --> 00:16:01,720
and you ran it in some other directory it might work for me but not for you in
154
00:16:01,720 --> 00:16:08,320
general when we run a program it is going to be operating on the current working directory at least by default
155
00:16:08,320 --> 00:16:13,750
unless we give it any other arguments and this is really handy because it means that often we don't have to give
156
00:16:13,750 --> 00:16:20,050
full paths for things we can just use the name of files and in the directory that we're currently in one thing that's