Skip to content

This guide and website are in beta! Help us make them awesome with your feedback!

Terminal: Commands

This quick guide focuses on the basic knowledge you need to run (and stop) commands and programs in your terminal.

At the end of this guide, you’ll know:

  1. what commands and programs are
  2. how to run commands or programs using a terminal
  3. how to stop commands or programs running in a terminal

After this guide, you can move on to our Terminal Navigation article. This will provide you with a deeper understanding of the relationship between your terminal and the file explorer you’re used to.

Commands are instructions you give to your terminal, asking it to take an action on your behalf. These can range from simple actions like printing your current directory (pwd) to more complex ones like listing all processes running on your machine (ps).

A program is a series of instructions written by a programmer that accomplish a specific task. You’re likely already familiar with programs run via a Graphical User Interface (GUI), usually by double-clicking or tapping an icon. Similar programs can also run on a terminal, with one big difference: rather than clicking on an icon, you launch the program by typing in the terminal itself.

Since working with a terminal is entirely text based, using commands or a program is incredibly simple:

  1. Type the command you want to run into the main terminal window.
  2. Hit the Enter key to begin the execution!
Terminal window
pwd
/Users/username/my-directory/

When you type the pwd command (present working directory) in your terminal and press enter, it will print the current directory your terminal has open.

While every operating system comes with some built-in commands (like those used for navigating in the terminal), some programs also install their own terminal-based commands, enabling access to their functionality through a Command-Line Interface (CLI). Git is an example of such a program.

Terminal window
git status
On branch main
nothing to commit, working tree clean

After Git is installed, you can access its functionality via its Command-Line Interface (CLI).

Some commands may execute entirely within the terminal window, while others may launch visual software on your computer. As you learn to read software documentation, you’ll be able to easily learn how and when to run commands. In the meantime, the internet is your friend!

One of the biggest concerns people have when beginning to use a terminal is this: what do I do if I use the wrong command, change my mind, or just don’t know if what I did was right?

Rest assured: mistyped or incorrect commands are a regular occurrence! In fact, many CLIs have been programmed with helpful hints that show up as the output when the command you input is a common typo. In some cases, the output might let you know your command won’t work unless you install an additional program, or it might throw an error that tells you more details on why it can’t do what you’re asking. That’s a pretty big clue you typed something wrong!

Terminal window
git stEtus
git: 'stEtus' is not a git command. See 'git --help'.
The most similar command is
status

As they say, "have no fear of commands-typing perfection, you'll never reach it".

If you don’t get a pre-written output prompt or error message, generally nothing bad will happen if you type a command the terminal doesn’t understand. Things are unlikely to go wrong in a permanent way, especially when using the basic commands you’re learning in these guides. If you do run the wrong program, you can also use the suggestion in the next section to stop it.

If the command you ran—intentionally or unintentionally!—starts a long-running program or otherwise begins doing things you don’t want, you may want to “kill it” and stop it from running. Luckily, there is one simple, straightforward way to stop most terminal programs: closing the terminal window the program is running in.

Sometimes, however, you may want to use a less nuclear option. In this case, the way to exit the program will depend on the program itself. Below are the most common scenarios we found people getting stuck in.

A long-running program takes full control of your terminal window. While it may still allow you to type in commands, these commands will control the program itself rather than the terminal.

A screenshot of a terminal window's output. The output is a long list of filenames next to time stamps filling up the window. The part of a terminal where you could normally input commands is not visible.

A long-running program that was used to develop this very website. It automatically updates the site’s preview upon saving, but won’t allow you to run other commands within its window.

If the program allows you to type, you can try typing commands like exit or quit (or sometimes \q, :q, and more) to tell the program to stop. However, not all programs accept commands while running.

The most common way to exit long-running programs is to use (and sometimes spam) Ctrl + C. If the command is received correctly, your terminal should output the ^C characters.

Some programs may need time to quit “gracefully” after pressing this key combination, just like some GUI programs might take time to close after pressing the exit button. However, if it seems as if a program is ignoring your termination request (or you’re in a hurry), holding down Ctrl while smashing the C key repeatedly will usually force a shutdown.

A screenshot of a terminal window filled with outputs. Two parts are underlined in red. The first underlined part says Gracefully stoppping...press Ctrl+c again to force. Two lines end with the word stopping, followed by the second underlined part, which says Error 0012 got 3 SIGTERM/SIGINTS, forcing shutdown. The things that previously said they were stopping now say they are stopped. The final output line says the word canceled.

The first press of CTRL + C (indicated by ^C) will gracefully stop the program, allowing it time to take care of any pending task. The second press forces an immediate shutdown.

With time, you’ll learn which programs need a little bit of encouragement to exit.

A pager is a terminal program that displays output that’s too large for the terminal to display all at once. It allows you to scroll up and down (and sometimes left to right).

Some commands (like git log) automatically use a pager to display their output. You can also display the content of a text file in a pager by using the more [file-path] command.

Terminal window
git log --oneline
c1f2e4e (HEAD -> main) *Git’s voice* hey, give that back
9717e55 HTML: CSS version
f0821c4 give HTML a maid dress
:▋

A pager, like the one opened by the git log command, allows you to scroll through the pages of a long output. It displays a colon (:) or (END) at the end of the ouput.

If you no longer see your command prompt, nothing appears to be running, and using the arrow keys scrolls through the output, you have found yourself in a pager. When you’re in a pager, many terminals will put a colon (:) before the cursor, or (END) if the output is short.

The most common way to exit a terminal’s pager is by pressing q or typing :q.

Sometimes, terminal commands (like git commit) may open a terminal-based text editor to help you type long information. As an unfortunate default, this terminal-based text editor is often Vim. While vim is a very powerful editor, its interface is so unintuitive that “being unable to exit vim” is a long-standing, popular meme in the programming community.

A terminal window full of text. The text appears to be the source code for a FujoWebDev article called Terminal: Usage Basics.

One of our articles, opened via the vim [file-path] command. Note the white square at the top (your cursor) and the file path, lines, and size at the bottom.

If you find yourself stuck in what appears to be a text editor, you can exit it with the following commands:

  • Press the ESC key and type :x to save the file and exit.
  • Press the ESC key and type :q! to exit without saving.

Now that you have the basic tools in hand, you can start using your terminal more regularly. Good luck, and remember: these guides will be here for you any time you need them!

As we mentioned before, closing the terminal window should stop even the most stubborn of programs. Should this fail, however, there’s one last tool under your belt: the aptly named kill command, often paired with ps to help you find the process id you need to terminate your “victim”.

While we won’t cover the intricacies of the kill command in this guide, we hope this will give you a pointer on what to search for should you find yourself in this situation.

If despite all these steps you still can’t figure out how to stop a program, always remember the golden rule of technical problem-solving: have you tried turning your computer off and on again?


As you know, learning just a few basics about the terminal will have a drastic impact on your coding journey. Once you’ve become comfortable with it, we recommend you learn another skill with similar outsized impact: Git.

Sign up below to get notified when our Git zine will be available for purchase! In the meantime, if you want to get started on your own, you can check out our basic Git Resources for information on how to install and how to set up this powerful programming tool.