Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder if there is a kind of a sandboxing solution for linux: when I want to try a software without installing it I get all the .deb files and extract then somewhere, then I do two things:

export PATH="$PATH:/home/user/testing_app/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/user/testing_app/lib"

Most of the times it works well, but sometimes the applications require /etc configurations, or other resources (like images on share folder) that I was not able to solve.

I know the chroot with mount -o bind would provide me a separated environment, but I still need to bind /bin and /etc directories to use others dependencies.

Well, I was wondering if you know any solution, such a way to bind two directories mixing their content and recording the new/edited content only in one of them.

From Wikipedia: "In computer security, a sandbox is a security mechanism for separating running programs. It is often used to execute untested code, or untrusted programs from unverified third-parties, suppliers, untrusted users and untrusted websites."

Sometimes there is more than one app that is candidate to solve my problems, in that case I want to get the one which better fit my needs, so I install all of them, but I just want to try them, I want to "restore" my machine state as it was before the installations, of all changes the software did. Just removing them is not enough, it is because them generate dot files in my home, or generate logs files, or change other software's settings, I want to have register of all the changes the app do when it runs, and undo them.

Yes, a VM would solve my problem but besides taking a large space to hold two or more linux installations, it also lose performance.

A separated linux installation in my disk doing chroot would please me better than a VM in performance, but it still takes some unwanted spaces because of repeated files, almost all of them are the same of my original distro.

This is what prompted me to open this topic, if somehow I could return to a previous state of my entire disk, like a version control system, or like the qemu-img's backing file "If a base image is specified with -o backing_file=filename, the image will only record differences between itself and the base image". Of course this still isn't the best solution, because I wish undo only a specific app changes.

The ideal solution would be something like that:

$ mkdir dir1 dir2
$ echo "Lipsum" > dir1/file1
$ echo "Original" > dir1/file2
$ sudo mount -o bind -some-magic-flag dir1 dir2
$ echo "Changed" > dir2/file2
$ touch dir2/file3
$ ls -1 dir2
# it's ok
$ ls -1 dir1
# file3 sould not be here!
$ sudo umount dir2
$ ls -1 dir2
# file1 was not changed, but file2 was
$ cat dir1/file2
$ cat dir2/file2

This is what I need!

share|improve this question

closed as unclear what you're asking by bodhi.zazen, dobey, Braiam, Avinash Raj, Eric Carvalho Jan 4 '14 at 15:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

That is not how I would use a chroot and I do not think mount --bind works the way you imagine either. IMO you have 2 solutions. IMO, the easiest is to simply use a virtual machine and install your applications there. A more complex solution is to use a chroot. See . To be honest, if you do not trust the source of your .deb you should probably not be installing it anywhere if you do not understand the source code and how to "monitor" the software. What are you wanting to do exactly? – bodhi.zazen Jan 3 '14 at 20:51
@bodhi.zazen I want to try a software to see if it attends my needs, if it doesn't I want to remove it knowing there is no lost file remaining and it didn't modified any of my original files. Indeed a VM would work as well, but it is too large and slow to maintain. I will study the other solution. – Tiago Pimenta Jan 3 '14 at 21:05
With that in mind, I think it is easiest to use apt-get, to remove use the purge option. sudo apt-get purge <package> as well as autoclean from time to time. See – bodhi.zazen Jan 3 '14 at 21:07
@bodhi.zazen I am skeptical, I do not trust just purging the packages will undo all the changes, for instance, if the app create dot files in my home? Or even if during the configuration it changed the files of other app? – Tiago Pimenta Jan 3 '14 at 21:15
From your edit, I do not think mount -o bind works the way you think it does and if you are not careful you are likely to break ubuntu ;) chroot mount -o bind is not a sandbox. – bodhi.zazen Jan 3 '14 at 21:22

Create a virtual machine, boot it up, and apply your install there. They, if it is OK, install it in your physical machine; if not, delete the VM. virtual machine inside ubuntu may be useful to you.

In Linux, the sandbox IS a VM.

share|improve this answer
That is probably the easiest, best solution , but from the discussion above "Indeed a VM would work as well, but it is too large and slow to maintain." – bodhi.zazen Jan 3 '14 at 21:21
DOn't need to maintain it, just test with it... – K7AAY Jan 3 '14 at 21:21
Tell that to the OP =) – bodhi.zazen Jan 3 '14 at 21:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.