3

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.

1 Answer 1

4

~ 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>
4
  • 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. Dec 25, 2012 at 0:06
  • Every user has a home directory. Not all are under /home. Dec 25, 2012 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 Dec 25, 2012 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. Dec 25, 2012 at 0:36

You must log in to answer this question.

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