https://raw.githubusercontent.com/github/explore/aca0b3b69ca680013b925338b0cc428190aa42dc/topics/cli/cli.png

Shell#

Shell is a program that takes commands from the keyboard and gives them to the operating system to perform.

0. Preliminaries#

0.1. File Structure#

File structure is a way of organizing files and directories in a computer. Most operating systems use a hierarchical file system.

0.2. File Path#

File path is the location of a file or folder in a directory structure. An example of a file is C:\Users\Documents\file.txt.

Note

Note that Unix based systems (e.g. MacOS, Linux etc.) use / whereas Windows uses \ as the path separator.

The file path is made up of the drive name (e.g. C:\), the folders (e.g. Users\), and the file name (e.g. Documents\file.txt).

1. Launch Command Line Interface#

  1. Press Command + Space to open Spotlight Search.

  2. Type terminal and press Enter.

_images/terminal.png
  1. Press Win + R to open the Run dialog box.

  2. Type cmd and press Enter.

_images/commandprompt.png

2. Where Am I?#

pwd command is used to print the current working directory.

cd command, without any parameters, is used to print the current working directory.

3. What’s in Here?#

ls [OPTION]... [FILE]...

ls command is used to list the files and directories in the current working directory.

ls -lt command is used to list the files and directories in the current working directory in long listing format and sorted by time modified.

dir command is used to list the files and directories in the current working directory.

4. Let’s Go!#

The following can be used to jump to locations: cd <location you want to move to> (Change Directory)

Some common shortcuts:

  • ~: Home Directory

  • .: Current Directory

  • ..: Parent Directory

  • /: Root Directory

5. Let’s create a folder#

A folder can be created using mkdir <folder name>