Filepath

A filepath represents the location of a file or folder within a file system.

Generally you will be using filepaths when using Bash or a terminal in order to change your working/current directory or copy a file or whatever.

There are also other uses for filepaths. But I won't get into that stuff right now.

Important: Filepaths are case-sensitive. For example, "readme.txt" is not the same as "ReadMe.txt".

Root directory

The root directory is the uppermost directory of any given computer disk. In other words, its a directory without a parent.

For example, when using a Mac, doubling clicking on the Macintosh HD icon will open the root directory for your main hard disk. And within that directory are all the top-level files and directories on your drive (e.g. Applications, Users, etc.).

Note: Like many Linux commands, the instructs provided in this tutorial can be used for the macOS Terminal.

A single forward slash (/) without any other characters, reprsents the root directory.

When using Bash or a terminal you can access your root directory by simply tying "cd /" regardless of your current/working directory.

Example

cd /

Parent directory

Access the parent directory of your current directory using "..".

Example

cd ..

Relative filepath

A relative filepath is based on the current/working directory.

If your current directory contains a folder called "books" and you want to navigate to that directory. The relative filepath would a dot and a forward slash "./" followed by the name of the directory you want to access.

Example #1

cd ./books

Alternatively, you could simply write the name of the directory. However, this may not be supported on all computers/servers.

Example #2

cd books

Directory names with spaces

Directories often have names with spaces (e.g. "My Documents").

A filepath with blank spaces needs to be wrapped in quotation marks.

Example

cd "My Documents"

Slashes

Mac and Linux use forward slashes ("/") for filepaths, but Windows uses backslashes ("").