RE:NODE

LinuxGSM vhserver: Valheim server install and commands

By RE:NODE Team
13 min read


LinuxGSM's vhserver is a ready-made management script for a Valheim dedicated server on Linux. You create a vhserver user, download linuxgsm.sh, run bash linuxgsm.sh vhserver and then ./vhserver install, and you get one command that installs the server through SteamCMD, starts it inside a tmux session, stops it cleanly, checks Steam for updates, archives backups, restarts it if it dies and sends alerts to Discord or email. Settings go in lgsm/config-lgsm/vhserver/vhserver.cfg, never in _default.cfg. Three cron lines - monitor every five minutes, update every thirty, update-lgsm weekly - turn it into a server that mostly looks after itself. The price is a layer of shell script between you and the game, and a vhserver that updates itself is the wrong default for a modded world.

This post covers the install, the config files and the variables that matter, every command you will use, the cron schedule, backups and alerts, mods, and an honest comparison with a plain start script under systemd.

What LinuxGSM is and what it does for Valheim#

LinuxGSM (Linux Game Server Managers) is an open-source collection of Bash scripts that manage well over a hundred dedicated servers with the same commands. vhserver is its Valheim module. It does not replace the game server or change how it works: underneath, it still installs Steam app 896660 with an anonymous login and runs valheim_server.x86_64 with the same launch arguments you would type yourself. What it adds is the operational shell around that:

  • Install and dependency checks. It tells you which packages are missing for your distribution and installs SteamCMD for the user.
  • A tmux session per server. The server runs detached; ./vhserver console attaches to it.
  • Update checks. It compares the installed build with the current one on Steam and only stops the server when there is something to install.
  • Backups. Compressed archives with a count and age limit.
  • Monitoring. A check that the server is running and answering, with a restart and an alert if not.
  • Alerts. Discord, email, Telegram, Slack, Pushover and others, configured in one file.
  • Details. ./vhserver details prints the ports, the password, the paths and the start line in one place.

Valheim has no configuration file of its own - every setting is a launch argument - so LinuxGSM's config file is effectively the server's config file. If you have not seen the arguments before, the Valheim launch arguments reference lists them all with their defaults.

Installing vhserver#

LinuxGSM supports the common server distributions; Ubuntu LTS and Debian stable are the ones most people run. Do everything as a dedicated, unprivileged user - LinuxGSM refuses to run as root.

bash
$ sudo adduser vhserver$ sudo su - vhserver$ curl -Lo linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh$ bash linuxgsm.sh vhserver$ ./vhserver install

The install step checks dependencies first. If anything is missing it prints the exact sudo apt install line for your distribution and stops; run that from a user with sudo rights, then run ./vhserver install again. On 64-bit Debian and Ubuntu the list includes 32-bit libraries for SteamCMD, which means dpkg --add-architecture i386 has to have been run - the printed instructions include it when it is needed. The package list changes between LinuxGSM releases and distribution versions, so copy it from the installer's output or from the vhserver page on linuxgsm.com rather than from an old guide.

The installer then downloads the server into ~/serverfiles, about 2 GB, and asks a couple of questions. ./vhserver auto-install answers them with defaults, which is the version to use in a provisioning script.

When it finishes, the home directory looks like this:

PathWhat it holds
~/vhserverThe command you run for everything
~/serverfiles/The Valheim server from SteamCMD
~/lgsm/config-lgsm/vhserver/LinuxGSM config files for this server
~/lgsm/backup/Backup archives
~/log/Console and LinuxGSM script logs
~/.config/unity3d/IronGate/Valheim/Worlds and the admin, ban and permitted lists

The last row is Valheim's own default save directory, not LinuxGSM's. Worlds sit in worlds_local inside it, and adminlist.txt, bannedlist.txt and permittedlist.txt sit next to that folder. Where Valheim keeps its files covers what changes if you set -savedir.

The config files and the variables that matter#

LinuxGSM reads three files in order, each overriding the one before:

  1. _default.cfg - every variable with its default. Overwritten when LinuxGSM updates itself. Read it, never edit it.
  2. common.cfg - settings shared by every LinuxGSM server under this user, such as alert credentials.
  3. vhserver.cfg - settings for this one instance. This is where your changes go.

The usual mistake is editing _default.cfg, seeing the change work, and losing it at the next update-lgsm. Copy the lines you want to change from _default.cfg into vhserver.cfg and edit them there:

lgsm/config-lgsm/vhserver/vhserver.cfg
servername="Longship Crew"serverpassword="herring-barrel-42"port="2456"gameworld="Midgard"public="1"

The variable names above are the ones the vhserver defaults have used for a long time, and the start line is assembled from them in a variable called startparameters. Names occasionally change between LinuxGSM releases, so open your own _default.cfg and copy from it rather than trusting any guide, this one included:

bash
$ grep -nE '^(servername|serverpassword|port|gameworld|public|startparameters)=' \    ~/lgsm/config-lgsm/vhserver/_default.cfg

