I\'m only new to using SSH, but when I log in I end up in the directory ~, which in general is the same directory when FTPing in. I can still go to /, but I don\'t know what
You can try realpath
realpath ~
~ is an alias to the currently logged in users home directory. To find out where that really is, type pwd
(stands for: Print Working Directory) right after logging in, which should give you the location relative to /
. It's probably something like:
/home/myusername
Home directory need not necessarily be under /home as kigurai has pointed out.
~ is your home directory. To see the path type:
echo ~
in the terminal
Yes, it is the home directory of the user you logged in as. You can use the command pwd
(print working directory) to see where it is located on the file system.
As others have commented, the tilde indicates your current $HOME
directory. This may or may not be the same as the value of ~username
for your user name. On my machine, $HOME
and ~
both refer to /work1/jleffler
. However, ~jleffler
is a reference to an NFS mounted directory, /u/jleffler
, as specified in the /etc/passwd
file (or any equivalent database - the POSIX standard defines the behaviour in terms of the getpwnam()
function; see below). My profile carefully sets $HOME
. It is interesting (aka exasperating) to work out which software packages use the wrong definition of the home directory.
For most people, ~
and ~username
are the same for their user name, but that is not required. Given that you are asking the question, it is almost certainly the case that ~
and ~username
are the same.
Quote from section 2.6.1 'Tilde Expansion' of POSIX.1-2008:
A "tilde-prefix" consists of an unquoted
<tilde>
character at the beginning of a word, followed by all of the characters preceding the first unquoted<slash>
in the word, or all the characters in the word if there is no<slash>
. [...] If the login name is null (that is, the tilde-prefix contains only the tilde), the tilde-prefix is replaced by the value of the variable HOME. If HOME is unset, the results are unspecified. Otherwise, the tilde-prefix shall be replaced by a pathname of the initial working directory associated with the login name obtained using thegetpwnam()
function [...]. If the system does not recognize the login name, the results are undefined.