Linux module
Lesson 4
Create and organize files
Build a small project layout with mkdir, touch, cp, mv, and a careful rm.
beginner25 minRun on your machine
What you will be able to do
- Create directories and empty files
- Copy, rename, and remove files without using rm -rf
- Recreate the linux-lab layout used in later lessons
Why this matters for DE and AI
Jobs expect a layout: data/ in, logs/ out, scripts/ to run. On a server you often create that layout yourself. Messy directories are how people overwrite yesterday’s extract.
Concepts
| Command | What it does |
|---|---|
mkdir NAME |
Create a directory |
mkdir -p a/b/c |
Create nested directories, no error if they exist |
touch FILE |
Create an empty file, or update its timestamp |
cp SOURCE DEST |
Copy |
mv SOURCE DEST |
Move or rename |
rm FILE |
Delete a file |
rmdir DIR |
Delete an empty directory |
There is no Recycle Bin in the terminal. rm is permanent.
We will use this layout for the rest of Linux:
~/dcubes/linux-lab/
data/
logs/
scripts/
Practice on your machine
cd ~/dcubes/linux-lab
mkdir -p data logs scripts
ls
What you should see: data logs scripts (order may differ).
Create a placeholder file and inspect it:
touch data/readme.txt
ls data
Copy it, then rename the copy:
cp data/readme.txt data/readme.copy.txt
mv data/readme.copy.txt data/notes.txt
ls data
What you should see: notes.txt and readme.txt.
Put a line of text into notes.txt using a redirect (full story in lesson 8):
echo "practice files live here" > data/notes.txt
> writes stdout into a file. It overwrites if the file exists.
Read it (full story in the next lesson):
cat data/notes.txt
What you should see: practice files live here
Remove only the extra file:
rm data/readme.txt
ls data
notes.txt should remain. If you removed the wrong file, recreate it with echo as above.
Confirm you did not delete the directories:
ls ~/dcubes/linux-lab
Common mistakes
rmwithout checkingpwd. Alwayspwdandlsbefore deleting.mkdir datawhendataexists. Without-p, mkdir errors. With-p, it is fine.- Copying a directory with
cpwithout-r. For this lesson we only copy files. Recursive copy is how people duplicate entire datasets by accident — we will wait.
Next
Read files like a data engineer — cat, less, head, tail, and wc -l.