A short explanation of what terminal is and some important commands
Terminals, also known as command lines or consoles, allow us to accomplish and automate tasks on a computer without the use of a graphical user interface (source: IT Connect)
If you are on Mac or Linux computers, you should have terminal already installed. On windows computers, the command line uses slightly different syntax so getting set up will require a few extra steps.
This article explains how to get terminal set up on windows
Note this will involve installing Visual Studio Code as well as Git/Git Bash (which you may already have installed if you use Git or GitHub)
In order to illustrate how terminal works, let's walk through a very simple example scenario
- Make a folder on the Desktop titled
My Folder
- Make a folder inside
My Folder
calledContents
- Make a file in
My Folder/Contents
calledfoo.txt
- Make another file in
My Folder/Contents
calledbar.txt
- Go back to
My Folder
and clone in one of our projects from our GitHub - Check that
My Folder
contains two subfolders:Contents
and the project we just cloned
Note I am going to describe the process using Mac OS, however it will look almost identical on Windows or Linux machines.
- Open Finder application and navigate to
Desktop
- Right click and select New Folder, title it My Folder
- Go to My Folder, right click and select New Folder, title it Contents
- Open textEdit application and make new file called
foo.txt
, write nothing and save to Contents - In textEdit application, make another new file called
bar.txt
, write nothing and save to Contents - Open GitHub Desktop and go through the steps described here
- Reopen Finder and double check the contents of my-folder for
Contents
and the project we just cloned
The steps above involve 3 separate applications, lots of navigating between applications and a lot of extra steps
- Open terminal application
- run
$ cd Desktop
- run
$ mkdir my-folder
- run
$ cd my-folder
- run
$ mkdir Contents
- run
$ touch foo.txt
- run
$ touch bar.txt
- run
$ cd ..
- run
$ git pull <PROJECT-URL>
(where project URL is the actual URL for the project) - run
ls
(to list folder contents)
That may seem like more steps, but consider what would take more time, doing all the subtasks in the non-terminal section or simply typing the commands in the terminal section?
For more info on the
git
command and using terminal for Git/GitHub, see here
An important thing to realize about terminal is that you are always somewhere -- ie. in some folder on a computer. When you first launch, this will be the HOME folder. As you navigate through, this will change.
Running ls
will list the contents of the current folder (subfolders and files)
cd
stands for change directory
You can use it to enter a immediate subdirectory from the current directory
$ cd my-subfolder
Or you can provide a whole filepath to go to any directory
$ cd "Desktop/My Folder/Contents"
You can also cd
out of a given directory to a parent directory
$ cd ..
(see how this was used in the example above)
mkdir
will create a folder:
$ mkdir my-new-folder-name
touch
will create a new file
$ touch my-new-file.txt
$ touch my-new-python-file.python