Introduction to Terminal
Before the wonderful interfaces offered by Windows and Macintosh users interacted with their computers through the terminal window. Shell, command prompt and terminal window are all terms that refer to a program your computer runs. It accepts input from you and outputs it in text. Terminal windows are the simplest way to access and modify files on your computer. Although GUIs (guided user interfacings) are more intuitive and prettier than the terminal, a terminal window is often the fastest way to do something. We will be introducing you to Git terminal in this post. We will use it in future blog posts.
Background and basic set up!
Bell Labs developed the first terminal program. It was designed for Unix. The Unix operating system was the predecessor to the Linux operating system and, believe it or not, the basis of the Mac OS genealogy. This is important because it means that navigating a Mac terminal is almost identical to navigating a Unix/Linux Terminal. Windows operating systems do not use Unix. A Mac/Linux terminal cannot accept the same commands as a Windows terminal. However, there are some similarities. We will show you how to use Git on both Mac and Windows, despite the differences.
Git is preinstalled for Macs. All you need to do is open your terminal, and follow the instructions! You can download the Git package from the Git homepage. This will be saved to your computer as a program called Git bash. You don’t need to download the source code. Just download Git for Windows. We recommend that you use the default settings for Git to prevent Git from integrating too much into your Windows operating system.
Navigation via the Terminal
Navigation is the first thing you need to know about the terminal. You are in a folder when you open a terminal window (the old term for a file is a directory). The command that returns the current folder location is:
pwd //this stands to mean ‘print working directory’
This command should return a file path. This path is your current location. Simply enter the following information into your terminal to navigate back to the directory.
//This changes your directory one level higher
Now, use pwd to find where you are located. Simply type:
//this stands for “list screen”
You can now view all the files and folders you want to edit/examine. You can navigate to a folder you saw by typing ls.
cd *foldername* //this navigates to the specified folder
These three commands will allow you to navigate in and around all file systems on your computer. To navigate up and down directories, use ‘cd’ and ‘pwd to see your current location. ‘ls’ will show all contents in your current location. This is how we navigated computers before there were pretty icons and displays.
Create folders and files!
It is easy to use the terminal to create new folders or files. Follow the instructions to create a folder via the terminal. Then, add a few files to it! Navigate to your desktop in your terminal and type:
//mkdir terminal_stuff
You can use the mkdir command to create a new folder with the same title and name as what you typed afterward. You should now be able to see your desktop. Pretty sweet, huh? Let’s now move some files to your new folder. Navigate to terminal_stuff, and type:
Touch index.html
The touch command can be used in many different ways. Your computer will create a file if there isn’t one by the exact name you entered after you type the command. If there is a file with the exact name, the computer will create it. This is useful for keeping track of changes.
Renaming and moving files and folders
In the world of UNIX-based terminals, you can name items and move them around. The command is:
mv *target* *destination* //This command accepts two inputs
The file or folder that you want to rename or relocate is called the target input. The destination input is the path or folder you wish to move the target into. If the destination input does not contain the name of a folder the computer will assume that you want to rename it. Let’s see how it works! Type the following in your terminal from the DESKTOP directory:
mv terminal_stuff TERMINAL_STUFF
Now, type ls to see the folder terminal_stuff renamed to appropria
0