CyberStars

Tree and Paths

As folders gain sub-folders, it gets hard to picture the whole structure. The tree command draws it for you as a neat diagram.

tree
.
├── mission.txt
├── reports
│   ├── january.log
│   └── february.log
└── tools
    └── deploy.sh

2 directories, 4 files

The indentation and lines show what is inside what. It is a read-only command. Like ls, it never changes anything.

Absolute vs relative paths

A path is the address of a file or folder. There are two kinds.

An absolute path starts at the root / and spells out every step:

/home/student/reports/january.log

It works from anywhere: it is the full address.

A relative path starts from wherever you currently are. If you are in /home/student, then:

reports/january.log

points to the same file. No leading / means "start from here".

Two special names help with relative paths:

  • .: the current directory
  • ..: the parent directory (one level up)

So ../tools/deploy.sh means "go up one level, then into tools".

Use pwd to see your absolute location, and tree to see the structure below you.


Mission: Map the Station

Before starting repairs you need a map. Draw the whole structure under your home directory, then walk into the reports archive with a relative path. From there, without moving, list the folder that holds the deploy script, with a path that starts from where you stand.

Expected result

You end up inside the reports archive, and your last listing shows the deploy script in its own folder.