LinuxGSM (Linux Game Server Manager) is a command-line tool that installs and manages more than 100 dedicated game servers, including Valheim, Counter-Strike 2, Rust, Minecraft and 7 Days to Die. Every server gets the same set of commands for starting, stopping, updating, backing up and monitoring it, so once you know one, you know them all.

In this tutorial you will install LinuxGSM on Ubuntu 24.04, deploy a Valheim dedicated server as an example, configure it, and automate crash recovery, updates, backups and Discord alerts. The same steps apply to any other game LinuxGSM supports; only the server name changes.

Prerequisites

To follow this tutorial, you will need:

  • A server running Ubuntu 24.04, for example a CubePath VPS. Valheim needs at least 2 vCPUs and 4 GB of RAM; check the requirements of your game, since some (ARK, Rust) need 8 GB or more.
  • At least 20 GB of free disk space for the game files and backups.
  • A non-root user with sudo privileges and UFW enabled.
  • Optional: a Discord server where you can create a webhook for alerts.

Step 1 - Creating a dedicated user

LinuxGSM refuses to run as root, and each game server should run under its own unprivileged user. That user does not need sudo: you will install system packages with your admin account.

Create a user named after the server, which is the LinuxGSM convention:

sudo adduser --disabled-password --gecos "" vhserver

Because the account has no password, you switch to it from your admin user with sudo:

sudo -iu vhserver
whoami
vhserver

Type exit to return to your admin user for the next step.

Step 2 - Installing dependencies

Most game servers are downloaded with SteamCMD and include 32-bit binaries, so you need the i386 architecture and the multiverse repository, where Ubuntu ships SteamCMD:

sudo dpkg --add-architecture i386
sudo add-apt-repository -y multiverse
sudo apt update

Install the packages LinuxGSM and Valheim use:

sudo apt install -y curl wget file tar bzip2 gzip unzip zstd bsdmainutils python3 util-linux ca-certificates binutils bc jq tmux netcat-openbsd lib32gcc-s1 lib32stdc++6 libsdl2-2.0-0:i386 libatomic1 libpulse-dev steamcmd

During the steamcmd installation you are asked to accept the Steam license. Use the arrow keys and Enter to accept it.

Step 3 - Downloading LinuxGSM

Switch to the vhserver user and download the LinuxGSM bootstrap script into its home directory:

sudo -iu vhserver
curl -Lo linuxgsm.sh https://linuxgsm.sh
chmod +x linuxgsm.sh

List the supported games to find the short name of the one you want:

./linuxgsm.sh list | grep -i valheim

The output shows the script name (vhserver) next to the game name. Other common names are cs2server (Counter-Strike 2), rustserver (Rust), mcserver (Minecraft Java) and sdtdserver (7 Days to Die).

Create the Valheim management script:

./linuxgsm.sh vhserver

This creates an executable called vhserver in the home directory. From now on, every action on this server goes through it.

Step 4 - Installing the game server

Run the installer. It checks dependencies, downloads the server files through SteamCMD and creates the configuration files:

./vhserver install

The installer asks a few yes/no questions; the defaults are fine. The download takes a few minutes depending on the game size. When it finishes, the files are laid out like this:

PathContents
~/serverfiles/Game server files downloaded by SteamCMD
~/lgsm/config-lgsm/vhserver/LinuxGSM configuration for this server
~/log/Console and script logs
~/lgsm/backup/Backups created by the backup command

Step 5 - Configuring the server

LinuxGSM keeps its settings in three files inside ~/lgsm/config-lgsm/vhserver/:

  • _default.cfg contains every available setting with its default value. Do not edit it: it is overwritten on updates.
  • common.cfg applies to all instances of this game on the account.
  • vhserver.cfg applies only to this instance. This is where your changes go.

Look up the setting names Valheim uses:

grep -E '^(servername|serverpassword|port|public)=' ~/lgsm/config-lgsm/vhserver/_default.cfg

The output shows each setting with its default value. Open the instance configuration:

nano ~/lgsm/config-lgsm/vhserver/vhserver.cfg

Add the settings you want to override, using your own values:

servername="Your Server Name"
serverpassword="your_server_password"
port="2456"
public="1"

Valheim requires a password of at least 5 characters, and the password must not appear in the server name. Settings you leave out keep the value from _default.cfg.

Before starting the server, exit back to your admin user and open the game ports. Valheim uses UDP 2456 and 2457:

exit
sudo ufw allow 2456:2457/udp
sudo ufw status

Step 6 - Starting and checking the server

