Skip to Main Content
Linux Pocket Guide
book

Linux Pocket Guide

by Daniel J. Barrett
February 2004
Beginner content levelBeginner
200 pages
5h 40m
English
O'Reilly Media, Inc.
Content preview from Linux Pocket Guide

Home Directories

Users’ personal files are often found in /home (for ordinary users) or /root (for superusers). Your home directory is typically /home/your-username: /home/smith, /home/jones, etc. There are several ways to locate or refer to your home directory.

cd

With no arguments, the cd command returns you (i.e., sets the shell’s working directory) to your home directory.

HOME variable

The environment variable HOME (see Shell variables) contains the name of your home directory.

$ echo $HOME     The echo command prints its arguments
/home/smith
~

When used in place of a directory, a lone tilde is expanded by the shell to the name of your home directory.

$ echo ~
/home/smith

When followed by a username (as in ~smith), the shell expands this string to be the user’s home directory:

$ cd ~smith
$ pwd            The "print working directory" command
/home/smith
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 Pocket Guide, 2nd Edition

Linux Pocket Guide, 2nd Edition

Daniel J. Barrett
Linux in a Nutshell, 6th Edition

Linux in a Nutshell, 6th Edition

Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins

Publisher Resources

ISBN: 9780596806347Errata Page