Section 1 of 12

1 Before you start

Before you begin, take a few minutes to check what you already know and how confident you feel. You will see the same questions again at the end of the module — this helps both you and us measure what you have learned. Click an option for every question and confidence rating, then click Next to continue.

Pre-test

Which command creates a new, empty file called patient_001.txt?

Pre-test

You want to create the folder study/raw/vitals in one step, even though study/ does not exist yet. Which command works?

Pre-test

What is the difference between cp and mv?

Pre-test

Which command renames the file draft.csv to cohort_2026.csv?

Pre-test

After running rm important.csv, how do you get the file back?

Pre-test

Which command removes an EMPTY directory?

Pre-test

What does the -i flag add to commands like rm, cp, and mv?

Pre-test

You want to copy a folder and everything inside it. Which command works?

Pre-confidence

I can create folders and empty files from the terminal.

Not at all confident
Fully confident
Pre-confidence

I can copy and move files, and I know which command keeps the original.

Not at all confident
Fully confident
Pre-confidence

I know why rm should be used carefully and what -i does.

Not at all confident
Fully confident
Section 2 of 12

2 Introduction

Now that you can move around, the next step is to create, copy, move, and delete things. These are everyday commands - you will use them every time you sit at a terminal. The commands are short, but a couple are unforgiving, so we will cover the safety rails too.

  • Making new folders and empty files: mkdir, touch.
  • Copying and moving: cp, mv (and renaming).
  • Removing: rm, rmdir, and why deletion in the terminal is permanent.
  • Useful flags: -r recursive, -i interactive, -v verbose.
Section 3 of 12

3 Making New Folders - mkdir

mkdir creates a folder in the current location:

$ pwd
/home/student
$ mkdir cohort_2026
$ ls
cohort_2026  notes.txt  scripts  vitals

List several folders in one command to create them all:

$ mkdir raw_vitals cleaned_vitals lab_reports figures

To create a folder AND any missing parents in one go, add -p. Without -p, mkdir refuses to create nested folders if a step in the middle does not exist.

$ mkdir cohort_2026/raw/vitals
mkdir: cannot create directory 'cohort_2026/raw/vitals': No such file or directory
$ mkdir -p cohort_2026/raw/vitals
$ ls cohort_2026/raw
vitals
Try it out

Try this snippet in the Bash Scratchpad on the right.

Try this snippet
$ mkdir test_folder
$ ls
$ mkdir -p study/raw/vitals
$ ls study/raw
mkdir makes one folder per name you pass it, so several names create several folders at once, and a nested path only succeeds when every parent already exists, which is exactly the gap -p closes by creating each missing level along the path.
mkdir makes one folder per name you pass it, so several names create several folders at once, and a nested path only succeeds when every parent already exists, which is exactly the gap -p closes by creating each missing level along the path.
Section 4 of 12

4 Making Empty Files - touch

touch creates an empty file. If the file already exists, touch leaves the contents alone and just updates the timestamp - occasionally useful in scripts. For now, think of touch as "make a new empty file".

$ touch patient_001.txt
$ ls -lh patient_001.txt
-rw-r--r-- 1 student staff 0 May 24 11:03 patient_001.txt
Running touch with a filename brings a brand-new file into existence that contains nothing at all (0 bytes), and ls -lh confirms it is there with a size of zero.
Running touch with a filename brings a brand-new file into existence that contains nothing at all (0 bytes), and ls -lh confirms it is there with a size of zero.

The 0 in the size column confirms the file is empty. You can pass several filenames at once.

Try it out

Try this snippet in the Bash Scratchpad on the right.

Try this snippet
$ touch a.txt b.txt c.txt
$ ls -lh
Section 5 of 12

5 Copying and Moving - cp and mv

Section 5.1 of 12

5.1 cp - make a copy

The shape is always cp SOURCE DESTINATION. The source exists; the destination is where the copy lands.

$ cp cohort_2026.csv cohort_2026_backup.csv
$ ls
cohort_2026.csv  cohort_2026_backup.csv

If the destination is a folder, the copy lands inside it with the original name:

$ cp cohort_2026.csv archive/
$ ls archive
cohort_2026.csv

To copy a whole folder you must add -r (recursive):

