Navigating the Linux Filesystem - page 2
Upside-down Trees
Let's go back to that filesystem in Figure 1, where we'd gotten as far
as /home. But you can string together more than one directory in a
pathname. You know that /home gets you one level below the root;
but if you add another directory, you can refer to useful places
like /home/sue. On most systems, that's where the user
named sue would have her home directory. So when Sue first
logs in, her working directory is her home directory,
/home/sue.
Remember I said how important it is whether you start with a slash? Suppose Sue has a directory of her own called "home", where she keeps all the records related to her house. If she's in her home directory and types "ls home", that's very different from "ls /home", as Figure 2 illustrates.
$ ls /home fred sue $ ls home mortgage.ods paintcodes.odf photosSee the difference?
Now let's say, going back to Figure 1, that Sue wants to
share a photo of her dog with Fred, who has an account on the same
system. All she has to do is tell him the full pathname to the photo
/home/sue/Pictures/pets/fido.jpg.
There's a shortcut, though. You can use the tilde character, ~, to
refer to home directories. A tilde by itself means your own home
directory: if Sue wants to edit the Fido photo in GIMP, she can say
gimp ~/Pictures/pets/fido.jpg.
The ~ stands for /home/sue in any command Sue types.
When Fred types a ~, though, Linux will look in /home/fred instead.
If Sue wants to tell Fred where to find her Fido photo, she should
use the slightly longer form "~sue", which means "the home directory of
user sue", or /home/sue. So she gives Fred the pathname:
~sue/Pictures/pets/fido.jpg, and Fred can use that from
anywhere.
Of course, Fred can't necessarily read Sue's files, and vice versa -- there are ways of protecting your files so no one else can see them. But that's a topic for another day!
Akkana Peck is a freelance
programmer whose credits include a tour as a Mozilla developer.
She's also the author of Beginning
GIMP: From Novice to Professional.
- Skip Ahead
- 1. Upside-down Trees
- 2. Upside-down Trees

Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.