# Command line

The server is one Java program, and what it does depends on the first word after its name:

```bash
java -jar CrushMFT.jar -d
```

Run it in the server's folder, as the account the server runs as. On most installations you never type these: the service, the start script and the control panel do. This page is for scripts, for repairs, and for knowing what a service line means.

Upper and lower case do not matter in the first word.

## Running the server

| Command | Does |
|---|---|
| no word at all | opens the control panel, on macOS and Windows: "the service, memory, admin users, a temporary server, thread dumps and logs" |
| `-d` | runs the server, with no window of any kind. This is what a service runs. A number after it makes the server wait that many seconds before it starts. |
| `-dmz 9000` | runs as a DMZ server that takes its orders on port 9000: see [DMZ](DMZ.md) |
| `-dmz_unpair` | run in a DMZ server's folder while it is stopped: it forgets the servers it was paired with, and shows a new code at its next start. See [Pairing a DMZ](DMZ-Pairing.md). |
| `-v` | prints the version and ends |
| `-?`, `-help` | prints a short list of commands and ends |

On Linux the start script wraps these: `crushmft_init.sh start`, `stop`, `restart`, `status`, `install`, `uninstall`.

### Words that go with a start

| Word | Does |
|---|---|
| `-UNSIGNED` | the server loads the program files that lie in its folder without checking that they are its own signed ones. For a developer's own build, and for support. It can only be given here, on the line that starts the server; no setting turns it on. Every start with it is written to the log. See [Writing a plugin](Plugins-Writing-Your-Own.md#getting-it-loaded). |

Java's own options go before `-jar`: the most memory (`-Xmx2g`), and `-Dcrushmft.fips=true` for [FIPS mode](FIPS-Mode.md). In the Linux start script they are the line `JAVA_OPTS`; on Windows and macOS the launcher's `.conf` file holds them.

## The service

| Command | Does |
|---|---|
| `-i` | installs the service, on Windows and macOS. On Windows a number after it is the memory in megabytes. |
| `-r` | removes the service, on Windows and macOS |
| `-dmzi` | installs the service so that it runs as a DMZ server |

On Linux use `crushmft_init.sh install` and `uninstall`.

## Users, from the command line

For the day nobody can log in to the admin pages.

| Command | Does |
|---|---|
| `-a name password` | makes a user with full administrator rights, in the server's first connection group. Put each word in quotes. A running server finds the new user when they first log in. |
| `-u name password folder permissions template notes email` | makes an ordinary user with one folder. The folder is written with forward slashes and ends in one: `"/data/acme/"`. Permissions are `FULL`, `READ_ONLY`, or the rights written out. The template is a user whose settings are copied; `""` for none. |
| `-p format password` | prints a password in its stored form, to paste into a file. The format is `DES` or `SHA`. `RANDOM_12` in the place of the password makes one of 12 characters and prints it. In FIPS mode it prints the form that mode uses. |

A password typed on a command line is in the shell's history and, for a moment, in the list of running programs. Change it in the admin pages afterwards.

## The licence

| Command | Does |
|---|---|
| `-reg name email code` | enters a licence |

## Checks before FIPS mode

| Command | Does |
|---|---|
| `-FIPS_CHECK` | reads the server's folder and reports what would stop it from starting in [FIPS mode](FIPS-Mode.md). It changes nothing. It ends with 0 when all is ready, 1 when something blocks, 2 when it could not run. |
| `-FIPS_PREPARE` | with the server stopped: writes the copies of the keystores that FIPS mode reads. It changes no setting. |

Both are run without `-Dcrushmft.fips=true`.

## Repairs across all users

Each takes the name of a connection group, the folder under `users`: `MainUsers` on most servers. Stop the server first, and back up the `users` folder.

| Command | Does |
|---|---|
| `-verifyusersvfs MainUsers` | checks every user's folders file and reports those that cannot be read. With `fix` after the group, it repairs what it can. |
| `-cleanupbadvfs MainUsers` | reports folder entries of users that are broken. With `true` after the group, it removes them; without, it only reports. |
| `-hashpasswords MainUsers` | turns stored passwords that can be decrypted into hashes that cannot. A hash kind can follow the group. |
| `-togglevfsencryption MainUsers encrypt` | encrypts the addresses of every user's folders in their files; `decrypt` turns that back |
| `-togglejoburlencryption encrypt` | the same for the addresses inside jobs; `decrypt` turns that back |

Run the reporting form first and read what it says.

## Tests of the machine

For finding a limit of the operating system, with support.

| Command | Tests |
|---|---|
| `-test_threads` | how many threads the system lets one program start |
| `-test_openfiles` | how many files it lets one program hold open |
| `-test_disk 1 10000 ./` | how fast a disk writes: a size, a count, and the folder to write in |
| `-test_ephemereal 6000 5` | connections to a port, to find limits on outgoing ports: a port and a count |
| `-test_gc_sockets` | how the system frees connections |

## Words the server uses for its own parts

You will see these in the list of running programs. They are started by the server itself, not by hand.

| Word | Is |
|---|---|
| `-jobs`, `-job_orchestrator`, `-job_engine`, `-job_runner` | the parts that run jobs: see [Job engines](Jobs-Engines.md) |
| `-panel_engine` | the control panel's helper |
| `-sbd` | ServerBeat's watchdog: "if session.obj file stops having date updated for 10 seconds, release our VIP". See [ServerBeat](ServerBeat.md). |

## Exit codes a service looks at

| Code | Means |
|---|---|
| 64 | the server asks to be started again: a restart from the admin pages |
| 78 | FIPS mode was asked for and could not start. The service does not start it again; fix what `-FIPS_CHECK` names. |

## Not tried for this page

The commands are read from the server's code and its own help text. `-v` and the server's normal start were run on test servers in the course of writing this wiki; the repair and test commands were not run.
