If you're looking for a quick and safe way to test bash scripts, check out the multipass virtual machine orchestrator.

If you tend to cobble together your own Linux bash scripts for things like backups, security, or other data center needs, there might be times when you're hesitant to run that newly created script. What will it do? Might it erase crucial data? Could it possibly bring down that data center server?
Because of this, you might want an environment for which to test those scripts. That's where a tool like multipass comes in handy. Multipass is an open source tool that makes it easy to create, manage, and maintain virtual machines (VM). By creating a virtual machine, you sandbox those scripts such that running them cannot harm the host.
SEE: Hiring kit: Database administrator (Tech Pro Research)
I'm going to walk you through the process of installing and using multipass. The tool is installed via snap, so any Linux distribution that supports snap packages will work, so long as the operating system is installed on a machine that supports virtual environments. I'll demonstrate on Pop!_OS.
Installation
The first thing to do is install multipass. Open a terminal window and issue the command:
sudo snap install multipass --beta --classic
Once the command completes, you're ready to go.
Usage
The next step in this process is the creation of the virtual machine. Let's create one called test. This is done with the following command:
multipass launch --name test
Note: If the command refuses to launch, claiming it is not in your path, you might have to issue the command with the full path to the executable, like so:
/snap/bin/multipass --name test
When the command completes, you should see:
Launched: test
Log into your new virtual machine with the command:
multipass shell test
You should now find yourself in the VM with a completely different bash prompt (Figure A).
Figure A: Our test vm shell is now ready.
You can now create your script within this virtual machine shell and run it without endangering your production machine. When you're finished testing, exit out of the virtual environment with the command:
exit
To delete the virtual environment, issue the command:
multipass delete test
A simple solution
You could certainly go the route of running your bash script testing on a full-blown virtual machine (such as those created by VirtualBox or VMware), but multipass is a much faster solution, especially when you don't need all of the bells and whistles of a complete virtual environment.
Also see
- How to know who logged into your data center Linux servers (TechRepublic)
- How to find and kill zombie processes on your Linux data center servers (TechRepublic)
- How to change the default SSH port on your data center Linux servers (TechRepublic)
- How to monitor events on your Linux data center servers with auditd (TechRepublic)
- Cloud computing and AI: Can IBM finally catch the wave this time around? (ZDNet)
- Hyperconverged infrastructure: A cheat sheet (TechRepublic)
- 10 things companies are keeping in their own data centers (TechRepublic download)
- How hyperscale data centers are reshaping all of IT (ZDNet)
- Best cloud services for small businesses (CNET)
- DevOps: More must-read coverage (TechRepublic on Flipboard)