Back to problem
Systems Administrator ICoreEnvironment & PATH~30-40 min

The Wrong Binary

The senior admin runs db-backup fine. deploy types the exact same word and gets the wrong version. Why?

Your goal

Your goal is not simply to make db-backup print the right version once. Your goal is to understand how a shell turns a bare command name into one specific program, fix the search order for deploy without deleting or rewriting either installed copy, and prove the fix survives a completely fresh login — not just the one shell you happened to edit.

Resolve
Inspect
Compare
Test
Persist
Verify

There are two installed copies of db-backup on this machine. Typing a bare command name isn't magic — it's a search, governed by a setting called PATH. You'll learn exactly how that search works, why deploy's shell finds the wrong copy first, and how to fix it in a way that survives a fresh login.

01

An address and a name are not the same thing

Back to this problem

This incident lives entirely inside deploy's own login environment — root's PATH was never touched. Your terminal starts you as root, so before running anything below, switch into deploy's shell first: sudo -iu deploy. Testing as root will not show the bug at all — it isn't broken.

Compare these two ways of running the same program:

Two different kinds of instruction
/usr/local/bin/db-backup
db-backup
  • `/usr/local/bin/db-backup` — explicit. You told Linux exactly where the file is.
  • `db-backup` — just a name. Your shell has to decide what it refers to.
/usr/local/bin/db-backup
explicit — no searching required
vs
db-backup
just a name — the shell must resolve it

The moment you type only a name, your shell has to answer a question: "where should I look for something called db-backup?" That question is what this entire investigation is about.

Knowledge check 0

Both /usr/bin/db-backup and /usr/local/bin/db-backup exist on this machine.

If you run the bare command db-backup, what decides which one actually runs?