0.1: Command Line
Learning Objectives
The command line is a text interface for manipulating our computers
Navigate folders and display folder contents in the command line
Create new folders and files in the command line
Rename or delete folders and files in the command line
Introduction
The command line, also known as "terminal" is a text-based computer interface. We will use the command line to manage files, use Git version control and run Node applications. Using the command line is separate from writing application code, though we will need the command line to build apps effectively.
If you are a Windows user, please use the VS Code terminal connected to Ubuntu in WSL. The Windows Command Prompt runs PowerShell by default which is not compatible with Unix-based commands that most software engineers use. See Windows Command Line Setup for details.
Common Commands
Below, we have listed some of the most commonly used terminal commands that software engineers use. To learn more about these commands, google "man" followed by the command name to get the "manual" page for the command (eg. to learn more about "pwd", simply enter "man pwd" into google).
Tab Complete
The command line will autocomplete file and folder names if we press tab
after starting to type their names. This can save us a lot of typing!
Command | Meaning | Sample Usage | Explanation |
---|---|---|---|
| Present working directory |
| Retrieve the "absolute path" of the current folder (directory). Absolute means relative to the root folder of your hard drive. |
| List |
| List the files and folders in the current folder |
| Change directory |
| Move to the specified folder.
If we do not specify a folder, |
| Create folder |
| Create a new folder at the specified path |
| Copy | File: | Copy the contents of the first file to the second, overwriting contents of the second if any.
Use |
| Move | Move: Rename: | Move the 1st argument to the 2nd argument. If the 2nd argument is a folder, move the 1st argument inside the 2nd argument. Otherwise, rename the 1st argument to be the 2nd argument. |
| Remove | File: | Delete a file or folder. This is irreversible and there is no trash folder. Be very careful, and if you delete the root folder |
Common Special Paths
The following paths are shortcuts to common locations and are often used in folder navigation.
Path | Meaning | Sample Usage | Explanation |
---|---|---|---|
| Root, i.e. the highest-level folder on our computers |
| All absolute paths begin with the root folder |
| Home, i.e. the logged-in user's home folder |
|
|
| Parent folder |
| Every folder has a hidden link |
. | Current folder |
|
|
Exercise
Run each of the above commands with local files and folders. Verify file and folder changes in Ubuntu File Manager or MacOS Finder.
Additional Resources
The following is a command line tutorial from a previous version of Rocket's Coding Basics course.
Last updated