Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On my machine, because of the way I have things set up, doing:</p> <pre><code>cd ~ # /work1/jleffler cd ~jleffler # /u/jleffler </code></pre> <p>The first pays attention to the value of environment variable <code>$HOME</code>; I deliberately set my <code>$HOME</code> to a local file system instead of an NFS-mounted file system. The second reads from the password file (approximately; NIS complicates things a bit) and finds that the password file says my home directory is <code>/u/jleffler</code> and changes to that directory.</p> <p>The annoying stuff is that most software behaves as above (and the POSIX specification for the shell requires this behaviour). I use some software (and I don't have much choice about using it) that treats the information from the password file as the current value of $HOME, which is wrong.</p> <p>Applying this to the question - as others have pointed out, '<code>cd ~x</code>' goes to the home directory of user 'x', and more generally, whenever tilde expansion is done, <code>~x</code> means the home directory of user 'x' (and it is an error if user 'x' does not exist).</p> <hr> <p>It might be worth mentioning that:</p> <pre><code>cd ~- # Change to previous directory ($OLDPWD) cd ~+ # Change to current directory ($PWD) </code></pre> <p>I can't immediately find a use for '<code>~+</code>', unless you do some weird stuff with moving symlinks in the path leading to the current directory.</p> <p>You can also do:</p> <pre><code>cd - </code></pre> <p>That means the same as <code>~-</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload