Accessing the Command Line

Terminal is the application for MacOS to interact with the computer using a command line.

Window's alternative to terminal is Command Prompt or if you installed Git then GitBash.

The Visual Studio Code application also comes with a built-in terminal which can be accessed from Terminal option or by pressing control shift ` back-tick

Common Commands

We will not go into too much detail but will only look at some basic commands that will help us to use the command line effectively.

To run each command we hit the enter key.

Where we are

pwd print working directory, to know the path of the directory where we are on our computer

What is in this folder

ls list all the files and folders inside the current folder we are in

What is in a specific folder

ls folder-name list the contents of a specific folder. Note in this command we have supplied a second value separated by space after the command

Move inside a folder

cd folder-name change directory to the specified folder(directory) name

TIP

We can use the tab key to autocomplete the folder names in command line.

Move out of the current folder

cd ../ change directory and move one level out similarly we can write cd ../../ to move two levels out and so on

The Path

We can use file and folder paths with the cd command to move from one folder to another

 - week-1/
    - index.html
    - images/
        - birds/
            - birds.jpg

In the above directory structure if we are in thee week-1 folder and we want to move inside the birds folder we can write the command as:

cd images/birds

and to move out of birds folder to the week-1 folder we can write the command:

cd ../../

NOTE

There is much more to the command line but these basic commands will help you navigate to the proper folders and run other commands as required.