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).
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
How to create a new project folder/directory
I am going to make a new directory folder called super_project
$ mkdir super_project
Navigate into the super_project directory I would change directory super_project
$ cd super_project
I want to create a new file called index.html
$ touch index.html
I want to see what a list of my files in the super_project directory.
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
If you lose track of where you are in your directories you can always
print working directory
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 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?
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 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 README.md
*Saying the commands out loud will help you memorize and get better.
Now, go and be the master of your computer universe.