terminal.cab

Linux Basics Lesson 1 of 38

guestLevel 1Badges and progress0/100 XP, XP to the next levelStreak0

Finding your way around a strange server

8 minutes

Learning goals

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/log

in the glossary: pwd

What 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:

  • -a also show names starting with a dot
  • -t newest first
  • -h sizes like 46M, together with -l

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 projects

in the glossary: ls

Read 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:

  • cd - back to the previous folder
  • cd ~ to your home folder, same as cd alone

Example:

cd /var/log/app
cd -
/home/lerner
cd -
/var/log/app
cd
pwd
/home/lerner

in the glossary: cd

Practice

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.

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the terminal

Not done yet

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.

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the 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.

Loading terminal …

lerner@web-01: ~bash
lerner@web-01:~$

Esc, then Tab leaves the terminal

Not done yet

Predict the output

Command

cd /var/log && cd -

Before the command, in your home folder ~

  • ~/.bashrc
  • ~/.profile
  • ~/.secret
  • ~/Documents/
  • ~/logs/
  • ~/notes.txt
  • ~/projects/
  • ~/archive/
What does cd /var/log && cd - print?

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

  1. Question 1 of 3In a line of ls -l, where do you find the owner of a file?

    Check works once you have chosen an answer.

  2. Question 2 of 3Which commands take you to your home folder? Choose TWO.

    Check works when exactly 2 are chosen. Chosen: 0.

  3. Question 3 of 3What does a dot at the start of a file name do?

    Check works once you have chosen an answer.

Cards

  1. Card 1 of 3

    Tap the card or press Space to turn it over.

  2. Card 2 of 3

    Tap the card or press Space to turn it over.

  3. 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

Next: lesson 2, Reading logs without drowning (9 min)

What you can do now: pwd, ls -la, cd /var/log/app

+0 XP in this lesson

  1. Lesson 1: done
  2. Lesson 2: open
  3. Lesson 3: open
  4. Lesson 4: open
  5. Lesson 5: open
  6. Lesson 6: open
  7. Lesson 7: open
  8. Lesson 8: open
  9. Lesson 9: open
  10. Lesson 10: open
  11. Lesson 11: open
  12. Lesson 12: open
  13. Lesson 13: open
  14. Lesson 14: open
  15. Lesson 15: open
  16. Lesson 16: open
  17. Lesson 17: open
  18. Lesson 18: open
  19. Lesson 19: open
  20. Lesson 20: open
  21. Lesson 21: open
  22. Lesson 22: open
  23. Lesson 23: open
  24. Lesson 24: open
  25. Lesson 25: open
  26. Lesson 26: open
  27. Lesson 27: open
  28. Lesson 28: open
  29. Lesson 29: open
  30. Lesson 30: open
  31. Lesson 31: open
  32. Lesson 32: open
  33. Lesson 33: open
  34. Lesson 34: open
  35. Lesson 35: open
  36. Lesson 36: open
  37. Lesson 37: open
  38. Lesson 38: open
1 of 38

Next: lesson 2, Reading logs without drowning (9 min) That's enough for today

Path complete

You finished all 38 lessons of Linux Basics.

Back to the path

Cheat sheet

The most important command lines of this module on one A4 page, black and white, to print or keep on your phone.