Command Line Reference

Command Line Reference

While getting to know the different ways to interact with your command-line environment, Ubuntu on Windows and Terminal on macOS, it's handy to have a reference lying about. This can be that reference!

You can also download this one-page PDF if you're the type of person that likes to have it available that way, too.

Summary of basic commands

The following table lists the commands to perform for different types of actions on files and directories in the Terminal/Ubuntu

Action

Files

Directories

Copy

cp

cp -r

Create

code

mkdir

Delete

rm

rmdir, rm -r

Inspect

ls

ls

Move

mv

mv

Navigate to

cd

View content

cat

ls

Glossary of terms

Here's a table of terms that you will want to remember not only as you work through this prep work but also during the remainder of your programming career.

Term

Definition

absolute path

A path that refers to a particular location in a file system. Absolute paths are usually written with respect to the file system’s root directory, and begin with either “/” (on Unix) or “\” (on Microsoft Windows). An example of an absolute path is /home/webdevhub/Downloads which would be the path for the directory that contains downloads for the "webdevhub" account.

command-line interface

A user interface based on typing commands that interacts with files and the operating system. On Windows, you will use the Ubuntu environment for that. On macOS, you will use Terminal.

current working directory

The directory that relative paths are calculated from; equivalently, the place where files referenced by name only are searched for. The current working directory is usually referred to using the shorthand notation "." (pronounced “dot”).

file system

A set of files and directories. A file system may be spread across many physical devices, or many file systems may be stored on a single physical device; the operating system manages access.

filename extension

The portion of a file’s name that comes after the final “.” character. By convention this identifies the file’s type: .txt means “text" file, .png means “Portable Network Graphics" file, and so on. These conventions are not enforced by most operating systems: it is perfectly possible (but confusing!) to name an MP3 sound file "homepage.html" which makes it look like an HTML file for showing content in a Web browser!

home directory

The default directory associated with an account on a computer system. By convention for your account, all of your files are stored in or below your home directory. On macOS, that is found in the /Users/«your-name»k directory. On Ubuntu, you can find your home directory under /home/«your-name». On Windows, you will find it under C:\Users\«your-name». On Ubuntu and macOS, the shortcut for your home directory is "~".

operating system

Software that manages interactions between users, hardware, and software processes. Common examples are Linux, macOS, and Windows.

parent directory

The directory that “contains” the one in question. Every directory in a file system except the root directory has a parent. A directory’s parent is usually referred to using the shorthand notation ".." (pronounced “dot dot”).

path

A unique description that specifies the location of a file or directory within a file system. There are two kinds of paths: absolute paths and relative paths.

relative path

A path that specifies the location of a file or directory with respect to the current working directory. Any path that does not begin with a path separator character, "/" on Ubuntu and macOS, is a relative path. The path "Documents/Contracts/" is a relative path from the current working directory into a "Contracts" subdirectory under a "Documents" subdirectory. You know that "Contracts" is a subdirectory because there's another path separator ("/") after it.

root directory

The top-most directory in a file system. On macOS and Ubuntu, its name is "/".

shell

A command-line interface such as Bash or Z shell that allows you to interact with the operating system.

subdirectory

A directory contained within another directory. All directories except the root directory are subdirectories.

wildcard

A character used to specify a pattern to match. In Bash or Z shell, the wildcard character "*" matches zero or more characters. This means that "*.txt" would match any name that ends with ".txt".

Regarding file extensions: since many applications use filename extensions to identify the MIME type of the file, misnaming files may cause those applications to fail. If you copy a picture from your phone to your computer and rename it "recipes.docx", then your word processor program will probably try to open it and complain that the file is unrecognizable or corrupt. You know that it's just an image, though, because you're smarter than the computer.

Last updated