← Operating Systems from Zero: Linux, Windows and macOS

Video coming soon

The written lesson below is ready now. The video is being published on our YouTube channel.

Follow ChangeCV on YouTube →

Lesson 1 of 6

Find your way around the file system: pwd, ls, cd, mkdir and touch

Learn how the file system is laid out with a filing-cabinet analogy, then use five commands to see where you are, list files, move between folders and create folders and files, on Linux, macOS and Windows.

The idea in plain words

Think of a filing cabinet. The cabinet itself is the root of the file system, written / on Linux and macOS and C:\ on Windows. A drawer is a folder, a document is a file, and the label on the drawer is the path, the address of a file. Your own desk is your home folder.

Two differences to remember. Windows uses backslashes and drive letters, and on Linux uppercase and lowercase letters count, so Notes and notes are two different names.

Commands in this lesson

pwd
Print the folder you are in. It works in PowerShell too, where the full name is Get-Location.
ls
List what is in the current folder. Add -l for sizes and dates. In PowerShell the full name is Get-ChildItem, and dir works too.
cd projects
Move into a folder. cd .. goes one level up. In PowerShell the full name is Set-Location.
mkdir notes
Create a folder. It works the same on all three systems. The long PowerShell form is New-Item -ItemType Directory.
touch notes/todo.txt
Create an empty file. Windows has no touch: use New-Item -ItemType File in PowerShell.

Written notes from the video

Why the file system matters

Every file on your computer lives somewhere. How do you find your way around without clicking through folders? This is Operating Systems from zero, episode one: finding your way around the file system. Five commands, shown on Linux, macOS and Windows.

The filing cabinet analogy

Think of a filing cabinet. The cabinet itself is the root of the file system. It is / on Linux and macOS, and C:\ on Windows. A drawer is a folder, and a document is a file. The label on the drawer is the path. It is the address of a file. Your own desk is your home folder: /home/ava, /Users/ava, or C:\Users\ava. Two differences to remember. Windows uses backslashes and drive letters. And on Linux, uppercase and lowercase letters count, so Notes and notes are two different names.

Command 1: pwd

Command one: pwd, short for print working directory. It tells you which folder you are in right now. On Linux, a home folder looks like /home/ava. On macOS, it is /Users/ava. In Windows PowerShell, pwd works too. It is a short name for Get-Location.

Command 2: ls

Command two: ls, short for list. It shows what is inside the current folder. Add -l to see sizes, owners and dates. In PowerShell, ls works as well. The full name is Get-ChildItem, and dir is another short name for it.

Command 3: cd

Command three: cd, short for change directory. cd projects moves you into the projects folder. Look at the prompt. It now shows tilde slash projects, so you always know where you are. cd .. goes one level up. On Linux and macOS, a plain cd takes you home.

Command 4: mkdir

Command four: mkdir, short for make directory. mkdir notes creates a new folder called notes. It works the same on Linux, macOS and PowerShell. The long PowerShell form is New-Item with -ItemType Directory.

Command 5: touch

Command five: touch. touch creates an empty file, here notes/todo.txt. Windows has no touch. In PowerShell, use New-Item with -ItemType File. Now ls notes shows that the file is there.

On Windows and macOS

Now Windows. Open PowerShell, and the same ideas apply. Get-Location shows where you are, and Get-ChildItem lists the folder. Set-Location moves you, and New-Item makes both folders and files. On macOS, open Terminal. The commands are the same as on Linux, and your home folder is /Users/ava.

Recap

Recap. pwd shows where you are. ls lists what is here. cd moves you. mkdir makes a folder, and touch makes an empty file.

Next episode

Next episode: working with files. You will copy, move, delete, read and search them. Subscribe so you do not miss it, and find written notes for every lesson at changecv.com/skills.

Common questions

What is the difference between an absolute and a relative path?

An absolute path starts at the root, such as /home/ava/notes or C:\Users\ava\notes, and works from anywhere. A relative path starts from the folder you are in, such as notes/todo.txt.

Why does Linux treat Notes and notes as different names?

Linux file names are case-sensitive. Windows file names are not, and macOS is usually not either, so the same command can behave differently across systems. Pick one style and stay consistent.

What does the tilde (~) mean in the prompt?

It is a short way of writing your home folder. On Linux it stands for /home/ava, and on macOS for /Users/ava. A plain cd with no folder takes you back there.

Why is there no touch command on Windows?

touch comes from Unix systems. In PowerShell, New-Item with -ItemType File creates an empty file, and New-Item with -ItemType Directory creates a folder.

What is the difference between ls, dir and Get-ChildItem?

In PowerShell they all do the same job. Get-ChildItem is the full name, and ls and dir are short names for it. The output is a table with Mode and LastWriteTime columns, not the Linux format.