I was wondering if there's a way to run shell commands that affect only a certain directory and its subdirectories.

I'm using PHP and I want to make an app that allows the user to execute shell commands from a web page, but I want these commands to be restricted to a directory only

1 Answer 1


Avoid running any commands on your host machine originating from a web page. That's a recipe for disaster.

Have a look at operating system level virtualization. Depending on your OS you can use zones, jails or LXC.

Those OS level instances have a very low overhead and can be fired up pretty quickly. They do provide separation between the host OS and the user's environment. It's not as safe as a fully virtualized machine, but it might be sufficient for your use case.

You must log in to answer this question.

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