With the environment set up in the previous lesson — Bash 5.x, your ~/veloz-ops created and the PATH configured — the time has come to move around the system with confidence. Navigating the command line is not a formality: it is the skill that everything else rests on. When, in Module 9, your script has to locate /var/log/veloz/access.log from any directory, or when at three in the morning you have to work out what is filling up the disk on srv-veloz-01, it will all come down to moving and looking with precision. In this lesson you will learn the anatomy of a command, the map of the Linux filesystem and the tools to walk and inspect it.

Contents

  1. Anatomy of the prompt and of a command
  2. The Linux directory tree
  3. Absolute and relative paths
  4. pwd: where am I
  5. cd: moving around
  6. ls: looking
  7. Reading the output of ls -l
  8. tree: seeing the structure at a glance
  9. pushd and popd: the directory stack
  10. Inspecting without opening: file, stat, du and df
  11. A guided tour of the Veloz Envíos infrastructure

  1. Anatomy of the prompt and of a command

1.1 The prompt

The prompt is the line Bash prints while waiting for your orders. With the configuration we left in the previous lesson it looks like this:

joan@srv-veloz-01:~/veloz-ops$

Every piece tells you something:

Part Meaning
joan The user you are working as
@ Separator
srv-veloz-01 The machine you are on
: Separator
~/veloz-ops Current directory (~ is your home folder)
$ A normal user. If you were root, you would see # here

That last character deserves attention: # means you have full permissions and that a mistake can be irreversible. Get into the habit of looking at it before running anything destructive.

1.2 The parts of a command

A Bash command breaks down like this:

ls -l -h /var/log/veloz
command  options       argument
  ls     -l -h    /var/log/veloz
  • Command: the program to run (ls).
  • Options (or flags): they change the behavior. They start with a dash.
  • Arguments: what the command acts on.

Options come in two formats worth telling apart:

Format Example Characteristics
Short -l, -h A single letter. They can be grouped: -lh is the same as -l -h
Long --human-readable A whole word, more readable. They cannot be grouped

These four forms are equivalent:

ls -l -h /var/log/veloz
ls -lh /var/log/veloz
ls --format=long --human-readable /var/log/veloz
ls -l --human-readable /var/log/veloz

A practical rule: use short options when typing interactively and long ones when writing scripts. In a script, --human-readable explains itself; -h forces you to check the manual (and in many other commands -h means "help", which is misleading).

When a long option takes a value, it is written with = or with a space:

ls --sort=time /var/log/veloz
ls --sort time /var/log/veloz

And one detail that saves odd situations: -- marks the end of the options. If one day you have a file called -report.txt, ls -- -report.txt treats it as an argument and not as an option.

  1. The Linux directory tree

In Linux there are no drive letters. Everything hangs from a single origin: the root, /. Additional disks, USB drives or network partitions are "mounted" at some point in that tree.

graph TD
    R["/"] --> etc["/etc<br/>configuration"]
    R --> var["/var<br/>variable data"]
    R --> srv["/srv<br/>service data"]
    R --> home["/home<br/>users"]
    R --> tmp["/tmp<br/>temporary"]
    R --> usr["/usr<br/>programs"]
    var --> log["/var/log"]
    log --> veloz["/var/log/veloz<br/>access.log, app.log"]
    srv --> sv["/srv/veloz/data<br/>shipments.csv"]
    home --> joan["/home/joan (~)"]
    joan --> ops["~/veloz-ops<br/>bin lib etc logs"]
    usr --> bin["/usr/bin<br/>ls, grep, date..."]

The directories you will use daily:

