# Use a Linux machine

Programs in a Linux machine run as root unless you name an account, and x86_64 programs run through Rosetta.

## Run programs

To run a program as root, then as your own account:

```sh
osmates vm exec dev -- uname -a
osmates vm exec dev --user "$USER" -- sh -c 'echo $HOME'
```

To log in with ssh, see [Connect with ssh and forward ports](https://osmates.com/docs/ssh#reach-a-machine-with-ssh). To move files, see [Copy files and share folders](https://osmates.com/docs/files).

## Add a display

The `debian-13`, `ubuntu-26.04`, and `fedora-44` images make servers with a console only, which the library marks Headless. For a screen, keyboard, and pointer, add a display when you create the machine:

```sh
osmates vm create desk --display 1600x900
```

For Retina and 3D acceleration, see [Displays and 3D in Linux](https://osmates.com/docs/linux-graphics).

## Run x86_64 programs with Rosetta

Rosetta runs x86_64 programs in a Linux machine on Apple Virtualization. It's off on new machines, and the OSMates engine has none.

1. Shut the machine down.
2. Choose **Machine > Machine Settings**, then click **Hardware**.
3. Turn on **Run x86_64 Programs with Rosetta**, then start the machine.

In Terminal, run `osmates vm set dev --rosetta`. `osmates vm info dev` shows whether the guest set it up, or why this Mac can't.

Statically linked programs run as they are. Others need x86_64 libraries in the guest, which a container brings: `podman run --platform linux/amd64` runs an x86_64 image.

The guest agent registers Rosetta at each boot. Without the guest agent, run this as root in the guest:

```sh
mkdir -p /media/rosetta
mount -t virtiofs -o ro rosetta /media/rosetta
printf '%s' ':rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/media/rosetta/rosetta:PCF' > /proc/sys/fs/binfmt_misc/register
```

## Use Secure Boot

Debian 13 and Ubuntu 26.04 start with Secure Boot on, as does any image with a boot loader Microsoft signed in 2011. Fedora 44's loader has only Microsoft's 2023 signature, so Fedora 44 starts with Secure Boot off and can't start with it on. The OSMates engine has no Secure Boot.

With it on, most distributions load only signed kernel modules, so DKMS modules you build don't load. To check the state, run `mokutil --sb-state` in the machine.

1. Shut the machine down.
2. Choose **Machine > Machine Settings**, then click **Hardware**.
3. Turn **Secure Boot** off or on, then start the machine.

In Terminal, run `osmates vm set dev --no-secure-boot`, or add `--no-secure-boot` to `vm create`. If the window shows a firmware or shim message instead of Linux, turn Secure Boot off.

### Load a module you signed

1. In the machine, run `sudo mokutil --import key.der`, and set a one-time password.
2. Restart the guest. The machine stops.
3. Start the machine and open its window. Enroll the key in MokManager with that password.
4. Choose **Reboot** in MokManager. The machine stops again.
5. Start the machine. Modules signed with your key now load.

MokManager needs a display. Without one, turn Secure Boot off instead.

## If the kernel panics

A kernel panic that doesn't recover leaves the machine failed. To read the message:

```sh
osmates vm events dev
osmates vm logs dev --source console
```

Library images log kernel messages from their second boot. If the log has none, see [Linux console log has no kernel messages](https://osmates.com/docs/known-issues#linux-console-log-has-no-kernel-messages).
