Different computers use different versions of Terminal. Windows devices tend to use “Command Prompt”, “Windows Console”, or “Windows Terminal”, while computers that run MacOS or Ubuntu are prepackaged with the succinctly titled “Terminal”.
How to Open Terminal
On most devices, this is very simple: Look up “Terminal” in your computer’s search bar (where you ordinarily search for files and applications), and it will come right up if it is installed. If you can’t find it, there are keyboard shortcuts you can use on Windows, or it can be opened from Utilities in MacOS.
The Command Line
If you’ve opened Terminal, great! You’ll know it’s open when you see a smallish window appear on your screen, on which a single line is printed: The name of the current user, an “@” symbol, and the name of the device, followed by the symbols “:~$”. You can type directly onto the line, and anything you type will show up after the “$” symbol. This is where commands to the Terminal go. You can type anything you like, but Terminal is configured to respond and perform actions for a certain set of instructions. Commands are then confirmed by pressing the enter key, after which a new line will appear below the previous one, allowing for a new command. While it may be fun to type random things into Terminal, it’s best not to mess around with it too much. Terminal can perform some very powerful actions that should left untouched if you don’t know how to use them.
Viewing Directories
The first command we are going to learn is pwd. This command prints in the window the current “path”, which we can imagine is the “place” we are in. Using pwd on a newly opened Terminal window shows that we are in “/home/user” (where “user” is replaced with your username), which is where things like our desktop, downloads, and all other files are located. The “place” that we are in is actually a directory, which is a system used to store files in a hierarchical way. A way we can think about directories is as very big folders, like the ones you can create on your desktop. If you would like to see all the things contained in user, type the command ls (the first letter is a lowercase L!). This will list all the files and directories contained within the current directory. You can type ls -l to view all the entries on separate rows, plus some additional information about each entry.
Moving Around, Opening, and Making Directories
Now that we know where we are, we can start moving around. The command for opening directories is cd, followed by the name of the directory you want to move into. For example, let us go to the desktop by using the command cd Desktop. If you want to go back at any time, you can use the command cd .. which brings you back to the directory you just left. If there is a specific sub-directory you want to get to and you know the path to it, you can also type cd followed by the path to go there directly. What if you want to create a new directory? For example, let us say we are now on our desktop and want to create a folder for some pictures. We can use the command mkdir followed by the name for the folder. In this case, I would type in mkdir Pictures, and voila! There is a new folder on my desktop that I can drag my pictures into.
Moving, Copying, and Renaming Files
Now that we know how to use directories, let us take on files. Let us take a look at the command mv, which is multipurpose. First, we can use it to move files around by typing mv followed by the filename (or path), and the new location. For example, let us say that I created another directory in my “Pictures” folder called “Favorites”. I can then moving the file photo.png from the pictures folder into the favorites sub-folder by using the command mv photo.png Favorites. This command can also be used to rename files, such as changing the name of the photo.png file by using the command mv photo.png photo2.png. We can also make a copy of files in a similar way, by using the command cp followed by the filename (or path) and the new copy’s name. For example, I can create a copy of photo.png by typing cp photo.png photocopy.png.
Clearing the Terminal and Opening Applications
Clearing the Terminal to get rid of all the commands that have been processed so far is easy- just type in clear. This will make the Terminal look the same as it originally did when we first opened it. Terminal can do a whole lot more than just moving files around. For example, it can open files and applications. First, navigate using cd to where the file (or application) is located, and then type open followed by the filename. For example, I can open my picture from earlier by using the command open photo.png.
What’s Next?
There’s a ton of different things you can do in Terminal, and this is just the beginning! To find out more, try typing in help, which will bring up a whole list of different commands that are available. You can also apply help to an individual command to learn more about it. For example, you can learn more about the help command by typing in help help. For more commands and other things you can do from Terminal, there are millions of different tutorials out there that discuss specific commands in detail. Go out and discover what you can do in Terminal, and you’ll be a command line expert in no time.