Your wish is my command


CLI.1.2


Becoming a developer has made me feel very powerful. I can command my computer to do things with just a thought a couple of keystrokes. I started to feel like a real developer when I learnt how to use my terminal and utilized the command line interface(CLI).

 

Screen Shot 2016-04-13 at 3.36.59 PM
Your computer is a genie in a bottle

SETUP

First thing is to find terminal on a Mac OS

  • Hold down your COMMAND key and the SPACEBAR
  • A “Spotlight Search” bar will pop up
  • Type: terminal
  • Click on the terminal black box icon

Screen Shot 2016-04-13 at 5.50.51 PM.png

BASIC COMMANDS

How to create a new project folder/directory

I am going to make a new directory folder called super_project

mkdir directory_Name

$ mkdir super_project

Navigate into the super_project directory I would change directory super_project

cd <directory>

$ cd super_project

I want to create a new file called index.html

touch <filename>

$ touch index.html

I want to see what a list of my files in the super_project directory.

$ ls

Let’s create another file called README.md

$ touch README.md

In the super_project we now have two files how do we list all of the files? This will display all files including any hidden files

$ ls -a

Screen Shot 2016-04-13 at 3.46.33 PM

If you lose track of where you are in your directories you can always

print working directory

$ pwd

I am still in the super_project directory but I want to make a new directory named sub_project and copy the README.md file into the  sub_project directory

mkdir <directory>

$ mkdir sub_project

I want to make sure my sub_project directory was created what command entry would I use to list all my files and directories?

$ ls-a

Now let’s copy the README.md file over to the sub_project directory

cp <filename> <to_new_directory>

$ cp README.md sub_project

How about moving a file from one location to another directory? Go ahead and move your index.html file to the sub_project.

 mv <filename><to_new_directory>

$ mv index.html sub_project

I changed my mind and no longer want the sub_project directory. I am going to remove it but since it has the index.html file inside I have to really force it trash.

rm -rf <directory>

$ rm -rf sub_project

If you want to remove a file or an empty directory you can just use the remove command

rm <filename>

$ rm README.md

*Saying the commands out loud will help you memorize and get better.

Now, go and be the master of your computer universe.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s