Directory What it holds Example at Veloz Envíos
/ The root of everything
/etc System configuration files /etc/nginx/, /etc/passwd
/var Data that varies during operation Logs, queues, caches
/var/log System and application logs /var/log/veloz/access.log
/srv Data served by the machine's services /srv/veloz/data/shipments.csv
/home Users' home folders /home/joan, shortened to ~
/tmp Temporary files; wiped on reboot Intermediate files from scripts
/usr/bin System programs for all users ls, grep, date, awk
/usr/local/bin Programs installed manually by the administrator In-house tools
/opt Self-contained third-party software Monitoring agents
/root The superuser's home folder
/proc Virtual filesystem with kernel information /proc/cpuinfo, /proc/meminfo
/dev Devices represented as files /dev/null, /dev/sda

This layout is not arbitrary: it is defined by the FHS (Filesystem Hierarchy Standard). Knowing it lets you guess where things are on any Linux server, even one you have never seen. If someone tells you "check the application logs", you already know you will start by looking in /var/log.

  1. Absolute and relative paths

A path is the address of a file or directory. There are two ways of expressing it.

  • Absolute path: it starts with / and describes the full route from the root. It is unambiguous and works from anywhere.
    /var/log/veloz/access.log
    
  • Relative path: it does not start with / and is interpreted from the current directory.
    veloz/access.log     (if you are in /var/log)
    

Bash also understands four fundamental shortcuts:

Symbol Meaning Example
. The current directory ./report.sh
.. The parent directory cd ..
~ Your home folder (/home/joan) cd ~/veloz-ops
- The previous directory (where you were before) cd -

Examples with the current directory set to /var/log/veloz:

You type It resolves to
access.log /var/log/veloz/access.log
./access.log /var/log/veloz/access.log
../syslog /var/log/syslog
../../log/veloz /var/log/veloz
~/veloz-ops/bin /home/joan/veloz-ops/bin
/srv/veloz/data /srv/veloz/data

When should you use each? The professional rule is clear:

  • In scripts, absolute paths. A veloz-ops script launched by cron may start from any directory; if it uses relative paths, it will fail unpredictably.
  • Interactively, relative ones. You type far less.

The - shortcut deserves a special mention because it saves an enormous amount of time:

cd /var/log/veloz
cd /srv/veloz/data
cd -
/var/log/veloz

cd - takes you back to the previous directory and also prints where it went. Switching between two distant locations becomes a single keystroke.

  1. pwd: where am I

pwd (print working directory) answers the most basic question.

pwd
/home/joan/veloz-ops

It looks unnecessary if the prompt already shows it, but it is not: some prompts only display the directory's short name (\W instead of \w), and in a script there is no prompt at all.

It has an interesting nuance with symbolic links:

pwd -P

-P (physical) shows the real path, resolving symbolic links. By default, pwd shows the logical path, that is, the route you took to get there. If /srv/veloz/data were actually a link to /mnt/veloz-data, pwd would say the former and pwd -P the latter. When diagnosing disk space, that difference matters.

  1. cd: moving around

cd (change directory) changes the current directory. Its most useful forms:

cd /var/log/veloz      # absolute path
cd veloz               # relative path (from /var/log)
cd ..                  # go up one level
cd ../..               # go up two levels
cd ~                   # go to your home folder
cd                     # identical to 'cd ~'
cd -                   # go back to the previous directory
cd ~/veloz-ops/bin     # combining ~ and a relative path

A realiztic working sequence on srv-veloz-01:

cd /var/log/veloz
pwd
cd ../..
pwd
cd -
pwd
/var/log/veloz
/var
/var/log/veloz

Notice the detail: cd ../.. from /var/log/veloz goes up two levels and lands in /var, not in the root. Each .. steps back exactly one rung.

An important technical note that will fully make sense in the next lesson: cd is not a program, it is a Bash builtin. It has to be. If it were an external executable, it would launch as a child process, change its directory and die, leaving yours untouched. That is why man cd finds nothing and you have to use help cd; we will see this in 01-05.

Tab completion, which is essential here: type cd /var/log/vel and press Tab. Bash completes it to /var/log/veloz/. If several options are possible, press Tab twice to list them. The full set of keyboard shortcuts appears in 02-06, but start using this one today: it cuts down typing errors dramatically.

  1. ls: looking

