~
alone expands to your own home directory. There is also a syntax ~username
that expands to the home directory of a given username. So if myUsername
is my username, then ~myUsername
is the same as ~
, and expands to /Users/myUsername
. Meanwhile, ~root
expands to root
's home directory, which (on my system) is /var/root
. Most of the other possibilities, like ~nobody
, seem to go to /var/empty
.
The big list of names you are seeing are when you press Tab after cd ~
is simply a list of usernames on your system. You can complete the line with any of the usernames and the resulting cd
command will (try to) take you to that user's home directory. Since the directories ~root
, ~nobody
etc. are not in your ~
, it is no surprise that ls ~
doesn't show them.
Note that it is typical for there to be many more "users" on a system than actual human users, since, for security reasons, it is often beneficial to run programs or services as their own user. Since programs can't access things their users don't have permissions for, this keeps programs from touching things they shouldn't.
ls ~
then Tab with no whitespace or justls ~
then Return?ls ~
then Return.