Beginner · 6 min · practise every command in the built-in terminal

Creating Files and Directories

touch — Create an empty file

touch myfile.txt
touch index.html style.css script.js   # Multiple files at once

touch also updates the modification timestamp of existing files.

mkdir — Make directory

mkdir projects
mkdir -p projects/website/css    # Create nested directories at once

The -p flag creates all parent directories if they don't exist. Without it, mkdir projects/website would fail if projects doesn't exist yet.

Naming conventions

  • Use lowercase letters
  • Use hyphens - or underscores _ instead of spaces
  • Avoid special characters like ! @ # $ %
  • Spaces in filenames require quoting: touch "my file.txt" (not recommended)

Check your work

ls -la

Practice tasks

  1. Create a file called notes.txt
  2. Create a directory called myproject
  3. Create nested directories: work/reports/2024 in one command
  4. Create three files at once: index.html, style.css and script.js
  5. Update the timestamp of notes.txt without changing its content

Commands in this lesson

Files & Directories