Command-line Environment
MIT 6.NULL The Missing Semester of Your CS Education, lecture 5, explained in plain English
Want this lecture to stick? In LessonBound you get checked practice questions for every part, can ask about anything you don't get, and can listen with your screen off. Free, no ads.
Learn this lecture freeWatch or read the original lecture: MIT OpenCourseWare.
Part 1
This part shows how to stop, pause, and background running programs, run several shell sessions at once, and save time with shortcuts called aliases.
Key ideas
- A signal is a short message sent to a running program to tell it to do something, such as stop. Pressing Ctrl-C sends a SIGINT signal, which usually stops the program, but a program can choose to catch it and ignore it.
- Ctrl-Z pauses a running job by sending a stop signal. You can then resume it in the foreground with fg or in the background with bg.
- A background job is still tied to your terminal, so closing the terminal can kill it. Running the program with nohup, or using disown on a job already started, stops that from happening.
- A terminal multiplexer such as tmux lets you split one terminal into several panes and tabs, and detach from a session and reattach later. This is especially useful on remote machines.
- An alias is a short name the shell swaps for a longer command, so you do not have to type long commands with many flags each time.
Words to know
- signal
- A short message the system sends to a running program to get it to respond, for example to stop or pause.
- SIGINT
- The signal sent when you press Ctrl-C. It asks the running program to interrupt, and it usually stops the program.
- nohup
- A command wrapper that runs another program so it keeps going even after you close the terminal.
- alias
- A nickname you set up in the shell that stands in for a longer command, so typing the nickname runs the full command.
Example
Think of a shell job like a kitchen order. Ctrl-C is like shouting 'stop cooking!', and a cook can choose to ignore the shout if they have been told to keep going. An alias is like a short code on the order slip that the kitchen expands into the full recipe.
3 checked practice questions for this part are in the app.
Part 2
This part covers shortcuts and settings that make the command line faster and more personal, and how to use remote servers safely over SSH.
Key ideas
- An alias is a short nickname for a longer command, such as ll for ls -lh. Aliases only last for the current shell session unless you save them in a startup file.
- Dotfiles are hidden plain-text settings files, such as .bashrc or .gitconfig. Keep them in their own version-controlled folder and link them into place with a script, so you can set up a new machine quickly and track changes over time.
- Settings can be made to work on several machines by using if-statements to apply rules only in certain cases, or by using includes to load a separate file with machine-specific settings.
- SSH lets you log in to and run commands on a remote server. Key-based login uses a private key that works like a password, so you do not have to type a password each time. You can store server details in ~/.ssh/config so you can connect with a short name.
- Local port forwarding with ssh -L lets you reach a service running on a remote server through a port on your own computer. For example, a Jupyter notebook on the server's port 8888 can be opened on your local port 9999.
Words to know
- alias
- A short name you create for a longer command, so you type less.
- dotfile
- A hidden settings file whose name starts with a dot, used to set up a program the way you like it.
- symlink
- A shortcut that points from one place in the file system to a file stored somewhere else.
- port forwarding
- Sending traffic from a port on your own machine to a port on a remote machine, so you can reach a service that is not directly open to you.
Example
Think of an alias like a speed-dial button on a phone: one press calls a long number you would otherwise have to type every time. Dotfiles are like the saved settings on a phone that you copy to a new phone so it feels the same. Port forwarding is like a mail forwarding service that delivers letters sent to your address to a friend's house across town.
3 checked practice questions for this part are in the app.
Part 3
This part covers how to protect your remote connections, pick a better shell, and customize your tools so the command line works the way you want.
Key ideas
- Your SSH config file can be kept with your other dotfiles (settings files that start with a dot), but do not make it public. It can reveal server addresses, usernames, and open ports, which may help attackers.
- Server-side SSH settings live in /etc/ssh/sshd_config. There you can turn off password logins, change the SSH port, and set other rules, even for each user.
- Mosh (the mobile shell) is a tool that improves on SSH. It keeps your session working when your connection drops, your laptop sleeps, or your network changes, and it handles slow connections better.
- Zsh is another shell that works like bash but adds helpful features such as better tab completion and spelling correction. Frameworks like oh-my-zsh add even more features on top.
- Shell frameworks can make your shell slower, especially if they run a lot of code. You can test their speed and turn off the features you rarely use.
Words to know
- dotfile
- A settings file whose name starts with a dot, such as one that customizes your shell or editor. Keeping them in one place makes it easy to set up a new computer the same way.
- globbing
- Using wildcard symbols like * to match many file names at once. Zsh has smarter globbing, including the ** pattern.
- mosh
- A remote login tool, like SSH, that stays connected through sleep, network changes, and lag.
- alias
- A short nickname you create for a longer command, so you can type less. The lesson suggests making an alias called dc that works as cd.
Example
Think of your dotfiles like a saved set of seat and mirror settings for your car. When you get into a new car, you can load your saved settings in one step instead of adjusting everything by hand. A setup script does the same job for your computer.
3 checked practice questions for this part are in the app.
← Lecture 4: Data Wrangling · Lecture 6: Version Control (Git) →
Notes written by AI (Claude) from the lecture's official transcript, so check anything important against the lecture. MIT CSAIL · CC BY-NC-SA 4.0 · not affiliated with or endorsed by MIT. These notes are shared under the same license.
LessonBound · Free lecture notes · Privacy · Terms · New York