back to labs
Directory Stack: CDPATH, pushd & popd
MediumCommand Line Guru15-25 minThe brief
You bounce between the same few deep directories all day. Two shell tools kill the friction: CDPATH (a search path for cd, so cd api works from anywhere) and the directory stack (pushd/popd/dirs, a working set you hop between).
Wire CDPATH into a drop-in (/root/.bashrc.d/nav.sh), then build a stack across the three seeded directories with pushd — saving dirs -v to /root/case/STACK.txt — and popd one off, recording where you land in /root/case/TOP.txt. Grading reads those files and sources nav.sh. The exact directories are in /root/case/brief.txt.
What you'll do
- Set CDPATH in a drop-in so `cd <leaf>` resolves from anywhere
- Build a directory stack across the three dirs with pushd
- Save the numbered stack (dirs -v) to STACK.txt
- popd one entry and record the directory you land in
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
