Check out a free preview of the full Introduction to Bash, VIM & Regex course

The "Introducing the Unix Shell" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. Here's what you'd learn in this lesson:

James presents the Unix shell, a computer program that executes other computer programs, and its importance with the UNIX philosophy.

Preview
Close

Transcript from the "Introducing the Unix Shell" Lesson

[00:00:00]
>> James: The shell is, like I said, a computer program that's use to launch other computer programs, and it does this via a text interface.
>> James: So, you type in things like commands and the commands have arguments. And then, they can read from the standard input, the keyboard or another program, and it can write to standard output.

[00:00:24]
>> James: And, the first UNIX shells, I think the first one was in 1971. I think it's on the next slide are very strongly influenced the shells that we even use today like to the point where they're fairly recognizable. And you can even run some programs that were made on those very early shells, on a modern shell.

[00:00:45]
Or you can actually run the C program, and compile it even today, and it still works. So you could actually run this old software, which is pretty fascinating.
>> James: Here's a list of some shells, and not a complete list, of course, because anyone can write their own shell.

[00:01:03]
It's kinda fun.
>> James: But a lot of them are very old, so the first one was the Thompson shell in 1971, and then there were a bunch more. Probably the most important one's today are bash, which we're gonna be learning, which was in 1987 and it's been maintained since then by another maintainer.

[00:01:24]
And also it's important to know about ash and dash, because they show up in places like busy box Linux and they're also the default shell on different kinds of like dbm systems.
>> James: So,
>> James: The other important thing to note is that, it's not just enough to know POSIX and to know how the kernel Cisco is working.

[00:01:53]
Then to know the show works because, everything on a Unix system kind of exist in this ecosystem of other programs. And one of the really important ideas is that, you can build programs by combining existing programs. And,
>> James: So, that's why a big part of this talk is gonna be diving into a lot of the programs that you're likely to find on a Unix system, and how you can plumb them together.

[00:02:26]
>> James: I think it's also important to know, like even though this is a very old operating system that started out in 1969, it's still extremely common. And this is important because it's a proven model that's worked in a lot of different cases, like it's on phones, it's on like my laptop, it's on any of your laptops.

[00:02:48]
It's also got a really vast ecosystem especially of open source software. And text is also a very powerful interface for some reasons I will get into.
>> James: Some fun places where you might not expect Unix to live. So I could tell you a little story. One time, when I was living in Fairbanks, Alaska,

[00:03:11]
>> James: Going to college there, I was doing an end map, which is a port scan, to figure out what the IP address of the desktop computer in the living room was, cuz I didn't wanna go over there and type something in. And so, I was searching for anything running on port 22, which is the port used for SSH, which is a kind of secure login.

[00:03:31]
And, I noticed, I found the desktop, of course. And I found my wireless router which I'd flashed with I think DDWRT which is a custom firmware that you can flash some kinds of routers, Wi-Fi routers with. We were using that to actually mirror the open Linksys routers that we could get more reliably because we didn't have Internet that time at the house.

[00:03:55]
>> Speaker 2: [LAUGH]
>> James: Anyways, but then later, we got a DSL modem, and I noticed that the DSL modem IP address showed up as listening on port 22, which was very interesting. And so, I tried to SSH into it with the same password used for the web login, and there I was at, [LAUGH] at a Unix shell.

[00:04:17]
And I had all kinds of commands that I expected to be there. I managed to figure out how, just with some Unix commands, how to copy all of the copy the entire image of the system out to my computer. And I was like poking around and didn't really find anything interesting but that's just one of the many kinds of places where you might find a Unix command line.

[00:04:40]
I can show you also, so I've got this other computer right here that many of you have seen. I'll just hold it up so that the livestream can see. This is a Raspberry Pi that's set up to be a pneumatic computing device. So I've got goggles here that I can wear.

[00:04:58]
And it's running Raspbian, which is a distribution of Linux based on Debian. And I can SSH into this computer,
>> James: From my terminal right here. And here I go, I'm on a Unix system. I can do things like, I can see what kind of processor I have. So I've got, this is a Raspberry Pi 3, so it's actually got quad-core ARM7 processor, it's pretty good.

[00:05:26]
And another place where you might find Unix shell is an Android phone. So if you've configured an Android phone to be in developer mode which you can do I think by clicking the, if you go into the Settings page, like About, there's a version number. If you click it seven times, you can put your phone in developer mode.

[00:05:47]
And then, if you have this program installed called ADB, you can do, adb shell. And now, here I go, I have a shell that's running on my phone. So I can list files, I can move around, I can see what's on the SD card.
>> James: I can do all kinds of fun stuff, which is I think a lot nicer than writing Java [LAUGH] or using somebody else's program to fiddle around.

[00:06:15]
So it's really useful, you can install software offline if you have the APK file, using the command line on Android. A lot of things, I think are a lot simpler if you wanna play around with a phone that you've got.
>> James: Also, it's a really important,
>> James: System for operating things like web servers or other pieces of Internet infrastructure.

[00:06:40]
So,
>> James: The command-line is kind of, it's in a lot of places, maybe a lot more than you might think. And the important part is that, if you know the command-line, that skill is extremely transferable to all of those different places. And a lot of those kinds of hardware might not even have something like a graphical display.

[00:07:04]
So the command-line is the only way that you can really interface with some of these systems.
>> James: This is because it uses a text interface. So,
>> James: Really nice thing about a text interface is all that you need to interact with the system, if you have a text interface like a shell is some way of getting data into and out of it.

[00:07:28]
So that could be a network connection, it could be a serial port link, it could be Bluetooth or maybe a web socket. All kinds of ways that you can establish a connection where a text interface will be useful.
>> James: So I think the other really important thing about the Unix system and using the command-line and knowing the command-line well is this idea of the Unix philosophy, which is many kind of related ideas.

[00:08:02]
It's sort of hard to pin down exactly what is in a single sentence, but some a the main ideas are that if you have programs, they should do one thing well. They shouldn't like have a bunch a features, they should really kind of have a narrow scope for what their purpose is.

[00:08:20]
So they're fairly simple, typically. And that you should be able to combine these single purpose programs to build bigger programs by kind of plumbing them together with things like pipes and redirects and that sort of stuff.
>> James: So there is a really great book published by Bell Labs in 1984 called Unix Programming Environment.

[00:08:44]
I think you can find PDFs on the Internet, and it kind of goes through a lot of this stuff. Some of the stuff just kind outdated but a lot of the philosophy and even a lot of the commands are still applicable today.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now