This is a guest post by Daniel Seymour, one of the Codecademy moderators, with editing help from Alex Craig and Dustin Goodman.

"I see a blinking cursor. WHAT DO I DO?!"

When you hear the word "command line", "terminal," or "little window that tells a computer what to do but only has a flashing cursor in it," what comes to mind? Do you scream and hide under your bed? Or do you look at me inquisitively and wonder why I would bring such a scary thing up?

Terminal

I hate to tell you this, but you MUST conquer your fear of the terminal (if you have a fear) and learn how to use that annoying little window with a flashing line in it. A *nix (Unix (like Mac), Linux) system is an operating system that can enable you to do some rather amazing stuff quite quickly, if you know what you are doing in the terminal. Before I start throwing terms at you I need to define a few.

Basic Terms

OS: Operating System, the program that tells the different pieces of hardware how to work together to make a comprehensive system. GUI: Graphical User Interface, essentially the little window that has buttons you can click that often hides the power of the terminal. Terminal: Part of the computer that allows you to issue commands to the computer and directly interface with the OS. Executable: Executable file, file used to execute a program on your computer.

Now that you have a rudimentary computer vocabulary, you can start conquering your fear. I use the terminal all the time and am able to do basic things faster, such as pushing to Github, connecting to a network, etc. I currently use a command-line-based Linux distribution. On the rare occasion that I have to use Windows, most of the basic jobs of the computer, such as connecting to a wifi network, take so long that I feel like I am waiting for a marathon to end.

Step 1: Find your Terminal

So how should you start conquering your fear? I would suggest finding the terminal on your system. For this first part, I am going to assume that you are using a Linux distribution such as Ubuntu, Linux Mint, Fedora, OpenSUSE, or Debian (to name a few). On any regular GUI-based Linux system, go to the applications menu and search for terminal. When you find it, open it and stare at that blinking cursor for a few seconds while saying, “I will learn to use this thing.” :) (You can skip the staring if you want.)

Step 2: Start an Application

The most basic operation that a user can do from the terminal is start an application. On almost every Linux system, simply using the name of the executable in the /usr/bin directory will start the application. For example, starting the Firefox web browser simply requires typing “firefox” into the command line and pressing enter. You should now see a session of Firefox launch on your desktop. Congratulations! You just executed your first command from the terminal!

Note: Launching an application from the terminal will lock that terminal instance so that you cannot do anything else with it. If you want to be able to use the terminal for other activities, trailing the application executable name with a “&” will put the process in the background of the terminal and you will be able to use the terminal for other things.

Step 3: Get Specific

Launching an application is not all that the terminal can do. You can launch applications and tell the application to edit such and such file (in the case of a text editor, such as Nano, Vim, or Emacs. Nano is the default terminal text editor for most Linux distributions) or you can tell a web browser to launch such and such a web page. For example, the command:

firefox www.codecademy.com

will launch a session of firefox and open the session on the Codecademy home page.

Step 4: Entering Commands

Now that you know how to launch an application, you will also need to know how to traverse the file system straight from the terminal as doing so is a big part of many operations that are done in the terminal.

To start off, enter the command pwd. You should now see something along the lines of

/home/{username}/

The above command stands for Print Working Directory so the directory that you see posted to the terminal is the directory that the terminal is currently in. Now enter the command “ls”. You should now see something along the lines of:

Desktop/    Documents/    Downloads/    Music/    Pictures/    Videos/

And all of the other folders that your home directory contains. The ls command can be thought of as standing for LiSt the contents of the present folder.

A Brief Note on Flags

Before we go any further, you will need to know about flags. Flags are options that are passed to a command that extend the command to accomplish another task at the same time.

Now type the command ls -a (-a meaning all). You should see everything that you saw using the ls command but also you should see a bunch of folders and files that begin with a .. These extra files/folders are “hidden” so as not to clutter up your home directory with files that you may only open once in the life of the computer (if that). As you may have guessed, the difference between a hidden and not hidden file is the beginning dot. The dot tells Linux to hide the folder/file.

Step 5: Change Directories

One last command that you must know to be able to start using the terminal effectively is the cd command. If you type cd by itself, you most likely will go back to your home directory or nothing will happen. This is because the cd command stands for Change Directory.

Because you didn’t pass cd an argument, the terminal has no clue what folder it should enter. The most important cd arguments that you will need to know are {childFolderName}, .., . and ~.

  • {childFolderName} argument tells the terminal to enter the folder in the current directory by the name of {childFolderName}
  • .. tells the terminal to go to the parent folder of the current directory
  • . when used in conjunction with /{folderName} tells the terminal to enter the child folder of the current directory by the name of {folderName}
  • ~ tells the terminal to go back to the home directory (/home/{username}).

Other Useful Commands

Here is a list of other commands that you will probably find useful:

  • mkdir “Makes” a directory in the file system at the specified file path.
  • rm Deletes (“removes”) the file at the specified file path.
  • rmdir Deletes the directory at the specified path.
  • man Opens the MANual pages for the specified command or application. For example, man ls will open the man page that contains all of the information and flag options for the “list” command. This is especially useful to see if a program offers any extra functionality or to figure out how to configure a program.

That's it! Now you're ready to get started in your terminal.

The official blog of Codecademy

The easiest way to learn to code

Stay up to date

Never miss a new feature and always know about scheduled maintenance

Subscribe to our feed

Sign in