A fairly straightforward way to do this - short of spinning up a VM - is to use a docker image, e.g.:
# use whatever ubuntu version you are targeting, although there may be pkg version differences:
$ docker run -it ubuntu:18.04
# using docker makes things like spin up/copying text/deleting images faster, but keep in mind a few gotchas: