Services are an integral part of Linux. They are processes or applications that run in the background, either as predefined tasks or in response to events. This offers many benefits, such as automatically starting the server at boot, automatic server updates, easy management, and access to logs. In this guide, we'll show you how to create a service for your dedicated game server.
First, connect to your Dedicated Server via SSH. If you need help, follow our SSH Initial Access guide.
You should also follow one of our dedicated game server guides in this section to install and set up a game server on your Linux system. In this guide, we'll use the Palworld Dedicated Game Server as an example, but you can adapt the steps for any of our guides.
Start by creating a new service file for your dedicated game server. Replace [your_game] with a suitable name. We recommend using the name of the game to keep things organized—in this case, palworld.service.
sudo nano /etc/systemd/system/[your_game].service
With the Nano editor open, copy the following basic content. This service file template can be reused. We've provided two versions: one for guides that use SteamCMD and one for games that don't use SteamCMD.
[Unit]
Description=[your_server] Server
Wants=network-online.target
After=network-online.target
[Service]
User=steam
Group=steam
WorkingDirectory=/home/steam/[your_server_folder]
ExecStartPre=/usr/games/steamcmd +force_install_dir '/home/steam/[your_server_folder]' +login anonymous +app_update [your_game_steamid] +quit
ExecStart=/home/steam/[your_server_folder]/[your_path_to_start_file]
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=[your_server] Server
Wants=network-online.target
After=network-online.target
[Service]
User=gameservers
Group=gameservers
WorkingDirectory=/home/gameservers/[your_server_folder]
ExecStart=/home/gameservers/[your_server_folder]/[your_path_to_start_file]
Restart=always
[Install]
WantedBy=multi-user.target
Here's a brief explanation of the key settings:
Description: Any description that helps you quickly identify the service's purpose.User: Our guides set up either thesteamuser for SteamCMD or thegameserversuser for games that don't use SteamCMD. If you're not following one of our guides, enter the user that should run the service here.WorkingDirectory: The path to the main directory containing all the files the service needs.ExecStartPre(SteamCMD only): Runs the SteamCMD installation command, which ensures the server is up to date every time it restarts. We recommend copying this from the relevant dedicated game server guide or replacing the values manually.ExecStart: The command that actually starts the server. Copy the path from the relevant guide or adjust it manually.
Wine compatibility
For games that require the Wine compatibility layer, add the xvfb-run and wine commands to the ExecStart parameter. Here's an example for V-Rising:
/usr/bin/xvfb-run wine /home/steam/V-Rising-Server/start_server.bat
Also make sure your ExecStartPre SteamCMD command includes the +@sSteamCmdForcePlatformType parameter if needed to force a platform version.
Once you've adjusted all the values for your dedicated game server, save the file by pressing CTRL + X, confirm with Y, and press ENTER to exit Nano.
Here's what the file looks like for our Palworld example:
[Unit]
Description=Palworld Server
Wants=network-online.target
After=network-online.target
[Service]
User=steam
Group=steam
WorkingDirectory=/home/steam/Palworld-Server
ExecStartPre=/usr/games/steamcmd +force_install_dir '/home/steam/Palworld-Server' +login anonymous +app_update 2394010 +quit
ExecStart=/home/steam/Palworld-Server/PalServer.sh
Restart=always
[Install]
WantedBy=multi-user.target
Once you've created the service file, you need to enable it. In this example, replace [your_service] with palworld for palworld.service.
sudo systemctl enable [your_service]
Whenever you make changes to the service file, run systemctl daemon-reload afterward to apply them.
Start the server with:
sudo systemctl start [your_service]
You can also stop or restart the server with:
sudo systemctl stop [your_service]
sudo systemctl restart [your_service]
To view service details, run:
systemctl status [your_service]
To troubleshoot using logs, run the following command to view the latest entries:
journalctl -u [your_service].service
If you no longer want the service to start automatically when the system boots, you can disable it:
sudo systemctl disable [your_service]