Linux Basics Lesson 1 of 38
Finding your way around a strange server
8 minutes
Learning goals
- Answer the first three questions on any server with pwd, ls and cd.
- Read ls -la, sort with ls -lt and get readable sizes with ls -lh.
- Commute between two folders with cd - and get home with cd or cd ~.
- Find hidden files and read one.
You know these commands from Terminal-Start, lesson 2. Here they get the options you need on a real server.
Where am I?
The prompt often only shows ~, short for your home folder. pwd (print working directory) gives you the full path. On
a machine you do not know, that is the first thing to check, because a relative path means something different in every
folder.
pwd
Purpose: Prints the full path of the folder you are in.
Syntax: pwd
Example:
pwd
/home/lerner
cd /var/log && pwd
/var/logWhat is here?
Plain ls hides half of the story. -l adds owner, size and date, and -a adds every name that starts with a dot.
Config files like to hide that way:
ls -la
Purpose: Lists what is in a folder, with -la also hidden files and all details.
Syntax: ls [OPTION]... [PATH]...
Options:
Example:
ls -la
total 40
drwxr-xr-x 6 lerner lerner 4096 Oct 17 08:58 .
drwxr-xr-x 3 root root 4096 Oct 17 08:58 ..
-rw-r--r-- 1 lerner lerner 12 Sep 1 12:00 .bashrc
-rw-r--r-- 1 lerner lerner 13 Sep 1 12:00 .profile
-rw------- 1 lerner lerner 56 Oct 2 08:00 .secret
drwxr-xr-x 2 lerner lerner 4096 Oct 14 10:30 Documents
drwxr-xr-x 2 lerner lerner 4096 Oct 1 03:00 archive
drwxr-xr-x 2 lerner lerner 4096 Oct 17 09:41 logs
-rw-r--r-- 1 lerner lerner 76 Oct 17 08:15 notes.txt
drwxr-xr-x 3 lerner lerner 4096 Oct 13 14:00 projectsRead one line from left to right: permissions, number of links, owner, group, size, last change, name. . is this
folder and .. the one above it. Two more options earn their place on a server. -t puts the newest entry on top, so
you see at once what was changed last. -h writes sizes the way people read them:
ls -lt logs
total 8
-rw-r--r-- 1 lerner lerner 621 Oct 17 09:41 app.log
-rw-r--r-- 1 lerner lerner 147 Oct 16 23:59 app.log.1
ls -lh archive
total 94M
-rw-r--r-- 1 lerner lerner 46M Sep 1 03:00 shop-2026-08.tar.gz
-rw-r--r-- 1 lerner lerner 48M Oct 1 03:00 shop-2026-09.tar.gz
How do I get somewhere else?
cd with a path takes you there, cd alone or cd ~ takes you home. On a server you often commute between a config
folder and a log folder. For that there is cd -, which jumps to the previous folder and prints where you landed:
cd /var/log/app
Purpose: Changes to another folder. cd - jumps back to the previous one.
Syntax: cd [FOLDER]
Options:
Example:
cd /var/log/app
cd -
/home/lerner
cd -
/var/log/app
cd
pwd
/home/lernerPractice
Terminal task 1/3
Mission
You just logged in to web-01. Find out which folder you are in.
Task 1/3: You just logged in to web-01. Find out which folder you are in.
Mission
You just logged in to web-01. Find out which folder you are in.
Task complete
Solution
pwd Why: After a login you usually land in your home folder, but on a strange server you check. Every relative path depends on the answer.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
Terminal task 2/3
Mission
Somebody left a hidden file in your home folder. Find it and read what it says.
Task 2/3: Somebody left a hidden file in your home folder. Find it and read what it says.
Mission
Somebody left a hidden file in your home folder. Find it and read what it says.
Task complete
Solution
ls -a
cat .secret Why: The dot is not a protection, only a convention. Anybody who may read the file can read it, ls just keeps the list short. Listing alone tells you the name, not what is inside.
Loading terminal …
Not done yet
Terminal task 3/3
Change to /var/log/app and list the files so that the most recently changed one is on top.
Task 3/3: Change to /var/log/app and list the files so that the most recently changed one is on top.
Change to /var/log/app and list the files so that the most recently changed one is on top.
Task complete
Solution
cd /var/log/app
ls -t Why: On a server the newest file is the one somebody or something wrote to last. That is usually where the story of the last few minutes is.
See the solution? You get fewer XP for this task.
Start over? Files, folders and output go back to the start. Your hints stay.
Loading terminal …
Esc, then Tab leaves the terminal
Not done yet
Repeat: you have solved this task before.
Predict the output
Command
cd /var/log && cd -Before the command, in your home folder ~
- ~/.bashrc
- ~/.profile
- ~/.secret
- ~/Documents/
- ~/logs/
- ~/notes.txt
- ~/projects/
- ~/archive/
Check works once you have chosen an answer.
Fill the gap
ls sorts by the time of the last change, newest first, with the option .
ls sorts by the time of the last change, newest first, with the option ….
Check works once you have typed an answer.
Next up: you know where the logs are, so now you read them.
Quiz
-
Check works once you have chosen an answer.
-
Check works when exactly 2 are chosen. Chosen: 0.
-
Check works once you have chosen an answer.
Cards
-
Card 1 of 3
Tap the card or press Space to turn it over.
-
Card 2 of 3
Tap the card or press Space to turn it over.
-
Card 3 of 3
Tap the card or press Space to turn it over.
End of the lesson
Still open: 5 exercises, 3 quiz questions
What you can do now: pwd, ls -la, cd /var/log/app
+0 XP in this lesson
- Lesson 1: done
- Lesson 2: open
- Lesson 3: open
- Lesson 4: open
- Lesson 5: open
- Lesson 6: open
- Lesson 7: open
- Lesson 8: open
- Lesson 9: open
- Lesson 10: open
- Lesson 11: open
- Lesson 12: open
- Lesson 13: open
- Lesson 14: open
- Lesson 15: open
- Lesson 16: open
- Lesson 17: open
- Lesson 18: open
- Lesson 19: open
- Lesson 20: open
- Lesson 21: open
- Lesson 22: open
- Lesson 23: open
- Lesson 24: open
- Lesson 25: open
- Lesson 26: open
- Lesson 27: open
- Lesson 28: open
- Lesson 29: open
- Lesson 30: open
- Lesson 31: open
- Lesson 32: open
- Lesson 33: open
- Lesson 34: open
- Lesson 35: open
- Lesson 36: open
- Lesson 37: open
- Lesson 38: open
Cheat sheet
-
pwdwhere am I, as a full path -
ls -laheverything here, with details and readable sizes -
ls -ltnewest entries on top -
cd -back to the previous folder -
cdhome, same as cd ~
The most important command lines of this module on one A4 page, black and white, to print or keep on your phone.
- Download PDF (PDF, 19 KB)
- View as image (PNG, 55 KB)