Sounds like you're trying to invent something that's been invented a handful of times already in a variety of manners:
Virtual Machines (yes, most have web based clients):
http://www.vmware.com/[
^]
https://www.virtualbox.org/[
^]
Containers:
https://www.docker.com/[
^] (if I remember correctly, this has an example that actually runs Linux within one of their containers from their website)
http://kubernetes.io/[
^]
If one of those meets what you'd like to do, find out more about how it works.