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 the ~ means. Home? Where is it in relation to /, or how could I find out?
相关问题
- How to get the return code of a shell script in lu
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Invoking Mirth Connect CLI with Powershell script
- Error building gcc 4.8.3 from source: libstdc++.so
/ is the root of the file system ~/ or ~ is the root of your profile, ~/ is always /home/username
And home, in relation to /, isn't necessarily always in the same place. That's why the ~ shortcut is so useful. The path to home should be in $HOME. Try typing
echo $HOME
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 thegetpwnam()
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:
~ is your home directory, yes. Which is very nice since your home directory is not always where you think it should be (/home/).
Also, fun fact: You can use "cd ~myuser" to get to the home directory of the user "myuser".
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.