Shell – Making the current directory as if it were where an absolute path starts

directoryshell

I'm wondering if there is an application that makes it so that commands after it operate in an environment that treats the working directory as if it were the top-most one, and there is absolutely no way to access the wider file system via '..' and such?

Best Answer

Looks like you might be looking for chroot.

Note that while something like ../../../../../.. will not escape the restricted root directory, there are other ways to escape indirectly, by leveraging other processes. If you're concerned about a malicious application, run it as a user who doesn't run any process outside the chroot.

For a more advanced/packageable/secure solution, have a look to docker or other container based solutions.