$ cp vitals vitals_backup
cp: -r not specified
omitting directory 'vitals'
$ cp -r vitals vitals_backup
$ ls
vitals  vitals_backup
The command is always cp SOURCE DESTINATION and the source is never touched; a plain destination makes a renamed copy, a folder destination drops the copy inside under its original name, and copying a folder requires -r so its contents come along.
The command is always cp SOURCE DESTINATION and the source is never touched; a plain destination makes a renamed copy, a folder destination drops the copy inside under its original name, and copying a folder requires -r so its contents come along.
Section 5.2 of 12

5.2 mv - move or rename

mv has the same shape but MOVES instead of copying. The source disappears from its old location.

$ mv cohort_2026.csv archive/cohort_2026.csv
$ ls archive
cohort_2026.csv

There is no separate "rename" command - mv with a different destination name in the same folder is how you rename:

$ mv draft_cohort.csv cohort_2026.csv

mv does NOT need -r for folders. A folder and its contents move together in one step.

Try it out

Try this snippet in the Bash Scratchpad on the right.

Try this snippet
$ touch report.txt
$ cp report.txt report_v2.txt
$ mv report.txt archive.txt
$ ls
mv simply rewrites a file's path, so pointing it at a new folder moves the file and pointing it at a new name renames it, all without -r and without ever leaving a copy behind.
mv simply rewrites a file's path, so pointing it at a new folder moves the file and pointing it at a new name renames it, all without -r and without ever leaving a copy behind.
Section 6 of 12

6 Removing - rm and rmdir

Deletion at the terminal is permanent. There is no Recycle Bin, no Trash, no Undo. Once a file is gone with rm, it is gone. Read that twice.

Section 6.1 of 12

6.1 rm - remove files

$ rm draft_cohort.csv
$ ls
(draft_cohort.csv is no longer listed)

To remove a folder and everything in it, add -r:

$ rm -r old_study

You will see rm -rf in online examples. The -f flag is "force" - it suppresses every prompt and ignores every warning. Avoid -f as a beginner. If you mistype the path, it silently obliterates whatever you mistyped.

Adding -r to rm widens its reach from a single file to an entire folder, while -f removes the warnings that would let you catch a mistake, so rm -rf can wipe a whole directory silently and permanently.
Adding -r to rm widens its reach from a single file to an entire folder, while -f removes the warnings that would let you catch a mistake, so rm -rf can wipe a whole directory silently and permanently.

Until your fingers are calm, get into the habit of rm -i. Bash will ask you to confirm each file:

$ rm -i patient_001.txt
rm: remove regular file 'patient_001.txt'? y
Section 6.2 of 12

6.2 rmdir - remove an EMPTY folder

rmdir only removes folders that are completely empty. It is a safety net - if a folder still has anything in it, rmdir refuses, giving you a chance to notice.

$ rmdir scratch
rmdir: failed to remove 'scratch': Directory not empty
$ ls scratch
things_i_forgot_about.txt
Try it out

Try this snippet in the Bash Scratchpad on the right.

Try this snippet
$ cp cohort_2026.csv scratch.csv
$ ls
$ rm scratch.csv
$ mkdir tmp_dir
$ rmdir tmp_dir
$ ls
Section 7 of 12

7 Check your understanding

You have reached the end of the module. Try the same questions again — your answers here, paired with your pre-test answers, are how we measure what the module taught you. Answer every question and confidence rating, then click Submit and see results to view your score.

Post-test

Which command creates a new, empty file called patient_001.txt?

Post-test

You want to create the folder study/raw/vitals in one step, even though study/ does not exist yet. Which command works?

Post-test

What is the difference between cp and mv?

Post-test

Which command renames the file draft.csv to cohort_2026.csv?

Post-test

After running rm important.csv, how do you get the file back?

Post-test

Which command removes an EMPTY directory?

Post-test

What does the -i flag add to commands like rm, cp, and mv?

Post-test

You want to copy a folder and everything inside it. Which command works?

Post-confidence

I can create folders and empty files from the terminal.

Not at all confident
Fully confident
Post-confidence

I can copy and move files, and I know which command keeps the original.

Not at all confident
Fully confident
Post-confidence

I know why rm should be used carefully and what -i does.

Not at all confident
Fully confident
Section 8 of 12

8 Your results

Here is how your post-test answers compare with your pre-test answers. The pre/post pairing is the most reliable way to see what this module actually taught you.

Your score

Submit the post-test to see your results.

Muddiest point

What is the one thing from this module that is still unclear to you?

Rate this module

Overall, how would you rate this module?

How likely are you to recommend this module to a peer? (0 = not at all, 10 = extremely likely)