Development General Technology Tutorials

The Most Basic Command-Line Commands

The most basic terminal commands to get you started on the command-line.

For those new to the terminal/command-line/command-prompt, here is a list of common commands to get you looking like a pro in no time.

What is the Terminal?

The terminal, otherwise known as the command-line, command-prompt, shell, or simply as the console, is a text-based interface for interacting with a computer via the Operating System. You can do most things in a terminal that you can do via the normal, graphical user interface that you interact with every day:

  • Navigate the folders and files on your system
  • Create/Delete/Modify files
  • Install/Remove/Run applications
  • Access information over the internet

At a basic level

Everything on your computer lives in a directory. A directory is another word for folder. Your desktop is a directory, and so is your Documents folder, your Music folder, your Pictures folder, and so on. Every application and file lives in a folder somewhere. Thus, the most important and basic commands (in my opinion) are the commands used to traverse your directories.

A few of notes:

  • The working directory refers to the directory/folder that you are currently in.
  • . represents the directory that you are currently in.
  • .. represents the parent directory of the directory that you are currently in.

Opening the Terminal

  • Opening the terminal on Windows:
    1. Open the Start Menu.
    2. Search for “cmd”.
    3. Open the “Command Prompt” app.
  • Opening the terminal on Mac:
  • Opening the terminal on Linux: Ctrl+Alt+t

Generally, when opening the terminal, you land in the HOME directory. The HOME directory is the main (top-level) directory for the current user of the system.

Basic Commands

A list of basic, cross platform (Windows, MacOS, Linux) terminal commands.


pwd stands for “print working directory.” This command is used to print out the path of the directory (folder) that you are currently in within the terminal. This command does not work in the Windows Command Prompt (see dir).


The ls or list command is used to list the files and folders (sub-directories) of the directory that you are in. This command is for Linux and MacOS systems (there is a different command for the Windows Command Prompt, dir).

If you run ls by itself, you will see a list of the files/folders within the current working directory (the folder that you are currently inside of) in the terminal.

You can list the files/folders of a particular directory by running ls <.../path/to/directory> where <…/path/to/directory> is the path to the directory that you want to look into. For instance, you might run ls ~/myFolder/ to see what is inside the myFolder folder located within your HOME directory (~).

Use ls -a to list all files/folders in the current (or specified) directory. Not all files show up by default, some are hidden (usually those that start with a “.”).


The dir command is used specifically in the Windows Command Prompt to list files and folders within a given directory. The dir command also prints out the path of the current working directory (the folder that you are currently inside of within the terminal).

dir shows all files/folders by default.


The cd command is short for “change directory.” It is used to….. wait for it…. change the working directory. In layman’s terms, it means to move from your current folder into another folder that you specify. Following are a few examples of cd.

cd .

The “.” symbol represents the directory that you are currently in. Running cd . effectively does nothing. You are telling the terminal to move into the directory that you are currently already inside of.

cd ..

Two “.” symbols in succession, “..”, represents the parent directory – the directory that contains the directory that you are in. Running cd .. tells the system to move up to the parent folder.

For example, take a look at the folder structure below. The root folder is the top-level directory. Inside of root, you have bin, modules, public, routes, views, app.js, package.json, package-lock.json, and

    |-- bin/
    |-- modules/
    |   |
    |   |-- module1/
    |       |
    |       |-- index.js
    |       |-- package.json
    |       |--
    |       |-- LICENSE
    |-- public/
    |-- routes/
    |-- views/
    |-- app.js
    |-- package.json
    |-- package-lock.json

Let’s say you had your terminal open, and you were currently inside of the module1 folder. If you ran the cd .. command, you now be in the modules folder. Running cd .. again would land you in the root folder.

cd folder1

Running cd folder1 would move you into the folder named folder1 if there was a folder with the name of folder1 in your current working directory.

cd folder1/folder2

Assuming that folder1 exists in your current working directory, and assuming that folder2 exists as an immediate child folder of folder1, this command, cd folder1/folder2 would move you into folder2.


mkdir is short for “make directory.” When running this command, you specify the name of a directory that you want to create. This command creates the directory (folder) as you specify.

  • mkdir myNewFolder creates a new folder called myNewFolder in your current working directory.
  • mkdir folderA/folderB would create a new folder called folderB inside of folderA. If folderA already exists, then it would create folderB inside of the existing folderA, otherwise, a new folderA would be created. (Flip the slash to “\” if you are running this in the Windows Command Prompt).


The echo command is used to print text to the terminal. Running echo test 123, for example, would print “test 123” to the terminal (try it!).

This command is useful within scripts when it is desirable to print output to the console.


Finally exit. This command is used to close the console. Of course, you can always close the console by clicking on the close button, but it looks cooler to close it with exit. Also, the exit command comes in handy when you want to automatically close the terminal upon completion of a script.


I will add some more basic commands to this list as I think of them, but my intent here is to provide a simple, basic/starter list of cross-platform commands. From here, anyone should be able to get going!

If you think there is a command that should be included, feel free to comment below!

Thanks for reading!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.