Learn Understand first, then practice while the concept is still fresh.

M08 - File Operations: Create and Edit

Create folders and files from the terminal, write simple text safely, and make small edits without relying on a full GUI workflow.

File System

File Operations: Create and Edit

Create folders and files from the terminal, write simple text safely, and make small edits without relying on a full GUI workflow.

40 min BEGINNER BOTH Field-verified
What you should be able to do after this
  • Create folders and files from the terminal.
  • Write new content or append a line safely.
  • Make a small text edit using a terminal-friendly workflow.

Why This Matters

Most CLI work is not dramatic. It is small, careful changes:

  • create a working folder
  • add a config file
  • write one line to a log or notes file
  • make a simple text change on a machine that has no desktop environment

This module stays with those real tasks. We are not trying to master every editor. We are building safe first habits.


1. Create Folders

The terminal is often the fastest way to create a clean structure.

Create Folders

Create one folder

mkdir Project

Create a nested structure

mkdir -Force Project\docs\notes

Create Folders

Create one folder

mkdir Project

Create a nested structure

mkdir -p Project/docs/notes

Use nested creation when you already know the structure you want.


2. Create Empty Files

Sometimes you want the file to exist first, then fill it in later.

Create Empty Files

New-Item -ItemType File -Path .\notes.txt

Create Empty Files

touch ./notes.txt

This is common for placeholders, logs, and simple config files.


3. Write or Append Text

You do not always need a full editor. Sometimes one command is enough.

Write Text Safely

Replace the file contents

Set-Content -Path .\notes.txt -Value “first line”

Add a new line at the end

Add-Content -Path .\notes.txt -Value “second line”

PowerShell also supports redirection, but Set-Content and Add-Content are easier for beginners to read.

Write Text Safely

Replace the file contents

echo “first line” > ./notes.txt

Add a new line at the end

echo “second line” >> ./notes.txt

One Critical Difference

> replaces the file. >> adds to the end. If you are not completely sure which one you need, stop and check the file first.


4. Make a Small Edit

For a short change, use the simplest tool that is available on the system you are on.

Open a File in Notepad

notepad .\notes.txt

On Windows, launching Notepad from the terminal is still a valid CLI workflow. It is often the most practical choice for a beginner.

Open a File in Nano

nano ./notes.txt

Save: Ctrl+O, then Enter

Exit: Ctrl+X

nano is enough for this stage. You do not need vim yet.

The goal is not to prove you are advanced. The goal is to make the change correctly.


A Safe Practice Loop

Try this in a practice folder:

  1. Create a folder called sandbox.
  2. Create a file called todo.txt.
  3. Write one line into it.
  4. Append one more line.
  5. Read the file back to confirm the result.

If that feels easy, you are learning the right thing.


What to Ignore for Now

  • advanced shell redirection tricks
  • vim commands and modal editing
  • editing system files in /etc or other privileged locations

Those are real topics, but they are not required for your first reliable workflow.


Before You Move On

You are ready for the next module when you can:

  1. create a folder tree
  2. create a new file
  3. replace file contents on purpose
  4. append a second line on purpose

Next, we add the operations that require more care: copy, move, rename, delete, and archive.