Navigating The File System: List Ls

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

11/12/2020 Learn the Command Line: Navigating the File System Cheatsheet | Codecademy

Cheatsheets / Learn the Command Line

Navigating the File System


List ls

The shell command ls is used to list the contents of


directories. If no arguments are given, it will list the $ ls Desktop
contents of the current working directory. resume.pdf
photo.png

Print Working Directory pwd

The shell command pwd displays the le path from


the root directory to the current working directory. $ pwd
/Users/sonny/Downloads

Make Directory mkdir

The shell command mkdir can be used to make a


new directory in the lesystem according to its $ mkdir new-directory
argument. If a le path is given, the new directory will be $ ls
placed at the end. Otherwise, it will create a new old-directory new-directory
directory in the current working directory with the name
given.

cd Change Directory

The shell command cd can be used to move


throughout the lesystem of a computer. It accepts a $ cd some-directory
variety of arguments: $ cd ..

● Full le paths.

● Names of children of the current directory.


.. the parent of the current directory.

Filesystem Structure
A computer’s lesystem organizes the data stored by a
computer, so that it can be easily retrieved by the user.
Files are typically represented by a tree-like structure, in
which any parent directory can have any number of
children.
The root directory is then found at the base of the tree.

https://www.codecademy.com/learn/learn-the-command-line/modules/learn-the-command-line-navigation/cheatsheet 1/2
11/12/2020 Learn the Command Line: Navigating the File System Cheatsheet | Codecademy
touch Create New File

The shell command touch creates a new le in the


current working directory with the name provided. $ touch secret-file.txt

The Command Line


The command line allows a user to navigate the
lesystem and run built-in programs or custom scripts. $
In Unix, the command line interface is called Bash, and
the shell prompt is the $ .

Helper Commands
Helper commands for the command line include:


clear to clear the terminal


tab to autocomplete the line


↑ and ↓ to cycle through your previous
commands

https://www.codecademy.com/learn/learn-the-command-line/modules/learn-the-command-line-navigation/cheatsheet 2/2

You might also like