Lima makes it easy to run a small Linux VM on macOS. This creates a Debian VM with two CPUs, 2 GiB of memory, and a 10 GiB disk.

1
2
3
brew install lima
limactl start --name=debian-dev --cpus=2 --memory=2 --disk=10 --tty=false template:debian
limactl shell debian-dev

Inside the VM, install a C compiler and lsb_release:

1
2
3
4
5
6
7
8
sudo apt update
sudo apt install -y build-essential lsb-release file

$ lsb_release -a
Distributor ID: Debian
Description: Debian GNU/Linux 13 (trixie)
Release: 13
Codename: trixie

Create and compile a hello world program:

1
2
3
4
5
6
7
8
9
10
11
12
cat > hello.c <<'EOF'
#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}
EOF

cc -Wall -Wextra -O2 -o hello hello.c
./hello

The executable is an AArch64 ELF binary, not a macOS Mach-O binary:

1
2
$ file hello
hello: ELF 64-bit LSB pie executable, ARM aarch64, ...

Exit the VM, then stop it when it is not needed:

1
2
exit
limactl stop debian-dev

Delete it completely with limactl delete debian-dev.

Finally, list all existing VMs and their status, architecture, and resources:

1
limactl list