# My dumb question of the day: What does the tilda key do in tcsh



## Phishfry (Oct 8, 2019)

Every once in a while I accidentally hit the tilda key(~) and I get the following output under the root user:

```
/root: Permission denied.
```

I looked through /.cshrc and I did not see an alias for the tilda.
What does it do in the tcsh shell?


----------



## yuripv (Oct 8, 2019)

It translates to your home directory, and that by itself can't be "executed", hence the "permission denied"? Same as if you'd type "/root".


----------



## CraigHB (Oct 8, 2019)

I actually use that one a lot to specify a path in my home dir, saves a few keystrokes.


----------



## SirDice (Oct 9, 2019)

The `~` is just a short-hand for `$HOME`. This also works; `cd ~myuser` which is translated to `cd /usr/home/myuser` (or where myuser's home directory has been set to). Quite useful, I use it a lot. 


```
The character `~' at the beginning of a filename refers to home
       directories.  Standing alone, i.e., `~', it expands to the invoker's
       home directory as reflected in the value of the home shell variable.
       When followed by a name consisting of letters, digits and `-'
       characters the shell searches for a user with that name and substitutes
       their home directory; thus `~ken' might expand to `/usr/ken' and
       `~ken/chmach' to `/usr/ken/chmach'.  If the character `~' is followed
       by a character other than a letter or `/' or appears elsewhere than at
       the beginning of a word, it is left undisturbed.  A command like
       `setenv MANPATH /usr/man:/usr/local/man:~/lib/man' does not, therefore,
       do home directory substitution as one might hope.
```

It's not limited to the C shells though, it works with Bourne shells too.


----------

