Command line basics

using a "hacker-looking" interface to access the file system

·

2 min read

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

On Windows, it may look something like: C:\projects\>:

  • C:\ refers to the hard drive

  • projects 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 argument myfolder

    • which takes us to the folder called myfolder

The commands

These commands come in handy on an everyday basis:

CommandArgumentsWhat it does
catfilenameprints the contents of a file (may not appear readable depending on the type of file)
cdfoldernameaccesses 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
mkdirfoldernamecreates a directory/folder
mvoldname newnamerenames ("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
rmdirfoldernameremoves the directory/folder (if it exists)
rmfilenameremoves the file (if it exists)
sudo(+ any command)"super user do" (run commands with admin-level permissions if you have certain credentials granted)
touchfilenamecreates a new blank file