# Command line

```
qkvm                             # run it here, in this window, until it is stopped (Ctrl+C); `qkvm start` is the same
qkvm status                      # is a copy running with this data folder, since when, where does it listen, and how large are the history and the activity log
qkvm stop                        # end the copy that runs, from any window
qkvm restart                     # have it started again, where it runs
qkvm --restore FILE --backup-key KIT --data-dir NEW   # a wall back from its backup, into an empty folder (see Backups)
```

`status`, `stop` and `restart` are about the copy that already runs, whatever it was started
from: a window that has since been lost, or none at all (a task at log-on). They find it
also where it was started with `--data-dir`: qKVM notes such a folder in `.qkvm` in your home
folder (`elsewhere.json`) when it starts. With two walls running, or one that runs as another
user, say which: `qkvm stop --data-dir D:\qkvm-data`.

These three only look: they run nothing that lies in the folder they are asked about (not an
installed update either), make and change nothing in it, and take nothing a file in it says
at its word. `stop` and `restart` leave one small file there, which the running copy picks
up. That is also the whole of who may stop qKVM: **whoever can write to its data folder**,
and whoever can write there can change its files as well. Keep the
folder writable by the account qKVM runs as and by nobody else; qKVM says so at start when it
is not, with what to do, and runs no update from a folder others may write. What qKVM makes
is yours alone from its first moment: on Windows the data folder, `<data folder>.keys` beside
it (where the storage key is kept), the key and every file it writes in them are yours,
SYSTEM's and the Administrators'. A folder it finds is used as it is found and never changed,
by any command, on Windows as on Linux (made elsewhere, on another drive say, or reached
through a junction): every start says what it lets others do, with the line that changes it,
for you to run. On Windows the lines are for Command Prompt, and the start says so; where a path
holds a `$` or a backtick, which PowerShell would read as something else, it gives the
PowerShell form as well (each path in single quotes, a removal by PowerShell's own
`Remove-Item -LiteralPath`, a link by `[System.IO.Directory]::Delete`, never through `cmd /c`).
For a folder open to others:

```
icacls "D:\qkvm-data" /inheritance:r /grant:r "PC\you:(OI)(CI)F" "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-544:(OI)(CI)F"
```

with the account qKVM runs as in place of `PC\you`. It sets the folder's own entries, which
what is in it takes from it; it has no `/T`, which would follow a junction inside out of the
folder. An entry given on the folder itself stays through that line: the start names it and
gives its own, `icacls "D:\qkvm-data" /remove:g *S-1-5-...`. A link on the way (a junction to
the folder, say) is set by a line of its own with `/L`, the link and not where it leads, and
the folder it leads to by its own. A folder another account owns is that account's to change:
in an elevated console, `icacls "D:\qkvm-data" /setowner "PC\you"` gives it to the account
qKVM runs as, and `icacls "D:\qkvm-data" /grant "PC\you:F"` lets that account use it (owning a
folder or a file lets nobody read it by itself; where it is open to its owner by an entry for
OWNER RIGHTS, as Python makes a private folder and 0.2.0 made its data folder, Windows turns
that entry off when the owner is set);
`takeown /F "D:\qkvm-data"` gives it to the console's own; none goes into what is in it. Or run
qKVM as that account. A drive formatted FAT or exFAT keeps no permissions at all: keep
the data folder on NTFS.

Stopping it this way is the same as Ctrl+C: connections are closed, the log says so.
`qkvm status` ends with status 0 when qKVM runs and 3 when it does not, for a script. Where
a service manager or Docker starts qKVM, stop and restart it there: they would only start it
again.

And what it can be started with:

```
qkvm --data-dir D:\qkvm-data     # where settings live (default: .qkvm in your home folder)
qkvm --bind local,tailscale      # override where it listens: local, tailscale, lan, all or an IP
qkvm --port 9000
qkvm --setup-code                # first-run setup from another machine asks for a code printed here
qkvm --https                         # HTTPS from the first request, with a certificate made here
qkvm --tls-cert qkvm.pem --tls-key qkvm.key   # ...or with a certificate of your own
qkvm --tls-tailscale                 # ...and Tailscale's own for this computer's name.ts.net (see Over Tailscale or NetBird)
qkvm --allow-from 192.168.1.0/24    # answer these addresses only (and this computer)
qkvm --trusted-proxy 172.18.0.0/16   # a reverse proxy in front of qKVM (see How it is protected)
qkvm --unlock-file /etc/qkvm/unlock.key   # keep the key that carries it on after a restart here, not in the data folder
qkvm --locked-start                  # require sign-in after restart; the separate server storage key is still required
qkvm --vault-key-file /secure/qkvm.key # separate server storage key; back it up separately
qkvm --migrate-vault --vault-key-file /secure/qkvm.key # offline legacy migration
qkvm --verify-vault --vault-key-file /secure/qkvm.key  # offline paired data/key verification
qkvm --sso-header Remote-User        # sign in whoever the named proxy has signed in (see Accounts)
qkvm --audit-syslog collector.example   # send the activity log on to a syslog collector as it is written
qkvm --log-level debug           # debug, info (default), warning or error
qkvm --update-repo owner/name    # get updates from another GitHub repository
qkvm --allow-unsigned-updates    # only for a copy built without a release key (see Updates)
qkvm --roll-back                 # go back to the version before the last in-app update
qkvm --reset-password            # forget every account (and the saved KVM passwords)
qkvm --disable-2fa NAME          # switch two-factor sign-in off for one account
qkvm --version
```

`--bind` and `--port` take priority over what is saved in the app. `python -P -m qkvm` is the
same command, for where `qkvm` is not on the path. (`-P` keeps Python from looking for the
program in the folder the command is typed in before it looks where it was installed: without
it, a folder called `qkvm` lying there, or a file there with the name of one of Python's own,
would be run in its place.)

`qkvm` starts the program as a child process and watches it, which is what lets it restart
after an update. Closing or killing the starter stops it as well. Only one copy runs with a
data folder: a second one says which process holds it and since when, and how to stop it.
