Managing a FiveM Linux Server: Essential systemd Units, User Permissions, and Maintenance Commands

Managing a FiveM Linux Server: Essential systemd Units, User Permissions, and Maintenance Commands

Why Linux Is Preferred for Serious FiveM Hosting

Many community downtime incidents are not caused by flawed Lua code. They happen because staff members lack the terminal experience to restore service quickly when problems occur late at night. When running a FiveM server on Linux, your SSH terminal acts as your control panel. Knowing a core group of commands allows you to bring your environment back online in minutes rather than waiting hours for host support.

Server administrators choose Linux for three practical reasons. First, hosting costs are lower because Linux virtual private servers eliminate Windows Server licensing fees, often saving 10 to 25 Euros per month on equivalent hardware. Second, system efficiency is significantly higher without a desktop graphical user interface consuming extra RAM or triggering forced system restarts. A minimal Ubuntu or Debian installation can run smoothly for hundreds of days without interruption. Third, Cfx.re supplies native Linux artifacts through the build_proot_linux channel, eliminating the need for translation layers like Wine.

Understanding SSH and Terminal Control

Command-line access should not be intimidating. A virtual server is simply physical hardware located in a remote data center, and SSH serves as your remote keyboard interface.

ssh [email protected]

Every action taken inside the prompt directly alters the target system. Running ls queries directory contents, while executing systemctl restart fivem instructs the process manager to cycle the game instance. Mastering command line management removes guesswork and significantly accelerates maintenance tasks.

Service Automation: Setting Up systemd for FXServer

Launching run.sh inside terminal multiplexers like screen or tmux is a common shortcut, but it creates operational risks. If the underlying server reboots following automated updates, the process will not recover automatically. Utilizing systemd solves this problem by launching the application during host boot sequences and restarting it if the server crashes.

Create a service configuration file at /etc/systemd/system/fivem.service:

[Unit]
Description=FiveM server
After=network-online.target mariadb.service
Wants=network-online.target

[Service]
User=fivem
Group=fivem
WorkingDirectory=/home/fivem/server-data
ExecStart=/home/fivem/artifacts/current/run.sh +exec server.cfg
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Configuring Restart=on-failure along with RestartSec=10 ensures that FXServer restarts within ten seconds of an unhandled crash. If you rely on txAdmin for management, set ExecStart directly to run.sh without additional arguments so txAdmin can initialize configuration parameters automatically.

Activate and verify your service configuration with these commands:

sudo systemctl daemon-reload
sudo systemctl enable --now fivem
systemctl status fivem

The enable --now flag registers the service for system boot and starts it instantly. Always run daemon-reload after modifying unit files so systemd reads your latest changes. Tools like tmux remain valuable for interactive debugging, but primary process management should always rely on systemd.

Securing Your Server Environment with a Dedicated User

Every script and resource running on FXServer operates with the exact security rights of the hosting account. Executing your server under the root administrative account creates severe risks. A compromised or backdoor-infected script can gain complete control over your entire filesystem, database, and SSH security credentials. Isolating the environment under a restricted fivem account limits potential impact to that single user directory.

Configure isolated user permissions using the following setup:

sudo adduser --disabled-password --gecos "" fivem
sudo mkdir -p /home/fivem/artifacts /home/fivem/server-data
sudo chown -R fivem:fivem /home/fivem
sudo chmod -R u=rwX,g=rX,o= /home/fivem/server-data

In this context, chown assigns folder ownership while chmod manages operational permissions. Using an uppercase X grants navigation permissions on directories without granting executable rights to normal files. Switch to the isolated user using sudo -iu fivem and avoid applying broad chmod -R 777 permissions during troubleshooting. Indiscriminate permission relaxation weakens server security, whereas applying correct ownership back to fivem:fivem resolves most access issues safely.

15 Essential Terminal Commands for Daily Management

