Photo by Gabriel Heinzer on Unsplash
Command line basics
using a "hacker-looking" interface to access the file system
We can access a computer's file system using the command line:
on Mac, via an application called Terminal
on Windows, via Command Prompt
The prompt
The prompt, which appears when we load the command line app, shows us the current status:
On Mac, it may look something like: jon@Jons-Mac-mini Desktop %
where:
%
is the prompt- this symbol could be
$
or#
depending on the system
- this symbol could be
On Windows, it may look something like: C:\projects\>
:
C:\
refers to the hard driveprojects
refers to a folder on that drive
As shorthand, we will refer to the prompt as simply $
The command
A command consists of a:
keyword
arguments (the values that follow the keyword)
For example:
$ cd myfolder
From that:
the keyword
cd
(change directory) has the argumentmyfolder
- which takes us to the folder called
myfolder
- which takes us to the folder called
The commands
These commands come in handy on an everyday basis:
Command | Arguments | What it does |
cat | filename | prints the contents of a file (may not appear readable depending on the type of file) |
cd | foldername | accesses a folder (if it exists) |
cd | .. (literally) | accesses the parent folder of the current folder |
clear | (none) | clears the command-line screen of its history |
ls | (none) | lists the files and sub-folders of the current folder |
mkdir | foldername | creates a directory/folder |
mv | oldname newname | renames ("moves") a file to a new name |
npm | (many different arguments) | manages the dependencies of a project (more on this later) |
pwd | (no arguments) | prints the path of the current folder |
rmdir | foldername | removes the directory/folder (if it exists) |
rm | filename | removes the file (if it exists) |
sudo | (+ any command) | "super user do" (run commands with admin-level permissions if you have certain credentials granted) |
touch | filename | creates a new blank file |