Switch back to the game server user and start it:

sudo -iu vhserver
./vhserver start

LinuxGSM runs the server inside a tmux session, so it keeps running after you log out. Check the state, ports and configuration with:

./vhserver details

The output includes the server name, the password, the ports in use and a status line that should read STARTED. Valheim takes a minute or two to generate the world on first start.

To watch the live console, use:

./vhserver console

To leave the console without stopping the server, press Ctrl+b and then d. Pressing Ctrl+c inside the console stops the server.

Once the server has finished loading, join it from the game using your_server_ip:2456 and the password you set.

Step 7 - Learning the everyday commands

All LinuxGSM scripts share the same commands. Each has a short alias:

CommandAliasWhat it does
startstStart the server
stopspStop the server
restartrRestart the server
detailsdtShow configuration, ports and status
consolecAttach to the live console
monitormCheck the server and restart it if it has crashed
updateuUpdate the game server if a new build exists
check-updatecuOnly check whether an update is available
validatevVerify and repair game files with SteamCMD
backupbCreate a compressed backup
update-lgsmulUpdate LinuxGSM itself
test-alerttaSend a test alert
debugdRun the server in the foreground to see startup errors

Run ./vhserver without arguments to see the full list for your game.

Step 8 - Automating monitoring, updates and backups

LinuxGSM does not run anything in the background by itself. You schedule its commands with cron under the game server user. Open that user's crontab:

crontab -e

Add the following lines:

# Restart the server if it has crashed
*/5 * * * * /home/vhserver/vhserver monitor > /dev/null 2>&1
# Check for game updates and apply them (restarts the server only if needed)
*/30 * * * * /home/vhserver/vhserver update > /dev/null 2>&1
# Update LinuxGSM once a week
0 0 * * 0 /home/vhserver/vhserver update-lgsm > /dev/null 2>&1
# Daily backup at 05:00
0 5 * * * /home/vhserver/vhserver backup > /dev/null 2>&1
# Start the server after a reboot
@reboot /home/vhserver/vhserver start > /dev/null 2>&1

Confirm the jobs are installed:

crontab -l

With the default stoponbackup="on" setting, the backup command stops the server while it archives the files and starts it again afterwards, so schedule it at a quiet hour. You can control retention in vhserver.cfg:

maxbackups="7"
maxbackupdays="14"

Create a first backup manually to check that it works:

./vhserver backup
ls -lh ~/lgsm/backup/

To see what a backup contains before restoring it, list its files:

tar -tf ~/lgsm/backup/backup_file_name | head

To restore, stop the server, extract the archive over the home directory with tar -xf, and start it again.

Step 9 - Configuring Discord alerts

LinuxGSM can notify you when the monitor restarts a crashed server or when an update is applied. It supports several services; Discord is one of the simplest to set up.

In Discord, open Server Settings > Integrations > Webhooks, create a webhook for the channel you want and copy its URL. Then add these lines to vhserver.cfg:

discordalert="on"
discordwebhook="https://discord.com/api/webhooks/your_webhook_id/your_webhook_token"

Send a test message:

./vhserver test-alert

A message from LinuxGSM should appear in the Discord channel within a few seconds. Other alert services (email, Telegram, Slack, Pushover and more) are listed with their settings in _default.cfg.

Troubleshooting

The server does not start or stops immediately. Run it in the foreground to see the error:

./vhserver debug

Press Ctrl+c to exit debug mode. Common causes are a missing dependency (install what LinuxGSM reports), a port already in use, or a password that is too short.

Players cannot find or join the server. Check that the ports are open with sudo ufw status and that the server is listening with sudo ss -ulnp | grep 2456. If you run the server behind another firewall, open UDP 2456-2457 there too.

The server runs out of memory. Check memory use with free -h. If the kernel killed the process, sudo journalctl -k | grep -i "out of memory" shows it. Move to a plan with more RAM or add swap.

Game files are corrupted after an interrupted update. Stop the server and repair the files:

./vhserver stop
./vhserver validate
./vhserver start

Conclusion

You now have a Valheim dedicated server managed by LinuxGSM on Ubuntu 24.04, running as an unprivileged user, restarted automatically if it crashes, kept up to date, backed up daily and reporting to Discord.

To host another game, create a new user and repeat the process with its server name, for example cs2server. To run a second instance of the same game on one account, run ./linuxgsm.sh vhserver again: LinuxGSM creates vhserver-2 with its own configuration file, where you set a different port. Finally, copy the backups off the server so a disk failure does not take your worlds with it.