system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Virtual machines

I’m trying to understand them a bit better, but it’s just not clicking for me. How is it able to operate like a physical computer and what is the benefit of that? Would you be able to say write an essay for your English class on a VM, save it there, and access it at a later time?
gpt
All an operating system is is an interface between your applications and the hardware; that these days provides some convenience functionality: a shell/desktop environment, a file system for data storage. But at a low level, the operating system is just computer code itself running in the CPU of the computer.

But what's the difference between a computer instruction running on the real hardware CPU or one that is interpreted by a software based CPU that is itself running on a real CPU? Turns out, not much. 

When you turn on a computer, the CPU knows to look in one specific location for its very first instruction. These instructions are a boot loader. These point to other locations to load special operating system files (for Windows or Linux). So you could easily write a program that emulates or simulates a CPU in this behaviour... you can write software the emulates _everything_ in a computer. 

That's all that virtualization is - an emulated computer running on a special virtualization platform that is running on a real computer. 

To answer your question about the essay tho... the answer is: it depends. When you write your essay and hit save, the essay is written to a physical hard disk or storage device. IN a virtual machine, the essay would be saved to a virtual hard disk/storage device, which itself is just a special file on the real storage that the virtualization software can understand. So yes, so long as they physical hardware that stores the virtual machine is ok, then yes you should be able to access the virtual storage as well. 

The nice thing about virtual machines is you can save their state at any time and restore back to it. We use virtualization at work in our testing all the time. We have a virtualized Windows PC, we install our software, the software was buggy, causes the virtual computer to crash, we wipe/restore the VM back to its known good state with a single instruction.

Old MS-DOS game emulators like DOSBOX? essentially these are virtual machines. Playstation or Gameboy emulators? virtual machines. Someone has just taken the time to write software that emulates the hardware of these old platforms.