Navigating the Linux Filesystem - page 2
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
/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,
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
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
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
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!
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader