A terminal is a program that allows you to interact with the operating system.
A shell is a program that interprets commands.
The combination of a terminal and a shell is called a terminal emulator.
Each operating system has a default shell:
bash (Bourne Again SHell, but just call it bash): Unix-based systems (Linux and Mac)
zsh (Z SHell): Mac
PowerShell: Windows
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:
You can change the shell in VS Code using the dropdown arrow next to the plus sign:
A side note on navigation is necessary here...
Absolute paths start at the root directory. This is the top-most directory in the file system.
C:\
/
Absolute Path Examples:
C:\Users\John\Documents\test.txt
/home/john/Documents/test.txt
Relative paths start at the current directory.
Relative paths start at:
Relative Path Examples:
Documents\test.txt
SomeFolder/OtherFolder/test.txt
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.
# clear = Clear the Terminal
clear
# exit = Exit the Terminal
exit
# pwd = Print Working Directory
pwd
# 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
.
is the current directory. ..
is the parent
directory relative to the current directory.
# cd = Change Directory
cd ..
cd ../images
cd /home/john/Documents
Will be created in the current directory in this case.
# mkdir = Make Directory
mkdir test
*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
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
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
First argument is the source file, second argument is the destination file.
# mv = Move
mv test.txt ../test.txt
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
# rm = Remove
rm test.txt