To add arguments the predefined variables do not cover - crossplay, a save interval, world modifiers - copy startparameters into vhserver.cfg and extend it. Keep the variable references so the simple settings above still work:

lgsm/config-lgsm/vhserver/vhserver.cfg
startparameters="-name '${servername}' -password '${serverpassword}' -port ${port} -world '${gameworld}' -public ${public} -crossplay -saveinterval 900 -backups 4 -preset casual"

If your _default.cfg already has a dedicated crossplay setting, use that instead of adding the flag by hand. Afterwards, ./vhserver details prints the resolved start line, which is the quickest way to confirm the quoting survived.

The game's own rules still apply on top of LinuxGSM's: the query port is always the game port plus one, so port="2456" means UDP 2456 and 2457 must be reachable. Valheim ports 2456-2458 explained has the firewall rules.

The commands you will use#

Every command has a short form, shown in brackets in LinuxGSM's own help. ./vhserver with no argument prints the full list for your version.

CommandShortWhat it does
startstStarts the server in a tmux session
stopspStops it gracefully, so the world saves
restartrStop then start
detailsdtPorts, password, paths, the start line, status
consolecAttaches to the tmux session
monitormChecks the server is up; restarts it if not
updateuUpdates the server if Steam has a newer build
check-updatecuReports whether an update exists, changes nothing
force-updatefuUpdates even if the build looks current
validatevVerifies the server files against Steam
backupbCreates a backup archive
update-lgsmulUpdates LinuxGSM's own scripts
test-alerttaSends a test message to configured alerts
debugdRuns the server in the foreground for troubleshooting
mods-installmiLists and installs mods LinuxGSM knows about

Two of these deserve a warning. console attaches you to the live server process; leave it with Ctrl+b then d. Pressing Ctrl+C in the console sends the interrupt to the server and stops it - LinuxGSM prints this warning when you attach, and people still do it. Valheim reads nothing from standard input, so the console is for watching, not for typing commands; admin commands are run from the game client's F5 console by players in adminlist.txt.

validate overwrites changed game files with Steam's copies. That includes start_server.sh and, on a modded install, can undo files BepInEx relies on. Run it when you suspect corruption, not as routine.

debug is the command to reach for when start reports success and the server is not there. It runs the server in your terminal with output visible, so the error that a detached session hid scrolls past in front of you. The usual suspects - a password rule violation, a port in use, a missing library, a world that will not load - are covered in Valheim server crashes on start.

Cron: monitor, updates and LinuxGSM itself#

LinuxGSM does nothing on a schedule by itself; you add cron jobs for the vhserver user with crontab -e. The set LinuxGSM's documentation recommends, plus a nightly backup and a weekly restart:

crontab -e (as vhserver)
*/5 * * * * /home/vhserver/vhserver monitor > /dev/null 2>&1*/30 * * * * /home/vhserver/vhserver update > /dev/null 2>&10 0 * * 0 /home/vhserver/vhserver update-lgsm > /dev/null 2>&115 5 * * * /home/vhserver/vhserver backup > /dev/null 2>&10 5 * * 1 /home/vhserver/vhserver restart > /dev/null 2>&1@reboot /home/vhserver/vhserver start > /dev/null 2>&1

What each line buys you:

  • `monitor` every five minutes. If the tmux session is gone, or the server stops answering its query port, LinuxGSM restarts it and sends an alert. This is the line that replaces systemd's restart-on-failure.
  • `update` every thirty minutes. Checks Steam for a new build. If there is one, it stops the server cleanly, updates and starts it again. On a vanilla server this means a Valheim patch is applied within half an hour, before most of your players have launched the updated client.
  • `update-lgsm` weekly. Keeps the scripts current. Your vhserver.cfg is untouched; _default.cfg is replaced, which is why you never edit it.
  • `backup` nightly and `restart` weekly, at hours nobody plays. Monday's backup runs fifteen minutes after the restart. Restart schedules that help explains why weekly is usually enough for Valheim.
  • `@reboot` starts the server when the machine boots. The alternative is a systemd unit, below.

Cron runs jobs with a minimal environment. Use full paths, as above, and if a job seems to do nothing, run the same line by hand as the vhserver user and read ~/log/script/. The five-field syntax is in cron expressions explained.

Starting at boot with systemd instead of @reboot#

@reboot works, but it does not stop the server cleanly when the machine shuts down - the tmux session is simply killed with everything else. A small systemd unit that calls LinuxGSM's own start and stop fixes that:

/etc/systemd/system/vhserver.service
[Unit]Description=LinuxGSM vhserverWants=network-online.targetAfter=network-online.target[Service]Type=forkingUser=vhserverWorkingDirectory=/home/vhserverRemainAfterExit=yesExecStart=/home/vhserver/vhserver startExecStop=/home/vhserver/vhserver stopTimeoutStopSec=180Restart=no[Install]WantedBy=multi-user.target

Restart=no is deliberate: crash recovery stays with monitor, and you do not want two supervisors fighting over the same process. With this unit enabled, drop the @reboot cron line. If you would rather skip LinuxGSM and let systemd supervise the server directly, running Valheim as a systemd service builds that unit from scratch.

