Your computer can hold millions of files. The OS organizes them all in one big tree. On Linux, the trunk of the tree is a single folder called / (say "root"). Everything else branches from it. Let's explore! 🌳
🧪 Lab 1: tour the tree
ls /
You'll see the famous top-level folders. Here is what they're for:
| Folder | What lives there |
|---|---|
/home |
Your files. Each user gets a folder here |
/etc |
System settings |
/bin, /usr |
Programs (the commands you run) |
/var |
Things that change, like logs |
/tmp |
Temporary files |
/dev |
Devices, shown as files |
/proc |
Live information from the OS |
/boot |
The files used to start Linux |
Let's peek into a few:
ls /etc | head
ls /usr/bin | head
ls /var/log | head
Look around, but only look: these are the OS's own folders, so we don't change them.
🧪 Lab 2: paths are addresses
cd /
pwd
cd /usr/bin
pwd
cd ~
pwd
- An absolute path starts with
/and always works, no matter where you are:/usr/bin. - A relative path starts from where you are now:
Documents/notes.txt. ~is your home folder..means here and..means one folder up.
cd ~/MagiLab
cd ..
pwd
cd MagiLab
pwd
🧪 Lab 3: build a project folder tree
You'll build this tree inside your lab:
Make your own version with one command that creates all the folders at once:
cd ~/MagiLab
mkdir -p Science/OS Pictures Stories
ls
ls Science
mkdir -pmakes folders and any missing parent folders.
Now make some files:
touch Pictures/cat.png
echo "Linux is awesome!" > Stories/first.txt
echo "The kernel is the heart." > Science/OS/notes.txt
cat Science/OS/notes.txt
touchmakes an empty file, andecho ... > filemakes a file with words in it.catshows what's inside a file.
Look at the whole project:
ls -R
-R means recursive: it shows folders inside folders.
🧪 Lab 4: copy, move and delete (inside the lab!)
cp Stories/first.txt Stories/copy.txt
mv Stories/copy.txt Science/moved.txt
ls Stories Science
rm Science/moved.txt
| Command | What it does |
|---|---|
cp a b |
Copy a file |
mv a b |
Move or rename a file |
rm a |
Remove (delete) a file, with no undo |
🛡️ Safety tip:
rm -i nameasks you first before deleting. When you're learning, add-i!
🧪 Lab 5: be a file detective
find ~/MagiLab -name "*.txt"
grep -r "kernel" ~/MagiLab
findlooks for files by name. The*means anything.grep -rsearches inside files for a word. You should see yournotes.txt!
ls -la ~
The -a shows hidden files: any name that starts with a dot, like .bashrc, is hidden. Linux uses them for settings.
🧪 Lab 6: what kind of file is it?
file ~/MagiLab/Stories/first.txt
file /bin/ls
file looks inside a file to say what it is. The ending (extension) like .txt is only a hint! (If file isn't installed, skip this one.)
Words to know
| Word | What it means |
|---|---|
Root (/) |
The top of the whole folder tree |
Home (~) |
Your own folder |
| Absolute path | An address starting from / |
| Relative path | An address starting from where you are |
| Hidden file | A file whose name starts with a dot |

