Skip to Main Content
Linux Desktop Hacks
book

Linux Desktop Hacks

by Nicholas Petreley, Jono Bacon
March 2005
Beginner to intermediate content levelBeginner to intermediate
342 pages
15h 55m
English
O'Reilly Media, Inc.
Content preview from Linux Desktop Hacks
46
|
Chapter 2, Console
#14 Simplify Changing Directories
HACK
HACK
#14
Simplify Changing Directories Hack #14
This hack makes it ridiculously easy to jump right to your favorite directories
from the command line.
Every Linux user probably knows there’s an environment variable called
PATH. When you type a command, your system looks through all the directo-
ries defined in the
PATH environment variable until it finds the command. If it
doesn’t find the command by the time it has exhausted all the directories
listed in the path, it tells you it can’t find the file.
There’s a similar environment variable that is a bit more obscure called
CDPATH. You can define CDPATH to include a number of directories to search
when you type the following command:
$ cd somewhere
Here’s how it works. Assume for a moment that you’re an obsessively orga-
nized writer who likes to create directory trees that organize files by types,
groups, categories, etc. Let’s say you organized your documents such that
you have the following directories:
/docs/pub/books/oreilly/linuxhacks/chapter1
/docs/pub/books/oreilly/linuxhacks/chapter2
/docs/pub/books/oreilly/linuxhacks/chapter3
Here’s what you want to do. You want to be able to jump right to the
chapter2 directory without having to type the entire path. Here’s how to set
the
CDPATH environment variable so that you can do that:
$ export CDPATH=:.:/docs/pub/books/oreilly/linuxhacks
Notice
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Server Hacks, Volume Two

Linux Server Hacks, Volume Two

William von Hagen, Brian K. Jones
Introducing Linux Distros

Introducing Linux Distros

Jose Dieguez Castro

Publisher Resources

ISBN: 0596009119Supplemental ContentCatalog PageErrata