ls lists the contents of a directory. It is probably the command you will run the most times in your life.

ls
bin  etc  lib  logs

With no arguments, it lists the current directory. You can point it at another one:

ls /var/log/veloz
access.log  access.log.1  app.log  app.log.1  veloz-api.log

6.1 The options you will really use

Option Long name What it does
-l --format=long Long format: permissions, owner, size, date
-a --all Also shows hidden files (the ones starting with .)
-A --almost-all Like -a but without . and ..
-h --human-readable Sizes in K, M, G instead of bytes (requires -l)
-t --sort=time Sorts by modification date, most recent first
-r --reverse Reverses the order
-S --sort=size Sorts by size, largest first
-R --recursive Descends through every subdirectory
-d --directory Shows the directory itself, not its contents
-i --inode Shows the inode number
-F --classify Appends a suffix by type (/ directory, * executable, @ link)

The combinations that will become reflexes:

ls -lh /var/log/veloz
total 47M
-rw-r--r-- 1 www-data adm   28M Aug  3 10:14 access.log
-rw-r--r-- 1 www-data adm  9.4M Aug  2 23:59 access.log.1
-rw-r--r-- 1 veloz    veloz 6.2M Aug  3 10:15 app.log
-rw-r--r-- 1 veloz    veloz 2.1M Aug  2 23:59 app.log.1
-rw-r--r-- 1 veloz    veloz 1.3M Aug  3 09:02 veloz-api.log
ls -lt /var/log/veloz

Sorted by date: the first one is the most recently modified. This is the star command when something has just broken: it immediately tells you which log is being written right now.

ls -lhS /var/log/veloz

Sorted by size from largest to smallest: the star command when the disk fills up.

ls -la ~
total 68
drwxr-xr-x 8 joan joan 4096 Aug  3 09:30 .
drwxr-xr-x 3 root root 4096 Jul 12 08:00 ..
-rw------- 1 joan joan 2814 Aug  3 10:02 .bash_history
-rw-r--r-- 1 joan joan 3841 Aug  3 09:28 .bashrc
-rw-r--r-- 1 joan joan  807 Jul 12 08:00 .profile
drwx------ 2 joan joan 4096 Jul 12 08:05 .ssh
drwxrwxr-x 6 joan joan 4096 Aug  3 09:30 veloz-ops

A key concept shows up here: in Linux, a file is hidden simply because its name starts with a dot. There is no special attribute. That is why ~/.bashrc does not appear with a plain ls. The . and .. directories you see are the directory itself and its parent.

  1. Reading the output of ls -l

This is one of those skills used daily throughout an entire professional career. Take one line:

-rw-r--r-- 1 veloz veloz 6291456 Aug  3 10:15 app.log

It breaks down into seven fields:

# Value Meaning
1 -rw-r--r-- File type and permissions
2 1 Number of hard links
3 veloz Owning user
4 veloz Owning group
5 6291456 Size in bytes (with -h, 6.0M)
6 Aug 3 10:15 Date and time of last modification
7 app.log Name

The first field is read in four blocks:

-        rw-        r--        r--
type     owner      group     others

The first character indicates the type:

Character Type
- Regular file
d Directory
l Symbolic link
c Character device (e.g. /dev/null)
b Block device (e.g. a disk)
p Named pipe (FIFO)
s Socket

The next three blocks are permissions: r read, w write, x execute; a dash means that permission is not granted. So -rw-r--r-- reads as: regular file, the owner can read and write, the group can only read, everyone else can only read.

This analysis immediately explains practical things. If you try to write to /var/log/veloz/app.log as joan and the file belongs to veloz with -rw-r--r-- permissions, you will get Permission denied. And if a script of yours will not start with ./script.sh, the first thing you will check is whether it has the x. Permissions, how to change them and octal notation are studied in depth in lesson 02-03; here you only need to know how to read them.

A special case you will see a lot on a server:

