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

The "Using 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:

After prompting students to open a terminal window and figuring out which shell they have installed on their computers, James demonstrates how to navigate through folders and files in an operating system through the terminal.

Preview
Close

Transcript from the "Using Shell" Lesson

[00:00:00]
>> James Halliday: So now, it's time to learn the command line. We're gonna be using bash which is a very popular shell. It's the default shell on a lot of systems including Macros 10 and on Linux for interactive shells anyways. So if you wanna try something, if everyone could pop open a terminal and type this, if you could type echo, then space $, and then all in caps, the word SHELL.

[00:00:29]
It should say something like /bin/bash, or maybe you have another kind of shell installed, but it will read something like that. So if I go ahead and do this, do echo $SHELL, I see /bin/bash.
>> James Halliday: So,
>> James Halliday: Echo in this case is a command and the $SHELL is an example of an argument.

[00:01:02]
So you can have as many other words as you want that are to the right of the commands. You see the different kinds of arguments and they just kind of customize how the command should work. Maybe what kinds of files it should operate on and what it should generally do.

[00:01:21]
>> James Halliday: So another fun command to try is the ls command, so this lets you list files. So if I type ls, I see everything in my home directory, some images and some directories in this case.
>> James Halliday: If we wanna provide some arguments to the ls commands, ls expects.

[00:01:49]
If you give it different arguments, those arguments are expected to be in different locations that you wanna list. So for example, I can do ls /, that's gonna list all of the files in the root directory. Or I can do, if I wanna see everything in my data directory, I can ls data, and I see everything in there.

[00:02:11]
That's weird.
>> James Halliday: There should be a lot more files in there. I'm gonna summon the Raspberry Pi which I am. I forgot about that. [LAUGH] So there we go. Right, that's what I expected. See, I didn't even know that I was on a different system because they're so interoperable.

[00:02:31]
They're both Debian systems as well.
>> James Halliday: There's another fun command that you can try which is pwd. This tells you kind of where you are on your system. So here I see that I'm in this directory, in my home directory called doc/workshop/mn/day1. You can also change the directory with the cd command.

[00:02:58]
So if I now go to, if I wanna go up with directory, I can do cd.. And I can also change into this directory, day 1. So this is sort of navigating around if you've used a graphical file explorer. Going into directories and then going back up to the parent directory again.

[00:03:22]
So if everyone could just take a little bit of time to poke around with these commands which are cd, ls, and pwd, I think that would be pretty good to do. And if you are already familiar with these commands, maybe try using some of the other switches to these commands.

[00:03:46]
Which you can read about using this command called man. Tells you everything you wanna know about any command. So if you ever wanna read more about any of these commands that we're gonna do, you can usually type man space and the command name. And you can learn more about it.

[00:04:04]
So there's all kind of fun options, written by Richard Stallman and David MacKenzie. That's very interesting too.

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