Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I un-tar-ed a file and it had a directory called "~something".

Without thinking I typed "cd ~" and hit tab to have bash complete the name. Instead of getting the "~something" result I expected I got a whole list of things starting with "~". Some of them are a little disconcerting. Things like: ~pulse ~sys/ ~daemon/ ~kernoops/ ~mysql/ ~root/ ~syslog ~libuuid/ ~rtkit/ ~usbmux

I deleted the tar directories and tried from another directory with the same results.

I did I a find on a couple of these starting from / down and found nothing but I am confused where and why Bash came up with this list and wondering if perhaps I have been rooted.

Thanks for any insight.

share|improve this question
up vote 4 down vote accepted

~ indicates the current user's home directory. ~username indicates that user's home directory. bash sees the ~ and assumes that you want some home directory on the system. If you want a literal "~" then you need to escape it.

cd \~<Tab>
share|improve this answer
But I don't have any home directories with the names bash came up with. Nor any files with those names in my own home directory. I don't understand how bash came up with the list. – Newton Falls Dec 25 '12 at 0:06
Every user has a home directory. Not all are under /home. – Ignacio Vazquez-Abrams Dec 25 '12 at 0:07
Ah, ok. I ran cat on /etc/passwd and the names I saw are in the file. But their home directory entries point to directories that don't exist e.g. /home/kdm – Newton Falls Dec 25 '12 at 0:12
I have assume Bash is taking a shortcut and listing home directories from /etc/passwd without necessarily verifying that the directories actually exist. – Newton Falls Dec 25 '12 at 0:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .