O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Home Directories

Users’ personal files are often found in /home (for ordinary users) or /root (for the superuser). 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 ~fred), the shell expands this string to be the user’s home directory:

$ cd ˜fred
$ pwd            The “print working directory” command
/home/fred

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required