0% found this document useful (0 votes)
58 views

Terminal Handout 1

The document provides an introduction to using the terminal or command line interface on MacOS and Windows computers, explaining how to access the terminal, basic navigation commands like ls, cd, and mkdir, and examples of using commands to create a new directory and file and write text to the file. Useful terminal shortcuts and resources for additional command references are also listed.

Uploaded by

api-434252529
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Terminal Handout 1

The document provides an introduction to using the terminal or command line interface on MacOS and Windows computers, explaining how to access the terminal, basic navigation commands like ls, cd, and mkdir, and examples of using commands to create a new directory and file and write text to the file. Useful terminal shortcuts and resources for additional command references are also listed.

Uploaded by

api-434252529
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Apple AiC Summer 2020 Workshop

Terminal

What’s Terminal?

Terminal on Mac, or the Command Line on Windows, provides a place for you to type
instructions (commands) for your computer to follow. With Terminal you can do all the
things you do with the user interface of your computer, but often more efficiently. It can
be used to:
• Access and change files
• Use Git for version control (keeping track of changes to files)
• Run programs
• Much more!

Accessing Terminal and Command Line

On MacOS
Type command + space to bring up spotlight, search for “Terminal”, hit enter to open the
Terminal app.

On Windows
Start -> type “cmd” or “Command Line”

Terminal Basics

When you use the command line to navigate the files on your computer it’s similar to
navigating the user interface, but some of the language is different. Instead of folders,
we refer to directories.

When you first open Terminal, you’ll see your prompt. For example, mine is:

maddiezug@ms-MacBook-Pro ~ %

The first part- “maddiezug” is my username. The second part “@ms-MacBook-Pro” is


the name of my computer. The third part “~” is my current directory, the name of the
folder I’m currently in. “~” is called the base directory, and contains my Desktop,
Downloads, and Documents. When you open a new Terminal window you’ll always start
in the base directory.

Some commands are just one word or acronym, and others take arguments. Let’s take
a look at some commands and try them out.

Useful Commands
macOS: pwd
Windows: cd

Stands for “print working directory”, or "change directory". It prints the path to your
current directory.

macOS: ls
Windows: dir

Lists all of the files and directories in your current directory.

cd path/to/directory

Stands for “change directory”. It moves you to the directory you specify in path/to/
directory. For Windows, if you don't specify any directory, it will print your current
directory. For Mac, if you don't specify any directory it will take you to your base
directory.

cd ..

Moves you back up one directory.

mkdir nameOfDirectory

Stands for “make directory”. It makes a new folder in your current directory named
nameOfDirectory.

open nameOfFileOrDirectory

Opens the nameOfFileOrDirectory file or directory.

echo “hello world”

Echo prints the text you pass it in quotes.

macOS: man commandYouWantHelpWith


Windows: HELP commandYouWantHelpWith

Opens the manual for the command, which describes what it does and how to use it. On
macOS Terminal, this will open a vim page. To exit the page type "q" for quit.

See the resource section of this handout for links to cheat sheets with tons more
commands to play with.
Useful Shortcuts

control-C

Will stop whatever command you're currently running

tab

will autocomplete a command or filename

up arrow

will let you navigate through previous commands you've typed. So if you want to run a
command twice but not type it both times you can use up arrow to get it back!

Try it out

Let’s try making a new folder in our Documents folder, and creating a text file inside with
our name in it, all using the command line. To start, open Terminal and type:

ls

You should see a list of files and folders from your base directory. Now type:

cd Documents

Your Terminal prompt should change! Mine is now:

maddiezug@ms-MacBook-Pro Documents %

Since I’m now in my Documents folder. Next, try listing the contents of your directory
again:

ls

Nice! Now we’ll make our new folder:

mkdir myFolder

I called my folder myFolder, but you can choose whatever name you want. Now I want
to navigate inside my new folder. Let’s type:

cd myFolder

Now that I’m in my new folder, I want to create a text file:


touch myFile.txt

Let’s check that my file was actually created. See what’s in myFolder:

ls

We should see myFile.txt listed. Great! Next I want to write my name into the file. With
the user interface, I would usually just open the file and type in my change. But with
terminal, I can add my text with a command:

echo “maddie” > myFile.txt

In this command, the > means to pass the result of the first command to the destination
specified in the argument after the >. So echo will print “maddie” into my file! To confirm
that it worked, type:

cat myFile.txt

You should see your name printed! Awesome! You can also view your new file in
textEdit by typing:

open myFile.txt

Resources

MacOS Terminal command reference list:


https://github.com/0nn0/terminal-mac-cheatsheet

Windows Command Line reference list:


http://www.cs.columbia.edu/~sedwards/classes/2015/1102-fall/
Command%20Prompt%20Cheatsheet.pdf

Command Line Commands


https://www.codecademy.com/articles/command-line-commands

You might also like