0

I'm learning bash language and I have a question: Which is the difference between /directory and directory/. Because sometimes when I try:

cd Home/directory

I have the error

No such file etc etc..

Then I try some possibility like /home/directory, or /home/directory/ and others... Thanks.

2
  • Linux is case sensitive so Home is going to be wrong most of the times (it will work if you made it yourself ;) ) And due get used to hitting TAB for auto-completion ;)
    – Rinzwind
    Sep 22 '15 at 16:59
  • 1
    This has little to do with bash. Take a (good) look at tutorialspoint.com/unix/unix-file-system.htm and around...
    – Rmano
    Sep 22 '15 at 18:01
3

/ is the very top of your filesystem.

If you type cd /home/directory, you can do that from anywhere, because it is the full path.

If you type cd home/directory, that will only work if you are in location /, similarly, if you are in /home, you could type cd directory, but not cd /directory (because that doesn't exist, it's either /home/directory, or just directory from /home)

You can always add a trailing slash, that does not make any difference, it's the first one that is important.

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.