Terminal Emulators

The combination of a terminal and a shell is called a terminal emulator.

Native Shells

Each operating system has a default shell:

VS Code Terminal

Visual Studio Code has an integrated terminal. If you've close the terminal you can always get back to it from the top bar by clicking View > Terminal.

You can see what shell you are using on the Terminal tab:

VS Code Terminal

You can change the shell in VS Code using the dropdown arrow next to the plus sign:

VS Code Terminal Change Shell

A side note on navigation is necessary here...

Absolute Paths

Absolute paths start at the root directory. This is the top-most directory in the file system.

Absolute Path Examples:

Relative Paths

Relative paths start at the current directory.

Relative paths start at:

Relative Path Examples:

Shell Commands

We will use bash commands for all examples, because many cloud platforms and virtual environments use Unix-based systems.

You can also use bash commands on Windows after you have installed Git via git bash. This also works in VS Code's integrated terminal.

Some may work in other terminals such as zsh or PowerShell, but this is not guaranteed.

*Don't run commands blindly. Make sure you understand what they do before running them. You can wipe your entire system clean with one short command.

Utility Commands

Clear the Terminal

# clear = Clear the Terminal
clear

Exit the Terminal

# exit = Exit the Terminal
exit

Directory Traversal

# pwd = Print Working Directory
pwd

List the Contents of a Directory

# ls = List
ls                      # List the current directory
ls -l                   # List the current directory in long format
ls -a                   # List the current directory, including hidden files
ls /home/john/Documents # List the contents of a specific directory

Change Directory

. is the current directory. .. is the parent directory relative to the current directory.

# cd = Change Directory
cd ..
cd ../images
cd /home/john/Documents

File Manipulation

Create a New Folder

Will be created in the current directory in this case.

# mkdir = Make Directory
mkdir test

Remove a Directory

*Be sure to back up any files prior to removing them! It's better to be safe than sorry. You can always delete them later.

If it's empty:

# rmdir = Remove Directory
# Must be empty
rmdir test

If it's not empty:

# rm -r = Remove Directory Recursively (Along with All Folders and Files Inside It
# You've been warned...
rm -r test

Create a New File

Will be created in the current directory in this case. Can also be used to set a file's "last modified" timestamp.

touch test.txt

Copy a File

First argument is the source file, second argument is the destination file. Will overwrite if the destination file already exists.

# cp = Copy
cp test.txt test2.txt

Move a File

First argument is the source file, second argument is the destination file.

# mv = Move
mv test.txt ../test.txt

Rename a File

First argument is the old name, second argument is the new name. Will overwrite if the destination file already exists.

# mv = Move (but also used for renaming files)
mv test.txt test2.txt

Delete a File

# rm = Remove
rm test.txt

What Should I Be Able to Do?