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