How to install Valheim with LinuxGSM on Ubuntu 22.04 ?


Setup a Valheim server with LinuxGSM on Ubuntu 22.04

How to install a Valheim server with LinuxGSM on Ubuntu 22.04

Valheim Title

In this tutorial, you will learn how to install and configure a Valheim game server on Ubuntu 22.04 using LinuxGSM.

Valheim is a brutal exploration and survival game for 1-10 players, set in a procedurally-generated purgatory inspired by viking culture. Battle, build, and conquer your way to a saga worthy of Odin’s patronage!

LinuxGSM is a command-line tool for quick, simple deployment and management of Linux dedicated game servers.

 

Prerequisites

This tutorial requires:

  • An Ubuntu 22.04 Jammy Linux server
  • Server access as a non-root user with sudo privileges
  • Basic knowledge of the Linux CLI and vim text editor

Connect to server

Connect to the remote server over ssh as a non-root user with sudo privileges.

In this example, the server name is lgsm-host and the user is ubuntu.

Console

 

Installation

Enable support for 32-bit architecture and update package index and system packages using the following commands:

sudo dpkg --add-architecture i386 packages sudo apt update

apt update result

Install dependencies and Steam

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

When prompted accept licenses and service restart requests.

apt update result

apt update result

apt update result

 

GameDig

GameDig is an additional module that replaces the default LinuxGSM query module that monitor uses. In addition to verifying if the game server is online, it provides players with live game details including maps. This module makes it possible for ./gameserver to display live information.

Install Node.js

GameDig requires Node.js, a JavaScript runtime environment.

Install Node.js with this command:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt update && sudo apt install -y nodejs

When asked, select OK and press ENTER to continue:

reload services

Install GameDig

Install GameDig with this command:

sudo npm install gamedig -g

it is better to update the npm package as shown with the following command:

sudo npm install -g npm@8.9.0

Create a dedicated user

For security, create a user that does not have sudo privileges.

sudo adduser vhserver

Create the user password and add any optional information.

adduser vhserver

Switch to the newly created user:

su - vhserver

Install LinuxGSM

Install linuxgsm using the following command:

wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh vhserver

install lgsm

 

Install Valheim server

Install Valheim server using LinuxGSM by entering the following:

./vhserver install

When asked, enter Y to all questions.

install Valheim

install Valheim

Installation takes a few minutes and when complete, the following command provides the Valheim server details.

./vhserver details

vhserver@lgsm-host:~$ ./vhserver details

Distro Details
==============================================================================================================
Date:      Tue May 10 08:13:32 UTC 2022
Distro:    Ubuntu 22.04 LTS
Arch:      x86_64
Kernel:    5.15.0-25-generic
Hostname:  lgsm-host
Uptime:    0d, 0h, 27m
tmux:      tmux 3.2a
glibc:     2.35

Server Resource
==============================================================================================================
CPU
Model:      Intel Core Processor (Broadwell, IBRS)
Cores:      2
Frequency:  2399.994MHz
Avg Load:   0.43, 0.26, 0.10

Memory
Mem:       total  used   free   cached  available
Physical:  6.7GB  212MB  6.2GB  2.4GB   6.2GB
Swap:      0B     0B     0B

Storage
Filesystem:  /dev/sda1
Total:                  49G
Used:                   3.4G
Available:   45G

Network
IP:           0.0.0.0
Internet IP:  162.19.69.3

Game Server Resource Usage
==============================================================================================================
CPU Used:  0%
Mem Used:  0%  0MB

Storage
Total:        1.4G
Serverfiles:  1.2G

Valheim Server Details
==============================================================================================================
Server name:      Valheim Server
App ID:           896660
Server IP:        0.0.0.0:2456
Internet IP:      162.19.69.3:2456
Server password:  NOT SET
Game world:       vhserver
Master server:    not listed
Status:           STOPPED

vhserver Script Details
==============================================================================================================
Script name:            vhserver
LinuxGSM version:       v21.5.1
glibc required:         2.15
Discord alert:          off
Email alert:            off
Gotify alert:           off
IFTTT alert:            off
Mailgun (email) alert:  off
Pushbullet alert:       off
Pushover alert:         off
Rocketchat alert:       off
Slack alert:            off
Telegram alert:         off
Update on start:        off
User:                   vhserver
Location:               /home/vhserver

Backups
==============================================================================================================
No Backups created

Command-line Parameters
==============================================================================================================
 ./valheim_server.x86_64 -name 'Valheim Server' -password  -port 2456 -world vhserver -public 1 -savedir '/home/vhserver/.config/unity3d/IronGate/Valheim'

Ports
==============================================================================================================
Change ports by editing the parameters in:
/home/vhserver/lgsm/config-lgsm/vhserver

