FiveM Server – Tutorial Ubuntu 19.04
- A Linux system running Ubuntu 19.04 with at least 1 CPU core and 2 GB of memory
- Non-root user on the system
Before we begin
To ensure your system is fully updated before proceeding with the installation, run the following commands:
sudo apt-get update
sudo apt-get upgrade
Also, make sure to open the following ports, as they are necessary for FiveM to function properly:
30120TCP & UDP
30110TCP & UDP
Ubuntu 19.04 ships with
UFW as the default firewall, you can open the necessary ports if you are using UFW by executing the following commands:
sudo ufw allow 30120
sudo ufw allow 30110
First, create an empty folder and navigate to it. This folder will hold all your FiveM server files.
Download the latest master branch build from the artifacts server. Copy the URL for the latest server version and use
wget <url> to download it to the created folder.
Once you’ve downloaded the build, extract it using the following command:
tar -xvf fx.tar.xz
This will extract all the necessary files.
Once you’ve successfully extracted the downloaded archive, you can now delete it.
Next clone the cfx-server-data repository to a new folder outside the server files folder. This folder will contain the default cfx server resources.
The command below will clone the repository to a new folder called
fivem_resources in your home directory.
git clone https://github.com/citizenfx/cfx-server-data ~/fivem_resources
Your server is now downloaded, but not ready yet.
Generate a FiveM license key, which is completely free and used for server identification. Use your favourite text editor to make a new file called
server.cfg in your
Populate it with the following content:
# Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only. endpoint_add_tcp "0.0.0.0:30120" endpoint_add_udp "0.0.0.0:30120" # These resources will start by default. ensure mapmanager ensure chat ensure spawnmanager ensure sessionmanager ensure fivem ensure hardcap ensure rconlog ensure scoreboard # This allows players to use scripthook-based plugins such as the legacy Lambda Menu. # Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won't be able to use external plugins. sv_scriptHookAllowed 0 # Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like rcon_password "YOURPASSWORD" #rcon_password "" # Set an optional server info and connecting banner image url. # Size doesn't matter, any banner sized image will be fine. #sets banner_detail "https://url.to/image.png" #sets banner_connecting "https://url.to/image.png" # Set your server's hostname sv_hostname "FXServer, but unconfigured" # Nested configs! #exec server_internal.cfg # Loading a server icon (96x96 PNG file) #load_server_icon myLogo.png # convars which can be used in scripts set temp_convar "hey world!" # FiveM Servers list details sets IP "server IP" sets Map "GTA V" sets tags "deathmatch,levels,fun,friends,events,missions,pvp,pve,kills" sets Locale "en-US" sets Language "English" # Uncomment this line if you do not want your server to be listed in the server browser. # Do not edit it if you *do* want your server listed. #sv_master1 "" # Add system admins add_ace group.admin command allow # allow all commands add_ace group.admin command.quit deny # but don't allow quit add_principal identifier.steam:110000100000000 group.admin # add the admin to the group # Hide player endpoints in external log output. sv_endpointprivacy true # Server player slot limit (must be between 1 and 32, unless using OneSync) sv_maxclients 32 # License key for your server (https://keymaster.fivem.net) sv_licenseKey replaceThisWithYourLicenseKeyCopy
This will be your server configuration file. On the last line of the configuration, there is a setting called
sv_licenseKey. Change this setting to your generated license key. Also, all configuration settings in the config have comments next to them so you can understand what each setting means and change it if you want.
Once you are finished, save the file and close the editor.
Starting the server
To start the server, you need to be in the server resources directory. Then you can start the server using the
runserver.sh script in the
fivem_server directory. Make sure to include the
+exec server.cfg parameters.
cd ~/fivem_resources && bash ~/fivem_server/run.sh +exec server.cfg
You can shutdown the server by pressing CTRL + C.
Running the server in background (optional)
To run the server in background, we’ll create a new screen session for the server to run in.
cd ~/fivem_resources && screen -s "FiveM server" bash ~/fivem_server/run.sh +exec server.cfg
If you want to exit out of the FiveM console press CTRL + A, then press D. You can reopen the window again by using the command
We can automate this by creating a bash script. Create a new file with the name of your choice and the extension
.sh. Open it in your favourite text editor.
Then paste the following script:
#/bin/bash cd ~/fivem_resources screen -s "FiveM server" bash ~/fivem_server/run.sh +exec server.cfg
Following this, mark the file as an executable by inputting the following command:
chmod +x startscript.sh
You can now start the server by executing the script:
Making the server start on boot (optional)
To make our server start on boot, we’ll make a new Linux service that will execute the server start script. This service will be called
fivem and start when your system boots up, starting the server.
Use your favorite editor to make a new file called
/lib/systemd/system/. This will require superuser privileges.
sudo nano /lib/systemd/system/fivem.service
Populate it with the following:
[Unit] Description=FiveM server [Service] Type=forking User=username ExecStart=/usr/bin/fivem_start.sh [Install] WantedBy=multi-user.targetCopy
Set your actual Linux username after
Save the file and close your editor.
Create a new file
/usr/bin/fivem_start.sh using your favourite text editor.
sudo nano /usr/bin/fivem_start.sh
Populate it with the following:
#!/bin/bash screen -dm bash -c 'cd /home/username/fivem_resources && bash /home/username/fivem_server/run.sh +exec server.cfg'
username with your Linux username. Save and close the file.
Mark the file as an executable by inputting the following command:
sudo chmod +x /usr/bin/fivem_start.sh
Run this command to reload the systemd manager configuration:
sudo systemctl daemon-reload
Start the service with this command:
sudo systemctl start fivem
Execute this command to make the service start on startup:
sudo systemctl enable fivem
Now you can restart your Linux server and the FiveM server will start automatically on boot. After rebooting login as the Linux account that you’ve installed the server as, and type the following command to open the console:
- If you don’t get any ‘resources found’, and it says ‘Failed to start resource’, you didn’t
cdto the right folder.
- If you get a lot of errors about
citizen:/scripting/, you didn’t use
- If nothing happens at all except
sending heartbeat, you didn’t use
run.shand failed to
cdto the folder.
- If no resources get started and you can’t connect, you didn’t add
- If you get
no license key was specified, one of the above applies.