commands
systemd-detect-virt — Detect virtualization
Reports a detected virtualization technology or none. Exit status zero means detected; a nonzero result needs interpretation. --vm and --container restrict the check. It is not proof of isolation. Use a fresh private workspace; live operations are VM-only.
Formal Syntax & Structure
linux syntaxlinux
systemd-detect-virt [OPTIONS]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| --vm | option | Restrict to VM detection |
| --container | option | Restrict to container detection |
Return Value
exit status and output
Reports a detected virtualization technology or none. Exit status zero means detected; a nonzero result needs interpretation. --vm and --container restrict the check. It is not proof of isolation.
Working Example
Example Snippetlinux
if systemd-detect-virt > virt.txt; then printf 'detected\n'; else printf 'not detected or error\n'; fi