Useful port diagnostic command:
ss -tuplwn | grep valheim_server.

DESCRIPTION  PORT  PROTOCOL  LISTEN
Game         2456  udp       0
Query        2457  udp       0

Status:	STOPPED

Configure Valheim server

From the Valheim server details above, note the directory containing the configuration files: /home/vhserver/lgsm/config-lgsm/vhserver.

The _default.cfg file contains the default Valheim server configuration. This file should not be modified but used as a template to create a personalized server configuration.

Open this file and copy the lines referring to the servername and serverpassword variables. If you also want to change the port number, include the line containing the port variable.

 

vi /home/vhserver/lgsm/config-lgsm/vhserver/_default.cfg

Open default configuration file

Now open the vhserver.cfg file in the same directory, add the lines corresponding to the parameters to be modified and change the values like this:

vi /home/vhserver/lgsm/config-lgsm/vhserver/vhserver.cfg

Open default configuration file

servername="My Awesome Valheim Server" # Minimum password length is 5. serverpassword="mypassword" port="2456"

 

Start Valheim server

Everything is ready to start the Valheim server with the following command:

./vhserver start vhserver@lgsm-host:~$ ./vhserver start [ OK ] Starting vhserver: Applying steamclient.so sdk64 hardlink fix: Valheim [ OK ] Starting vhserver: Applying steamclient.so sdk32 link fix: Valheim [ OK ] Starting vhserver: My Awesome Valheim Server

Once started, check the status and detailed information:

./vhserver details

vhserver@lgsm-host:~$ ./vhserver details

Distro Details
==============================================================================================================
Date:      Tue May 10 08:21:51 UTC 2022
Distro:    Ubuntu 22.04 LTS
Arch:      x86_64
Kernel:    5.15.0-25-generic
Hostname:  lgsm-host
Uptime:    0d, 0h, 35m
tmux:      tmux 3.2a
glibc:     2.35

Server Resource
==============================================================================================================
CPU
Model:      Intel Core Processor (Broadwell, IBRS)
Cores:      2
Frequency:  2399.994MHz
Avg Load:   0.67, 0.24, 0.12

Memory
Mem:       total  used   free   cached  available
Physical:  6.7GB  1.7GB  4.8GB  2.4GB   4.8GB
Swap:      0B     0B     0B

Storage
Filesystem:  /dev/sda1
Total:                  49G
Used:                   3.4G
Available:   45G

Network
IP:           0.0.0.0
Internet IP:  162.19.69.3

Game Server Resource Usage
==============================================================================================================
CPU Used:  111%
Mem Used:  22.2%  1506MB

Storage
Total:        1.4G
Serverfiles:  1.2G

Valheim Server Details
==============================================================================================================
Server name:      My Awesome Valheim Server
App ID:           896660
Server Version:   1.0.0.0
Server IP:        0.0.0.0:2456
Internet IP:      162.19.69.3:2456
Server password:  mypassword
Players:          0/64
Current map:      My Awesome Valheim Server
Game world:       vhserver
Master server:    listed
Status:           STARTED

vhserver Script Details
==============================================================================================================
Script name:            vhserver
LinuxGSM version:       v21.5.1
glibc required:         2.15
Discord alert:          off
Email alert:            off
Gotify alert:           off
IFTTT alert:            off
Mailgun (email) alert:  off
Pushbullet alert:       off
Pushover alert:         off
Rocketchat alert:       off
Slack alert:            off
Telegram alert:         off
Update on start:        off
User:                   vhserver
Location:               /home/vhserver

Backups
==============================================================================================================
No Backups created

Command-line Parameters
==============================================================================================================
 ./valheim_server.x86_64 -name 'My Awesome Valheim Server' -password mypassword -port 2456 -world vhserver -public 1 -savedir '/home/vhserver/.config/unity3d/IronGate/Valheim'

Ports
==============================================================================================================
Change ports by editing the parameters in:
/home/vhserver/lgsm/config-lgsm/vhserver

Useful port diagnostic command:
ss -tuplwn | grep valheim_server.

DESCRIPTION  PORT  PROTOCOL  LISTEN
Game         2456  udp       1
Query        2457  udp       1

Status:	STARTED

Schedule admin tasks

Whith lgsm, you can use crontab to schedule maintenance or admin tasks.

For example:

crontab -e */5 * * * * /home/vhserver/vhserver monitor > /dev/null 2>&1 */30 * * * * /home/vhserver/vhserver update > /dev/null 2>&1 0 0 * * 0 /home/vhserver/vhserver update-lgsm > /dev/null 2>&1

 

Connect to the Valheim game server and play!

To connect to the Valheim game server, open your Valheim game and join the server either by searching with name or by joining with IP address.

join server

And now it’s up to you to conquer Odin’s kingdom!

let's play