Backups and alerts#

./vhserver backup writes a compressed archive to ~/lgsm/backup/. It archives the LinuxGSM directory, which in a default install is the vhserver home directory, minus the backup folder itself - so the world files under ~/.config/unity3d/IronGate/Valheim come along. Confirm that on your own install before you depend on it:

bash
$ ./vhserver backup$ ls -lh ~/lgsm/backup/$ tar -tzf ~/lgsm/backup/vhserver-*.tar.gz | grep -E 'worlds_local/.*\.(db|fwl)$'

If that last command prints your world files, the backup contains what matters. If it prints nothing, your saves live outside the archived tree - usually because of -savedir - and you need a separate copy.

The behaviour is controlled by variables you can override in vhserver.cfg. Check the names and defaults in your _default.cfg; the ones that matter are a maximum number of archives to keep (maxbackups), a maximum age in days (maxbackupdays), and whether to stop the server while archiving (stoponbackup). Stopping is safer - it guarantees a fresh save and no file is written mid-archive - at the cost of a minute offline at 5 a.m., which nobody will notice.

Two caveats. The archive includes the 2 GB of server files, so it is much larger than the world it protects; with a small disk, lower the count. And ~/lgsm/backup/ is on the same disk as the server, so copy archives elsewhere too. Valheim server backups and world corruption covers restoring, and what a corrupt world looks like.

Alerts are set in common.cfg so every server under the user shares them. For Discord, set discordalert="on" and paste a channel webhook into discordwebhook, then run ./vhserver test-alert. Other services follow the same <service>alert and credential pattern; _default.cfg lists every supported service and its variables. An alert on monitor restarts is the single most useful notification a small server can have - repeated restarts are the first sign of a dying world or a broken mod.

Mods with LinuxGSM#

LinuxGSM has a mods-install command, and recent versions list a BepInEx pack for Valheim among its options. Whether it is listed, which BepInEx build it fetches, and how it wires the start script depend on your LinuxGSM release, so run ./vhserver mods-install, read the list, and check the log after the next start for BepInEx's own start-up lines. If they are missing, the server is running vanilla.

Individual mods are not managed by LinuxGSM. Their .dll files go into ~/serverfiles/BepInEx/plugins, and their configs appear in ~/serverfiles/BepInEx/config after the first start. The manual BepInEx install, which also works under LinuxGSM, is in Valheim mods with BepInEx on a server. Three rules from there matter more under LinuxGSM because of its automation: disable the automatic update cron job, never run validate casually, and keep a copy of the working BepInEx folder before every update so you can roll back in a minute.

LinuxGSM or a plain script: the trade-offs#

LinuxGSM is good. It is also a lot of shell between you and one Unity process. Which is better depends on what you want to own.

LinuxGSM vhserverPlain script under systemd
Setup timeA few minutesFifteen to thirty minutes
Updatesupdate checks the build and only restarts if neededSteamCMD by hand or on every start
Crash recoverymonitor from cron, up to five minutes lateRestart=on-failure, seconds
LogsFiles in ~/log/The journal, or a file you choose
AlertsBuilt inYour own script
ConsoleAttachable tmux sessionNone, which Valheim barely needs
Moving partsLinuxGSM, tmux, cronsystemd only
Several serversbash linuxgsm.sh vhserver again makes vhserver-2A template unit

Choose LinuxGSM if you want update detection, alerts and backups without writing them, or you already run other LinuxGSM servers and like one set of commands. Choose a plain script if you want the fewest layers, faster crash recovery, logs in the journal, and an install where every line is one you wrote. Neither is wrong; mixing them is - one supervisor per server.

Wherever it runs, the box needs the basics right first: a firewall that allows only SSH and the two UDP ports, key-only SSH, and enough memory. Valheim on a Linux VPS covers sizing and the firewall, and Linux commands for server admins is a good refresher if you are new to the shell.

FAQ#

Where are the worlds in a LinuxGSM Valheim install?

In Valheim's default save directory for the vhserver user: ~/.config/unity3d/IronGate/Valheim/worlds_local/, as a .db and .fwl pair per world. LinuxGSM does not move them unless you add -savedir to the start parameters.

Why did my config change disappear?

You edited _default.cfg, which update-lgsm overwrites. Put changes in vhserver.cfg for this server or common.cfg for all servers under the user. Both survive updates.

Does ./vhserver stop save the world?

Yes, it stops the server gracefully so Valheim writes the world before exiting. Check the console log after a stop the first time. Killing the tmux session or the process directly skips the save.

How do I run two Valheim servers with LinuxGSM?

Run bash linuxgsm.sh vhserver again in the same home directory; it creates vhserver-2 with its own vhserver-2.cfg. Give it a different port at least two above the first, a different world name and a different server name.

Is LinuxGSM safe to auto-update on a modded server?

Updating LinuxGSM itself with update-lgsm is fine. Updating the game automatically with update is not, because a Valheim patch breaks BepInEx mods until they are rebuilt. Use check-update and update by hand.