Wondering where a path that looks like this '/../' would point to outside a file? I'm guessing it might be something like always specifying the root directory and then the relative parent directory to the file it was written in?


Lets break /../ down piece by piece

The first /indicates the root of the file system This is the top most level of the filesystem

.. means the parent folder However, since we are at the top most level, we cannot go higher, so we are still at the top most folder

adding / at the end indicates a folder. This is never mandatory, unless specifying a subfolder path or file. So we are still at the top most folder on the file system.

So, /../ is no different than typing /

  • 24
    Except when you're in chroot, and the kernel is sufficiently buggy that such tricks let you escape the chroot. (It used to be the case years ago, I think.) – grawity Sep 29 '16 at 6:11
  • 8
    The trailing slash can be significant in some cases. For example, if /example is a symlink to a directory, ls -l /example will display the symlink, whereas ls -l /example/ will display the contents of the directory. – Flimm Sep 29 '16 at 8:30
  • you could contrast with cd ../abc i.e. where ../ does make a difference. I guess it's only useful for relative paths, not for absolute paths. – barlop Sep 29 '16 at 11:40
  • 1
    @barlop ../ can have an effect for absolute paths: /foo/bar/../quux = /foo/quux. Some more useful examples: 1) realizing you just tab completed a really long directory name, but it wasn't the one you wanted. ../ might be quicker than backspacing 50 times. 2) foo=/long/absolute/path/to/foo; bar=$foo/../bar; – 8bittree Sep 29 '16 at 13:51
  • 1
    @grawity Closing the .. escape path if implementing chroot as a jail is as obvious as closing the barn door to keep the animals in; you don't miss a case like that: the most obvious escape path. That leads me to suspect that early chroot implementations might not have had inescapability as a requirement. – Kaz Sep 29 '16 at 19:00

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.