The comparison above, while valid, is perhaps misleading: the tilde only works during shell interpretation in scripts and at the command line. The environment variable, $HOME, however, works anywhere an environment variable works - which is a lot more places.
– MeiApr 6 '11 at 14:44

The "squiggly" is called a tilde. It is used to refer to your home directory which on Linux, is normally/home/username. It is also stored in the $HOME environment variable. Expanding the ~ to the location of the home directory is the job of the shell (like zsh or bash) or file manager (like Nautilus) and not the filesystem or OS its self.

You can also use this to refer to another user's home directory. For instance, if the other user's username is bob, you could refer to their home directory with ~bob, which will be expanded to /home/bob/.

The first example you've given sets the variable service to ~, so it corresponds to your home directory. This is equivalent to service=/home/username or service=$HOME.

The second example copies the file ~/Desktop/Service$version.tgz (or /home/username/Desktop/Service$version.tgz) to /home/username. This command is equivalent to:

mv ~/Desktop/Service$version.tgz ~

or

mv ~/Desktop/Service$version.tgz $HOME

or

mv ~/Desktop/Service$version.tgz /home/username/

The third will change the current working directory ($PWD) to /home/username/. This is equivalent to:

One additional thing to keep in mind: Tilde expansion is the job of the shell or the filemanager, it is not a function of the Linux filesystem itself. Thus it often won't work in configuration files and adding quotes around "~" it will stop its expansion in the shell.
– GrumbelApr 6 '11 at 8:58

3

It should also be noted that home directories don't necessarily lie in /home so it shouldn't be assumed that ~ expands to /home/[my user name] or that ~bob expands to /home/bob
– darkliquidApr 6 '11 at 9:13

Thanks for the suggestion @Grumbel. And Thanks @PriceChild for adding in @darkliquid's suggestion!
– WuffersApr 6 '11 at 12:24