Maintaining a Linux server requires familiarizing yourself with a specific group of core utility tools:

  1. cd / ls -lah - Navigate directories and list contents with file sizes and ownership details.
  2. cp / mv - Duplicate, move, or rename files and folders.
  3. nano file - Make quick edits to configuration files directly inside your SSH session.
  4. less file - Paginate through large documents; press q to exit.
  5. tail -f file.log - Monitor log files live as new lines are appended.
  6. grep -i "text" file - Search for specific strings without matching case sensitivity.
  7. df -h - Check overall disk space across mounted filesystems.
  8. du -sh /home/fivem/server-data/* - Determine which directories consume the most disk space.
  9. htop - View real-time resource allocation and process CPU or RAM usage.
  10. systemctl status fivem - Verify whether the service is online and inspect recent log output.
  11. systemctl restart fivem - Safely trigger a full restart of the server unit.
  12. journalctl -u fivem -f - Stream incoming system console logs continuously.
  13. unzip pack.zip -d resources/[local]/ - Decompress archive files into specified paths.
  14. rsync -avP src/ dest/ - Transfer directory trees with progress monitoring and auto-resume.
  15. scp file fivem@host:/path/ - Send individual files directly over an SSH connection.

Combining these utilities simplifies standard operational tasks. To review today's runtime errors, execute:

journalctl -u fivem --since today | grep -i "error"

To locate where a specific framework event is registered across your installation:

grep -Rni "esx:setJob" /home/fivem/server-data/resources/

Running a recursive grep search across your resource folders provides instantaneous results without requiring manual text file searches.

Diagnosing Crashes and Memory Issues from Logs

When FXServer unexpectedly stops, review recent log entries by listing system messages backward from the failure point:

journalctl -u fivem -n 300 --no-pager

Entries immediately preceding the crash routinely highlight the cause, such as an unhandled script error loop, missing resource dependencies, or hitch warning spikes. If log generation stops abruptly without producing an explicit application error, check if the operating system terminated the server due to insufficient memory:

journalctl -k | grep -i "out of memory"

An Out of Memory (OOM) event indicates that hardware allocation is insufficient for your active resource load. Additionally, Linux artifact builds output crash minidumps within artifacts/current/alpine/opt/cfx-server/crashes/. While binary .dmp files require specialized analysis, attaching them to official bug reports provides valuable diagnostic details to core developers.

Safe Artifact Upgrades and Easy Rollbacks Using Symlinks

Avoid unpacking new FXServer artifact builds directly over existing files. Maintain individual build versions in dedicated directories and control your active installation using a symbolic link called current:

cd /home/fivem/artifacts
mkdir 17346 && cd 17346
wget "https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/<build-url>/fx.tar.xz"
tar xf fx.tar.xz && rm fx.tar.xz
cd .. && ln -sfn 17346 current
sudo systemctl restart fivem

Every build directory maintains its own distinct run.sh entry point and support dependencies. If a new artifact build introduces instability, revert immediately by updating the symbolic link target: ln -sfn 17285 current followed by restarting the service. Including the -n parameter prevents ln from placing new links inside existing target directories during replacement operations.

File Transfer, Firewall Setup, and Choosing Between VPS and Panels

Using browser file managers to move large content packages can lead to interrupted transfers. Utilizing rsync -avP or standard SFTP via client applications like WinSCP ensures file transfers can resume automatically if disconnected. Configure basic firewall rules to open necessary communication ports:

sudo ufw allow OpenSSH
sudo ufw allow 30120
sudo ufw enable

Always allow OpenSSH before enabling firewall services to prevent accidental locked SSH access. Managed web panels offer convenience for basic server administration, but self-managed virtual private servers deliver full administrative freedom, custom background tasks, and maximum resource efficiency. Selecting standalone FiveM resources, custom vehicles, ESX scripts, or QBCore scripts built for low performance overhead helps maintain clean server execution across all hosted environments.

More FiveM script guides

Fixing FiveM Server Boot Failures: Triage and Bisection Guide
Guide
Fixing FiveM Server Boot Failures: Triage and Bisection Guide
FiveM Server Monitoring: Uptime Tracking, Resource Trends and Outage Prevention
Guide
FiveM Server Monitoring: Uptime Tracking, Resource Trends and Outage Prevention
Configuring FiveM Server Restarts and Crash Recovery
Guide
Configuring FiveM Server Restarts and Crash Recovery
Guide published · Jul 02, 2026 Browse every FiveM article →