Transcript from the "Introducing UNIX" Lesson
>> James Halliday: Welcome everyone, both here and in cyber-space. Today, we're going to be going through the command line using bash, which is a shell for the Unix system. And so, I wanted to start out by talking a little bit about what the heck is Unix? So, Unix is an operating system that actually got its start as a project called Multix that started in 1964 is a collaboration between Phil Labs, General Electric and MIT, and then, I think, in 1969 Phil Labs pulled out and made their own version of this, bundable projects that became UNIX.
[00:00:40] So, Phil Labs is kind of a really important place where a lot of this stuff happened probably from the 60s up until the 80s. So, at Bell Labs not only that you get the transistor in previous times, but you got Unix and the C programming language and a lot of the different utilities that are kind of like still around, still important foundational pieces of modern systems.
[00:01:12] So, there's a really great video in the lecture notes right here that's from AT&T's archive. I think, it was made from In the 70s, maybe, or early 80s, about. And people like Brian Kernighan and Ken Thompson talk about what makes the UNIX system work. And I really love this one little segment where Brian Kernighan just sits down on the terminal and makes a little one-liner spell checker [LAUGH] using a bunch of small tools.
[00:01:42] I think, that really embodies the power and flexibility of this kind of approach to computing. That's still really useful, even today. So, I think, it's important kind of to talk a little bit about the context and the history where these systems were built. So, the big thing, kind of in the 60s and early 70s, was building time-sharing systems, because computers were very, very expensive.
[00:02:10] And so, you wanted many people to be able to use them at the same time, because then you wouldn't have to buy so many. So, the original systems were built around the idea of time sharing, or like batch computing, so a bunch of people could be logged into the same machine, and their little programs could be running sort of simultaneously and then our printing system can kind of schedule then accordingly.
>> James Halliday: To do this at first there are these pretty ridiculous by standards machines that had a keyboard and they had a printer, and so, when you would run your program on one of these things called a teleprinter. You would type in a command on a keyboard and a line feed printer would print out the output of your program line by line as it ran on the mainframe.
[00:03:01] These systems weren't very complicated and they were replaced by monochrome monitors instead of a printer, to save on paper, but the basic idea was the same, the terminal it was called, that sits at your desk, can't really do any computing of its own. It's all wired up either through the telephone network, or through fiber optic cable to the mainframe.
[00:03:26] Later, this went away and the mini computer, micro computer era, kind of. Now, we have CPUs in the machines on our desk. But the legacy was really important from this era, because it gave us an idea of this called standard input, like someone typing on the keyboard, and standard output, like this printer that's printing out the characters from your program.
[00:03:55] And even writing any kind of program today, these ideas are really important, because they sort of give you a place where you can log information, you can display output, and you don't have to come up with your own system for doing that. But I know they're really important piece about this idea is that instead of the keyboard, instead of having to type everything, you can get a program to do the typing for you, and I'll get more into that later.
[00:04:28] And we still use ideas of course like a, printed, which back in the old days meant that an actual printer was printing, but now, it's just a word that we used to say that characters are being written to the screen.
>> James Halliday: So, the UNIX system has this kind of layered model where at the core, you have the kernel.
[00:04:53] The kernel is a program that kind of manages resources, and then you have the shell, that's what we're gonna be doing mostly today. And then, you have utilities, so the shell is a program that runs other programs. And the utilities are little system tools, maybe you've written, maybe the system provides them, maybe your friend wrote them.
>> James Halliday: So, the kernel's job is to do things like scheduling. So, if you have two programs and they're running at the same time on this machine, you might only have one CPU, so the kernel's job is to make sure that, okay, this program gets to run 1,000 instructions, and then we're gonna switch over to this program that can run 1,000 instructions and does this balancing act.
[00:05:45] It's also important that the kernel provides a kind of standardized interface to a lot of different kinds of hardware like a keyboard and a mouse. Or maybe a network card in a consistent way, so that you don't have to write a different program based on whether you have a Ethernet card from Broadcom, or whether you have one from Realtek.
[00:06:06] It's all standardized at the kernel level. And also the kernel sort of deals with how programs can allocate and free memory. So, both that they can't read each others memory, which is important for security and stability, so that the kernel can manage using the actual physical memory, and also things like swap space, which is when your computer uses the hard disk for memory.
[00:06:38] And there's this thing called a SYSCALL and a standard called Posix, P-O-S-I-X, that sort of say how this all should basically work in a kind of standards compliant way on any kind of system that's like a Unix C system, that includes Linux and VSD and even Mac OS 10.