ls -l /var/log/veloz/current.log
lrwxrwxrwx 1 root root 8 Aug  3 00:00 /var/log/veloz/current.log -> app.log

The leading l and the -> arrow indicate a symbolic link: a file that points to another. The rwxrwxrwx permissions of a link are always like that and mean nothing; the ones that matter are the target's.

  1. tree: seeing the structure at a glance

tree draws the directory hierarchy. It is not installed by default on many systems:

sudo apt install tree      # Debian/Ubuntu
sudo dnf install tree      # Fedora/RHEL
tree ~/veloz-ops
/home/joan/veloz-ops
├── bin
├── etc
├── lib
└── logs

5 directories, 0 files

Useful options:

Option Effect
-L n Limits the depth to n levels
-d Directories only
-a Includes hidden entries
-h Shows human-readable sizes
-f Shows the full path of each item
tree -L 2 -d /var/log
/var/log
├── apt
├── nginx
├── unattended-upgrades
└── veloz

4 directories

Limiting the depth with -L is almost mandatory in large directories: without it, tree / can spit out hundreds of thousands of lines.

If tree is not available and you cannot install it (common on production servers or in containers), the alternative is ls -R, which we will see in the final tour, or find combined with a format, which is covered in 05-01.

  1. pushd and popd: the directory stack

cd - toggles between two directories, but sometimes you need to juggle three or four. For that, Bash maintains a directory stack.

  • pushd PATH: pushes the current directory onto the stack and moves to PATH.
  • popd: pops the stack and returns to the directory at the top.
  • dirs -v: shows the stack, numbered.
cd ~/veloz-ops
pushd /var/log/veloz
/var/log/veloz ~/veloz-ops
pushd /srv/veloz/data
/srv/veloz/data /var/log/veloz ~/veloz-ops
dirs -v
 0  /srv/veloz/data
 1  /var/log/veloz
 2  ~/veloz-ops
popd
pwd
/var/log/veloz ~/veloz-ops
/var/log/veloz
popd
pwd
~/veloz-ops
/home/joan/veloz-ops

Each pushd prints the whole stack, with the current position on the left. It is the ideal tool when you are diagnosing an incident and need to jump between logs, data and scripts without losing your thread. You can also jump straight to a position: pushd +2 rotates the stack to item number 2.

  1. Inspecting without opening: file, stat, du and df

Before opening a file it pays to know what it is and how much space it takes. Four commands cover 90% of the cases.

10.1 file: what kind of file it is

Linux does not trust the extension: file examines the contents to determine the type.

file /var/log/veloz/app.log /srv/veloz/data/shipments.csv /usr/bin/ls ~/veloz-ops
/var/log/veloz/app.log:         ASCII text
/srv/veloz/data/shipments.csv:  CSV text
/usr/bin/ls:                    ELF 64-bit LSB pie executable, x86-64, dynamically linked
/home/joan/veloz-ops:           directory

Its practical value is enormous: it stops you from opening a 2 GB binary in a text editor and freezing the terminal. Before running cat on an unknown file, run file on it.

A very relevant use for Veloz Envíos: spotting compressed files with a misleading extension.

file /var/log/veloz/access.log.1
/var/log/veloz/access.log.1: gzip compressed data, from Unix

Even though it does not end in .gz, it is compressed, and it would have to be read with zcat instead of cat.

10.2 stat: the full metadata

stat /var/log/veloz/app.log
  File: /var/log/veloz/app.log
  Size: 6291456    Blocks: 12288      IO Block: 4096   regular file
Device: 8,1  Inode: 262147   Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/  veloz)   Gid: ( 1001/  veloz)
Access: 2026-08-03 10:15:22.000000000 +0200
Modify: 2026-08-03 10:15:22.000000000 +0200
Change: 2026-08-03 10:15:22.000000000 +0200
 Birth: 2026-07-01 08:00:00.000000000 +0200

stat gives you the same as ls -l but with full precision, including the three timestamps Linux maintains:

