1

I'm trying to locate where some files are stored and I can easily browse to them via ssh by going to "cd ~/foldername", however, I have no idea what directory "~/" actually is.

When I browse around folders via WinSCP (yes, I'm a Windows admin), I can't seem to locate this folder at all.

Note: I'm using Amazon Linux on EC2.

4

The tilde character is shorthand for the home directory of the current logged-in user. If you are logged in as jason, then ~ is likely /home/jason/. It is the home directory of any username, as given in /etc/passwd. It is also the same as the $HOME environment variable. The expansion from ~ to the home directory is done by the shell.

  • That is what I thought, but I can't seem to locate the folder under my home directory. The full directory I'm looking for it "~/.ec2"...does adding that period make the folder invisible or something? I'm able to browse to it via ssh without issue, but it doesn't show up under WinSCP. – Jason Davis Jan 18 '13 at 18:14
  • I figured out my issue...I had sudo'ed to the root user to make the file I was looking for, so the folder I was looking for was actually under /root rather than /home/user. This information was helpful in any case though, thanks! – Jason Davis Jan 18 '13 at 18:16
  • Will award the answer once I'm able to in 8 minutes. Thanks for the quick response everybody. – Jason Davis Jan 18 '13 at 18:18
  • 2
    It is expanded by the shell, try echo ~. There's not even a folder with that name, because any command getting it as an argument will actually be passed the value of $HOME, not ~. – njsg Jan 18 '13 at 18:25
  • 2
    ~ actually expands to the current value of $HOME, not necessarily to the current user's home directory. Normally they'll be the same, but it is possible to modify the value of $HOME. (This is rarely a good idea.) On the other hand, ~foo does expand to the home directory of user foo as defined in /etc/passwd or in your system's equivalent. – Keith Thompson Jan 18 '13 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.