8

For example, what would it mean to say:

cd ~/mydirectory

Lucas Alanis
  • 199
  • 1
  • 3
  • 10

2 Answers2

11

~ is a shortcut for the home directory, so

cd ~/mydirectory 

Will move to mydirectory if there is such a directory in your home folder, otherwise it will throw a directory does not exist error.

Example:

enter image description here

Your home directory is located at /home/<username>.

Trivia: This is why the default bash prompt has a tilde in it like this user@host:~$. The tilde indicates that you are currently in your home directory. If you move somewhere else, for example into /etc it will show user@host:/etc$.

Seth
  • 58,122
  • 2
    I've always used $HOME instead, for clarity and because some programs don't expand a tilde. – kiri Feb 06 '14 at 20:59
2

It's shorthand for your home directory. For example, my desktop directory is at

 /home/marc/Desktop

or

 ~/Desktop

for short.

Marc
  • 9,980