Stamp Name Changes when...
atime Access The contents are read
mtime Modify The contents are changed
ctime Change The contents or the metadata change (permissions, owner)

Confusing mtime with ctime is a common mistake in audits: if someone changed a file's permissions but not its contents, mtime stays the same and only ctime gives it away.

stat also accepts custom formats, very handy in scripts:

stat -c '%n has %s bytes, modified on %y' /var/log/veloz/app.log
/var/log/veloz/app.log has 6291456 bytes, modified on 2026-08-03 10:15:22.000000000 +0200

Where %n is the name, %s the size and %y the modification date. In Module 9 we will use this form to check whether a log has been updated recently.

10.3 du: how much a directory takes up

du (disk usage) adds up the space used.

du -sh /var/log/veloz
47M	/var/log/veloz
  • -s (summarize): a single total instead of the detail of every subdirectory.
  • -h (human-readable): in K, M, G.

To see the breakdown per subdirectory, sorted from largest to smallest:

du -h --max-depth=1 /var/log | sort -h -r | head -5
312M	/var/log
47M	/var/log/veloz
28M	/var/log/nginx
12M	/var/log/journal
4.1M	/var/log/apt

This command is the standard answer to "the disk is filling up": it tells you which subdirectory the problem is in, and by repeating it one level down you reach the culprit in a few steps. The | pipe and sort are studied in Module 2; here we are using it as a recipe.

10.4 df: how much is left on the disk

df (disk free) reports the mounted partitions and how full they are.

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       100G   72G   23G  76% /
/dev/sdb1       500G  410G   65G  87% /srv
tmpfs           3.9G  1.2M  3.9G   1% /run

The difference between the two commands tends to confuse:

Command Point of view Question it answers
du From the files upwards "How much does this folder take up?"
df From the filesystem "How much is left on the disk?"

And a classic anomaly worth knowing: if df says the disk is full but du cannot find the data, it is almost always because a process is keeping an already deleted file open. The space is not released until that process ends. That is exactly what happens when someone deletes access.log without restarting the service that writes to it. Process management is covered in 05-02.

df -i is also worth knowing: it shows the free inodes. A disk with space but no available inodes (millions of tiny files) also produces "no space left" errors.

  1. A guided tour of the Veloz Envíos infrastructure

Let us put it all together in a real reconnaissance session on srv-veloz-01. It is your first day and you want to understand the terrain.

Step 1: Locate yourself

whoami
pwd
joan
/home/joan

Step 2: Explore the logs

cd /var/log/veloz
ls -lht
total 47M
-rw-r--r-- 1 veloz    veloz 6.0M Aug  3 10:15 app.log
-rw-r--r-- 1 www-data adm    28M Aug  3 10:14 access.log
-rw-r--r-- 1 veloz    veloz 1.3M Aug  3 09:02 veloz-api.log
-rw-r--r-- 1 www-data adm   9.4M Aug  2 23:59 access.log.1
-rw-r--r-- 1 veloz    veloz 2.1M Aug  2 23:59 app.log.1

