> For the complete documentation index, see [llms.txt](https://docs.linuxgsm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.linuxgsm.com/game-servers/fivem.md).

# FiveM

## Requirements

* A free Cfx.re server license key. Each server needs its own key.
* A copy of GTA V and the FiveM client to join the server.

LinuxGSM downloads the recommended Linux FXServer build from Cfx.re. The base resources come from the Cfx.re server data repository.

## First Start

1. Get a server key from the [Cfx.re portal](https://portal.cfx.re/servers/registration-keys).
2. Set `sv_licenseKey` in `serverfiles/server.cfg` before starting the server. Keep the key private.
3. Start the server with `./fivemserver start`. If the key is missing, LinuxGSM stops and shows the config file and portal link.

LinuxGSM starts FXServer with `+exec server.cfg`, so it runs without txAdmin. Use LinuxGSM to start, stop, monitor, update and back up the server. The txAdmin web panel is not started.

## Server Settings

Stop the server before editing:

```
serverfiles/server.cfg
```

| Setting                                | Description                                                |
| -------------------------------------- | ---------------------------------------------------------- |
| `sv_licenseKey`                        | Required Cfx.re server key.                                |
| `sv_hostname`                          | Server name.                                               |
| `sv_maxclients`                        | Player limit. More than 48 requires OneSync.               |
| `endpoint_add_tcp`, `endpoint_add_udp` | Listening addresses and ports. Use the same port for both. |
| `ensure`                               | Resources to start.                                        |

For additional FXServer start parameters, set `extraparams` in `lgsm/config-lgsm/fivemserver/fivemserver.cfg`. See [start parameters](https://docs.linuxgsm.com/configuration/start-parameters.md#extra-parameters).

## Ports

| Description                 | Port    | Protocol    |
| --------------------------- | ------- | ----------- |
| Game and server information | `30120` | TCP and UDP |

Change both `endpoint_add_tcp` and `endpoint_add_udp` in `server.cfg` when changing the port. Open both protocols in your firewall and publish both when using Docker. Give each instance a different port.

## Updates

`./fivemserver update` and `check-update` use Cfx.re's recommended Linux build. LinuxGSM keeps `server.cfg`, `resources/` and `run.sh` when updating FXServer. It fetches the base resources only when `resources/` is missing, so changes you make there remain in place.

## Resources

Put added resources under `serverfiles/resources/` and add an `ensure` line for each one to `server.cfg`. The default resources come from [cfx-server-data](https://github.com/citizenfx/cfx-server-data).

## Stopping

LinuxGSM uses [stop mode](https://docs.linuxgsm.com/features/stop-mode.md) 3, which sends `quit` to the FXServer console.

## Files

| Path                     | Contents                         |
| ------------------------ | -------------------------------- |
| `serverfiles/server.cfg` | Server settings and license key. |
| `serverfiles/resources/` | Base and added resources.        |
| `log/console/`           | LinuxGSM console logs.           |

{% hint style="warning" %}
Backups include `server.cfg` and its license key. Keep backup archives private.
{% endhint %}

## Server Resources

* [Cfx.re server setup](https://docs.fivem.net/docs/server-manual/setting-up-a-server-vanilla/)
* [Cfx.re server commands](https://docs.fivem.net/docs/server-manual/server-commands/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.linuxgsm.com/game-servers/fivem.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
