Gaming Servers

FiveM Server Setup

Install and configure a FiveM GTA V multiplayer server on Linux with resources and basic configuration

FiveM is the most popular GTA V multiplayer framework by Cfx.re. This guide covers setting up a FiveM server on Linux from scratch.

Looking to secure an existing FiveM server? See the FiveM Security guide for DDoS protection, anti-cheat, and hardening tips.

Requirements

  • Ubuntu 22.04 / Debian 12 (64-bit)
  • 4 GB RAM minimum (8 GB recommended)
  • 20 GB disk space
  • Port 30120 TCP+UDP
  • A Cfx.re account and server license key
  • GTA V is not required on the server

Get a license key

  1. Go to keymaster.fivem.net
  2. Log in with your Cfx.re (FiveM) account
  3. Click New Server → register your server IP
  4. Copy the license key

Create a dedicated user

sudo useradd -m -s /bin/bash fivem
sudo su - fivem
mkdir -p /home/fivem/server
cd /home/fivem/server

Download the server artifacts

# Get latest recommended artifact URL
wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/LATEST-RECOMMENDED.tar.xz \
  -O fx.tar.xz
tar -xf fx.tar.xz
rm fx.tar.xz
ls -la

You should see run.sh, FXServer, and related files.


Download base resources

cd /home/fivem/server
wget https://github.com/citizenfx/cfx-server-data/archive/refs/heads/master.tar.gz \
  -O cfx-data.tar.gz
tar -xf cfx-data.tar.gz
mkdir -p resources
cp -r cfx-server-data-master/resources/* resources/
rm -rf cfx-data.tar.gz cfx-server-data-master

Create the server config

nano /home/fivem/server/server.cfg
# Basic settings
sv_hostname "My FiveM Server"
sv_maxclients 32
sv_licenseKey "YOUR_LICENSE_KEY_HERE"

# Network
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

# Game settings
set gametype "Freemode"
set mapname "FiveM"
sets tags "freemode, roleplay"

# RCON (admin console access)
rcon_password "ChangeThisRconPassword!"

# Disable OneSync for small servers (enable for 32+ players)
# set onesync off

# Base resources (required)
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure basic-gamemode
ensure hardcap
ensure baseevents

# Add your custom resources below
# ensure my-resource

Create the start script

nano /home/fivem/start.sh
#!/bin/bash
cd /home/fivem/server
exec ./run.sh +exec server.cfg
chmod +x /home/fivem/start.sh

Run as systemd service

exit
sudo nano /etc/systemd/system/fivem.service
[Unit]
Description=FiveM Server
After=network.target

[Service]
Type=simple
User=fivem
WorkingDirectory=/home/fivem/server
ExecStart=/home/fivem/start.sh
Restart=on-failure
RestartSec=15s
KillSignal=SIGTERM
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable fivem
sudo systemctl start fivem
sudo systemctl status fivem

Firewall

sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp

Install resources (scripts)

Resources are the FiveM equivalent of plugins. Place them in /home/fivem/server/resources/:

cd /home/fivem/server/resources

# Example: download a resource from GitHub
git clone https://github.com/example/my-resource [my-resource]

Add to server.cfg:

ensure my-resource

Restart or use RCON to start it:

rcon -H 127.0.0.1 -P 30120 -p "ChangeThisRconPassword!" "start my-resource"

RCON (admin console)

sudo apt install rcon -y

# Connect
rcon -H 127.0.0.1 -P 30120 -p "ChangeThisRconPassword!"

Useful RCON commands:

CommandDescription
statusList connected players with IDs
clientkick <id> <reason>Kick a player
ban <id> <reason>Ban a player
restart <resource>Restart a resource
refreshScan for new resources on disk
start <resource>Start a resource
stop <resource>Stop a resource
sv_maxclients <n>Change max players

Enable OneSync (32+ players)

OneSync is required for servers with more than 31 players. In server.cfg:

set onesync on

For 64+ player servers with population density:

set onesync on
set onesync_population true

Update the server

sudo systemctl stop fivem

sudo -u fivem bash -c '
  cd /home/fivem/server
  wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/LATEST-RECOMMENDED.tar.xz \
    -O fx.tar.xz
  tar -xf fx.tar.xz
  rm fx.tar.xz
'

sudo systemctl start fivem

Logs

journalctl -u fivem -f

On this page