Difficulty: Beginner
Estimated Time: 10 minutes

Welcome to the command line interface. In this brief lesson, you'll create files and directories, read files, navigate around directories, and install software packages. You'll also turn the output of a command into a text file and send output of one program to another.

This lesson is adapted from my book Small Sharp Software Tools, published by the Pragmatic Programmers LLC. All content used by permission. If you like this lesson, pick up your own copy of the book today!

In this lesson, you got a taste of basic command-line usage. You know how to navigate around your home directory, you can create basic text files and directories, and you can install programs with the package manager.

To learn more great command-line tricks, pick up your copy of Small Sharp Software tools today. It has many more lessons just like this one.

Getting Started with the Command Line Interface

Step 1 of 13

You Are Here

When you first open the command line interface, or CLI, you'll be presented with something that looks like this:


This is the prompt, and it's the CLI's way of telling you it's ready for you to type a command.

Depending on your operating system's configuration, your prompt may show more information. This prompt is from the Ubuntu operating system:

[email protected]:~$

When you open the command line interface, you'll be placed in your "home directory".

Your home directory is where you'll find your documents, music, and settings for your programs. You have total control over your home directory. You can create and delete files and directories, move things around, and even install whole programs without administrative privileges. When you launch the CLI, it'll open the session in your home directory.

The computer's disk stores files in a hierarchy of folders, or directories, which we call the file system. When you use the GUI, you click on a folder to open it and see its contents, and an indicator at the top of the GUI window tells you where you are on the file system.

Your prompt may tell you what directory you're currently looking at. But there's a more clear way to tell, and that's with the pwd command, which stands for "print working directory."

At the prompt, type

$ pwd

The command prints the full path to the current directory to the screen: