Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
      You have completed Introduction to the Terminal!
      
    
You have completed Introduction to the Terminal!
Preview
    
      
  By default, terminals run a program called a shell.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
                      The terminal is a text interface.
                      0:00
                    
                    
                      By default,
terminals run a program called a shell.
                      0:02
                    
                    
                      There are many different
shell programs available,
                      0:05
                    
                    
                      most of them with names ending in SH,
like ZSH, KSH, and so on.
                      0:08
                    
                    
                      Most operating systems today
run a shell called Bash, and
                      0:13
                    
                    
                      that's what we're running here.
                      0:17
                    
                    
                      All the different shells
work very similarly, so
                      0:19
                    
                    
                      the things you'll learn in Bash will
be applicable in the other shells too.
                      0:21
                    
                    
                      You can see a bunch of text here,
ending in a dollar sign.
                      0:26
                    
                    
                      This is the shell prompt, the shell
is prompting you to type something.
                      0:30
                    
                    
                      Most shell prompts end with a dollar sign,
like this.
                      0:35
                    
                    
                      The blinking box following
the dollar sign is the cursor,
                      0:38
                    
                    
                      it's the place the text
you type will appear.
                      0:42
                    
                    
                      It mostly works like the cursors you've
seen in word processors and web forms, but
                      0:44
                    
                    
                      with a few exceptions.
                      0:49
                    
                    
                      You can type text with the letter
keys on your keyboard, and
                      0:51
                    
                    
                      you can delete it with the backspace key.
                      0:53
                    
                    
                      You can move back and
                      0:56
                    
                    
                      forth within the text you've typed on this
line with the left and right arrow keys.
                      0:57
                    
                    
                      But you can only type on this one line,
you can't move off of it.
                      1:02
                    
                    
                      If you press the up and
                      1:06
                    
                    
                      down arrow keys, it will instead cycle
through entries you've made previously.
                      1:07
                    
                    
                      Here you can see it bringing
up commands I entered before.
                      1:11
                    
                    
                      This is called command history, and we'll
talk about it more in an upcoming video.
                      1:14
                    
                    
                      If I hit the Enter key without typing
anything, it won't really do anything,
                      1:19
                    
                    
                      it'll just display another prompt.
                      1:23
                    
                    
                      We can run commands at the prompt to
execute other programs inside the shell.
                      1:26
                    
                    
                      The output of these commands
will be shown in the terminal.
                      1:31
                    
                    
                      Because the shell offers you a single
line of text where you enter commands,
                      1:34
                    
                    
                      this is often referred
to as the command line.
                      1:38
                    
                    
                      Let's try running a program called ls,
which is used for listing files.
                      1:42
                    
                    
                      I type ls and
press the Enter key to run the command.
                      1:46
                    
                    
                      The program runs, and its output appears
on the terminal below the command line.
                      1:50
                    
                    
                      The program prints out
the names of several files.
                      1:55
                    
                    
                      Then the ls program finishes, and
we're returned to our shell prompt.
                      1:59
                    
                    
                      The shell is ready for
us to type another command.
                      2:03
                    
                    
                      Let's try running another program.
                      2:06
                    
                    
                      This time we'll run the whoami command,
                      2:08
                    
                    
                      which prints the name of
the current user account.
                      2:10
                    
                    
                      It looks like we're logged in
as a user named treehouse.
                      2:13
                    
                    
                      Once again, the program completes and
we're returned to the shell prompt.
                      2:17
                    
                    
                      Now I'll run a program called cat,
which concatenates or
                      2:21
                    
                    
                      joins the contents of files together.
                      2:25
                    
                    
                      Normally, you'd provide the names of one
or more files you want cat to print out.
                      2:28
                    
                    
                      But since I didn't provide any, the cat
program sits there waiting for input.
                      2:32
                    
                    
                      I don't want to use this right now,
so I'm going to stop the cat program.
                      2:38
                    
                    
                      To do this, I hold down the Ctrl key
on my keyboard and press the C key.
                      2:41
                    
                    
                      This special key combination sends
a signal to the program telling it that I
                      2:46
                    
                    
                      want to quit.
                      2:50
                    
                    
                      Any time a terminal program
appears to be stuck or
                      2:52
                    
                    
                      isn't doing what you want, you can
press Ctrl+C to send it this signal.
                      2:55
                    
                    
                      Most of the time, the program will quit
and return you to the shell prompt, so
                      3:00
                    
                    
                      you can run another command.
                      3:03
                    
                    
                      By the way, you may be wondering
what's up with these crazy command
                      3:05
                    
                    
                      names like ls and cat.
                      3:08
                    
                    
                      When you're working in the terminal,
                      3:10
                    
                    
                      there are certain commands
you'll be using a lot.
                      3:11
                    
                    
                      You don't wanna have to type
the word list over and over, so
                      3:15
                    
                    
                      the command name is abbreviated to ls.
                      3:17
                    
                    
                      You don't wanna type
concatenated all the time, so
                      3:20
                    
                    
                      the name is shortened to cat, and so on.
                      3:22
                    
                    
                      The abbreviations take a little extra
time when you're learning the commands.
                      3:26
                    
                    
                      But believe me, they'll save you
some typing in the long run.
                      3:29
                    
                    
                      Let me run one more program, clear.
                      3:33
                    
                    
                      The clear program clears output
from the terminal screen,
                      3:36
                    
                    
                      moving the prompt up to the top.
                      3:39
                    
                    
                      By default, Bash shell also
supports a keyboard shortcut that
                      3:42
                    
                    
                      does the same thing,
just hold the Ctrl key and press L.
                      3:45
                    
                    
                      You don't have to remember
this key combination,
                      3:50
                    
                    
                      it's not as important as Ctrl+C.
                      3:52
                    
                    
                      But if you see me clear
the screen during this course,
                      3:55
                    
                    
                      you'll know I did it by pressing Ctrl+L.
                      3:57
                    
                    
                      Before we move on, I should point out
a couple more aspects of the prompt.
                      4:00
                    
                    
                      This prompt shows the name of
the current user, treehouse.
                      4:05
                    
                    
                      Then it shows the directory or folder that
we're in, ~/workspace, or just workspace.
                      4:10
                    
                    
                      I can change to a different directory, and
                      4:17
                    
                    
                      the directory name will be updated
when the new prompt is shown.
                      4:19
                    
                    
                      We'll talk more about directories
and the cd command later.
                      4:23
                    
                    
                      As I mentioned before,
                      4:27
                    
                    
                      the end of the prompt is usually marked
with a dollar sign for normal users.
                      4:28
                    
                    
                      This could be changed, but
it's conventional to use a dollar sign.
                      4:32
                    
                    
                      The prompt is customizable, so
                      4:36
                    
                    
                      don't worry too much if the prompt
on your system shows different info.
                      4:37
                    
                    
                      Now you know how to enter
commands in the shell.
                      4:42
                    
                    
                      Up next, we'll look at ways to change
the behavior of those commands.
                      4:44
                    
              
        You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up