# Setting up a FiveM server on Linux (Ubuntu and Debian)

> Set up a FiveM server on Ubuntu or Debian: install xz-utils, extract the Linux artifacts, run run.sh for txAdmin on 40120, then add a systemd service.

Source: https://fam-tools.com/guides/fivem-linux-server-setup · FAM Tools · published 2026-09-11 · updated 2026-09-11 · about 13 min

**Short answer.** Install `xz-utils` and `curl`, create a `fivem` user, download the latest recommended Linux artifacts (`fx.tar.xz`) from the Cfx runtime server, extract them, and run `./run.sh` to start txAdmin on port 40120. Open ports 30120 TCP/UDP (and 40120 for txAdmin, ideally restricted) in the firewall, then create a systemd service so the server restarts on boot and crash.

## Key points

- Never run the server as root — use a dedicated user.
- Linux artifacts come as `fx.tar.xz`; extract with `tar xf`.
- `./run.sh` starts the server (and txAdmin on first run).
- Open 30120 TCP and UDP; protect 40120.
- A systemd unit keeps it running after reboots.

Linux is the most common home for FiveM servers on a VPS or dedicated machine: it is free, stable and light. The setup is a handful of commands — download the artifacts, run txAdmin once, and make the server start by itself. This guide uses Ubuntu or Debian and a dedicated user so the server never runs as root.

## Step 1: prepare the machine

*As root (or with sudo)*

```bash
apt update && apt -y upgrade
apt -y install xz-utils curl git screen
adduser --disabled-password --gecos "" fivem
su - fivem
```

## Step 2: download the artifacts

Pick Linux and Recommended on the Cfx server download page and copy the `fx.tar.xz` link it gives you. The old browsable listing of every build is gone — individual builds still resolve by URL, but the page is now the way in.

*As the fivem user*

```bash
mkdir -p ~/server && cd ~/server
curl -L -o fx.tar.xz "<paste the fx.tar.xz link of the recommended build>"
tar xf fx.tar.xz
rm fx.tar.xz
ls   # you should see run.sh and alpine/
```

> **Linux is a courtesy port** — Cfx.re builds FXServer for Windows first and describes the Linux build as a courtesy port: if you hit a native crash, it is more likely to be fixed on Windows. Linux still runs most servers fine. For FiveM for GTAV Enhanced the archive is named `cfx-server-linux_x64`.

## Step 3: first run and txAdmin

```bash
cd ~/server
./run.sh
```

txAdmin starts and prints its address and a PIN. Open `http://<your-server-ip>:40120`, enter the PIN and complete the setup — see [the txAdmin setup guide](https://fam-tools.com/guides/txadmin-setup-guide). txAdmin keeps its own data (admins, player database, settings) in a `txData` folder; the path is printed in the console when it starts.

## Step 4: the firewall

*ufw example (as root)*

```bash
ufw allow 22/tcp
ufw allow 30120/tcp
ufw allow 30120/udp
# txAdmin only from your own IP:
ufw allow from <your.home.ip> to any port 40120 proto tcp
ufw enable
```

Port details and why each is needed are in [ports and firewall](https://fam-tools.com/guides/fivem-server-ports-firewall).

## Step 5: start on boot with systemd

*/etc/systemd/system/fivem.service*

```ini
[Unit]
Description=FiveM server (txAdmin)
After=network-online.target mariadb.service
Wants=network-online.target

[Service]
User=fivem
WorkingDirectory=/home/fivem/server
ExecStart=/home/fivem/server/run.sh
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
```

*As root*

```bash
systemctl daemon-reload
systemctl enable --now fivem
journalctl -u fivem -f   # follow the output
```

> **txAdmin restarts the game server** — systemd keeps txAdmin (and therefore the server process) alive; txAdmin itself handles scheduled restarts and crashes of the game server inside it.

## Updating artifacts

1. Download the new `fx.tar.xz` next to the old one.
2. Stop the service, move the old `alpine/` and `run.sh` aside, extract the new archive.
3. Start the service and check the console; roll back by restoring the old files if needed.

Which build to choose and why “recommended” matters is in [artifacts and updates](https://fam-tools.com/guides/fivem-artifacts-and-updates).

## Questions

### Can FiveM run on Linux?

Yes. The server has native Linux builds; download `fx.tar.xz` from the Cfx runtime server’s Linux artifacts and run `./run.sh`.

### Which Linux distribution should I use?

Ubuntu LTS or Debian are the common, well-documented choices.

### Should I run FiveM as root?

No. Create a dedicated user; a compromised resource then cannot take over the whole machine.

### How do I keep the server running after I close SSH?

Use a systemd service (or screen/tmux for quick tests).

### Which ports does a Linux FiveM server need?

30120 TCP and UDP for players, and 40120 TCP for txAdmin (restrict it to your IP).

## Related

- https://fam-tools.com/guides/txadmin-setup-guide
- https://fam-tools.com/guides/fivem-server-ports-firewall
- https://fam-tools.com/guides/fivem-artifacts-and-updates
- https://fam-tools.com/guides/fivem-mariadb-database-setup
