Moving to Linux: Kiss the Blue Screen of Death Goodbye!

There's No Place Like $HOME

Yeah, I know. It's a pretty cheesy pun, but I like it.

Because you've just had a chance to play with a few directory commands, I'd like to take a moment and talk about a very special directory. Every user on your system has a home directory. That directory can be referenced with the $HOME environment variable. To get back to your home directory at any time, simply type cd $HOME; then no matter where you were, there you are. Actually, you only need type cd, press <Enter>, and you are home. The $HOME is implied.

The $HOME shortcut is great for shell scripts or anytime you want to save yourself some keystrokes. For instance, say you want to copy the file remote.file to your home directory and you are sitting in /usr/some_remote/dir. You could use either of the next two commands:

cp remote.file /home/my_username cp remote.file $HOME

The second command saves you keystrokes, and the more time you spend doing system administration, the more you will love shortcuts like this. To save the maximum keystrokes, you can also use the tilde (~), a special character synonym for $HOME:

cp remote.file ~

Категории