You already know a lot from this single screen:

  • app.log and access.log are being written right now (today's date, a recent time): the service is alive.
  • The .1 files are the previous day's rotations, cut off at 23:59.
  • access.log weighs 28 MB, four times more than app.log: if space needs watching, that is the candidate.
  • access.log belongs to www-data and app.log to veloz: they are two different services, with different identities. As joan, you will be able to read them (the "others" block has r) but not write to them.

Step 3: Check the type before opening

file access.log access.log.1
access.log:   ASCII text, with very long lines
access.log.1: gzip compressed data, from Unix, original size 84213760

Confirmed: the rotated file is compressed despite not ending in .gz. Good to know before trying to read it.

Step 4: Visit the business data

pushd /srv/veloz/data
ls -lh
/srv/veloz/data /var/log/veloz
total 12M
-rw-rw-r-- 1 veloz veloz  11M Aug  3 06:00 shipments.csv
-rw-rw-r-- 1 veloz veloz 512K Jul 31 06:00 shipments-2026-07.csv
drwxrwxr-x 2 veloz veloz 4.0K Jul  1 06:00 archive

A working pattern is visible: there is an active file, a monthly one and an archive directory. The 06:00 timestamp suggests an automated process that runs in the early hours.

stat -c 'Modified: %y | Size: %s bytes' shipments.csv
Modified: 2026-08-03 06:00:12.000000000 +0200 | Size: 11534336 bytes

Step 5: Check the space

du -sh /var/log/veloz /srv/veloz/data
df -h /srv
47M	/var/log/veloz
12M	/srv/veloz/data
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       500G  410G   65G  87% /srv

/srv at 87%: not critical yet, but exactly the kind of metric our future report script should watch. Make a mental note, because it will be one of the requirements in Module 9.

Step 6: Head home

popd
cd ~/veloz-ops
tree
/var/log/veloz
/home/joan/veloz-ops
├── bin
├── etc
├── lib
└── logs

5 directories, 0 files

For now it is empty. From Module 3 onwards we will start filling it.

The alternative without tree

If tree is not installed on the server:

ls -R ~/veloz-ops
/home/joan/veloz-ops:
bin  etc  lib  logs

/home/joan/veloz-ops/bin:

/home/joan/veloz-ops/etc:

/home/joan/veloz-ops/lib:

/home/joan/veloz-ops/logs:

Less pretty, but available on any machine.

Common Mistakes and Tips

  • Confusing /var/log with ~/veloz-ops/logs. The first is managed by the system and requires permissions; the second is yours. Our scripts will write to the second.
  • Running cd without checking whether it worked. If the directory does not exist, cd fails but you stay where you were; in a script, the following commands will act on the wrong directory. It is solved with cd /path || exit, which we will see in 03-04.
  • Using relative paths in scripts. A script launched by cron does not start in the directory you imagine. Always absolute paths.
  • Forgetting that -h does not mean the same thing in every command. In ls, du and df it is "human readable"; in many others it is "help". When in doubt, man (lesson 01-05).
  • Running cat on a huge or binary file. It freezes the terminal and can leave it full of corrupted characters (fixed with reset). Use file first and less to read.
  • Looking for hidden files with a plain ls. In Linux a leading dot is all it takes to hide a file. Use ls -a when something "does not show up".
  • Running tree / or du / with no limit. It takes forever and floods the terminal. Use -L or --max-depth.
  • Tip: use tab completion systematically. On top of typing less, it validates that the path exists while you write it: if it does not complete, you have made a mistake.
  • Tip: ls -lt and du -h --max-depth=1 | sort -hr are the two diagnostic commands that most often save a night shift. Memorise them.

Exercises

Exercise 1: Resolving paths in your head

You are in /var/log/veloz. Without running anything, state which absolute path each expression is equivalent to:

  1. ..
  2. ../../..
  3. ./app.log
  4. ../nginx/error.log
  5. ~/veloz-ops/bin
  6. ../../../srv/veloz/data/shipments.csv

Exercise 2: Reconnaissance of a server

On your own machine (adapting the paths if you do not have the Veloz Envíos structure), carry out this reconnaissance sequence and explain what each result tells you:

  1. Find out your current directory.
  2. List /var/log in long format, with human-readable sizes and sorted by modification date, newest first.
  3. Identify the largest file or directory in /var/log.
  4. Find out the usage percentage of the partition where /var lives.
  5. Determine the type of the file /etc/passwd without opening it.

Exercise 3: Navigating with the stack

Using only pushd, popd and dirs, write the sequence of commands that:

  1. Starting from ~, visits /var/log, then /etc and then /tmp, pushing each one.
  2. Shows the numbered stack.
  3. Returns to /etc by undoing a single level.
  4. Finally goes back to ~.

State which directory you end up in after each step.

Solutions

Solution to Exercise 1

Expression Absolute path Reasoning
.. /var/log Goes up one level from /var/log/veloz
../../.. / Three levels: logvar/. You cannot go above the root
./app.log /var/log/veloz/app.log . is the current directory
../nginx/error.log /var/log/nginx/error.log Goes up to /var/log and down into nginx
~/veloz-ops/bin /home/joan/veloz-ops/bin ~ does not depend on where you are
../../../srv/veloz/data/shipments.csv /srv/veloz/data/shipments.csv Goes up to / and down into srv

A detail about the third case: / is the ceiling. cd ../../../../.. from anywhere leaves you in /, with no error.

Solution to Exercise 2

# 1
pwd

# 2
ls -lht /var/log

# 3
du -h --max-depth=1 /var/log | sort -hr | head -3

# 4
df -h /var

# 5
file /etc/passwd

Output and reading of each point:

/home/joan

You are in your home folder.

total 312M
drwxr-x--- 2 root adm    4.0K Aug  3 10:16 veloz
-rw-r----- 1 syslog adm   18M Aug  3 10:16 syslog
drwxr-xr-x 2 root root   4.0K Aug  3 00:00 nginx

The first entry is the most recently modified: the services writing right now. It is the starting point for investigating an ongoing incident.

312M	/var/log
47M	/var/log/veloz
28M	/var/log/nginx

The first line is the total of the directory you asked about; from there on, veloz is the biggest consumer. Note: --max-depth=1 includes the directory itself, which is why /var/log heads the list.

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       100G   72G   23G  76% /

/var has no partition of its own: it hangs off /, which is at 76%. That is an important fact, because it means a runaway log can fill the entire system, not just /var.

/etc/passwd: ASCII text

It is plain text, so it can be read with cat or less with no risk. Despite the name, it does not contain passwords (those are in /etc/shadow).

Solution to Exercise 3

cd ~
pushd /var/log     # -> /var/log      | stack: /var/log ~
pushd /etc         # -> /etc          | stack: /etc /var/log ~
pushd /tmp         # -> /tmp          | stack: /tmp /etc /var/log ~
dirs -v
popd               # -> /etc          | stack: /etc /var/log ~
popd; popd         # -> ~             | stack: ~

Output of dirs -v at step 2:

 0  /tmp
 1  /etc
 2  /var/log
 3  ~

The route: ~/var/log/etc/tmp → (popd) /etc → (popd) /var/log → (popd) ~.

Notice that each pushd pushes the directory you were in and takes you to the new one, while popd discards the top and places you in the next. An alternative for the last step would be cd ~ directly, but the exercise asked for the stack only. If you wanted to jump straight to /var/log from /tmp without popping, pushd +2 would rotate the stack to that position.

Conclusion

You now move around the system with judgement. You can break a command down into program, options and arguments; you know the FHS map and what each key directory holds; you tell absolute from relative paths and know when to use each; you handle pwd, cd, ls with their decisive options, tree and the pushd/popd stack; and you can read ls -l line by line and inspect files with file, stat, du and df before touching them. Above all, you have done your first real reconnaissance of srv-veloz-01 and you now know where every piece of Veloz Envíos lives.

So far you have been using the shell. In the next lesson, Understanding the Shell, we will open the box: what exactly happens between pressing Enter and the result appearing, why cd cannot be an external program, how Bash looks for commands in the PATH, what a subshell is and why a variable defined inside one disappears when you leave it. Understanding that mechanism is what separates someone who copies commands from someone who knows what they are doing.

Bash Programming Course

Module 1: Introduction to Bash

Module 2: Basic Bash Commands

Module 3: Scripting Fundamentals

Module 4: Intermediate Scripting

Module 5: Advanced Scripting Techniques

Module 6: Working with External Tools

Module 7: Automation and Scheduling

Module 8: Best Practices and Optimization

Module 9: Real-World Projects

© Copyright 2026. All rights reserved