How to set up a Valheim Server on Linux

In this tutorial, we will be showing you how to set up a dedicated Valmheim server on Linux.

Valheim Dedicated Server Linux

Valheim is a popular survival and sandbox game that is heavily inspired by Viking culture. This game can be played with up to 10 people at the same time.

Setting up a Valheim dedicated server allows you to have a world available 24/7 without needing to keep the main game running on your machine. You don’t even need to own the game yourself to be able to host a server.

Linux is a great operating system for running servers as it has relatively low overheads, and the vast majority of Linux operating systems don’t require you to pay for a license to use them.

While the following steps are written for the Ubuntu operating system, they should work with most Linux systems.

Setting up a Valheim Dedicated Server on Linux

Over the following sections, we will walk you through setting up a Vlaheim Dedicated server on Linux.

This process is relatively simple, and you will have the game server up and running in no time.

Preparing your System to run the Valheim Server

1. Before we start setting up your Valheim dedicated server on Linux, you will want to ensure you have an updated system to work off of.

Updating the packages on your system is as simple as using the following two commands.

sudo apt update
sudo apt upgrade -y

2. Our next step is to install the “software-properties-common” package to our system.

This package makes adding repositories and adding additional supported architectures a breeze.

sudo apt install software-properties-common

Installing SteamCMD

3. To install the Valheim Dedicated server onto our Linux operating system, we will use SteamCMD. This is an official tool from Valve that allows you to install software from Steam’s servers without needing the full Steam client.

To install SteamCMD to our system, we must add the “i386” architecture to the package manager.

sudo dpkg --add-architecture i386

4. Since Steam is closed source, we must add the “multiverse” repository to install the tool.

Adding this repository is as straightforward as using the following command in the terminal.

sudo add-apt-repository multiverse

If you use an operating system that isn’t Ubuntu, such as Debian, then you will want to use the below command instead.

sudo apt-add-repository non-free

5. Since we made changes to both the available package architectures and the repositories, we will need to update the package list cache.

You can update this cache by using the command below.

sudo apt update

6. Finally, you can install the SteamCMD tool on your Linux device by using the following command within the terminal.

sudo apt install steamcmd

Creating a User to run the Valheim Dedicated Server on Linux

7. Before using SteamCMD to download and install the Valheim dedicated server on Linux, we should create a user to run the server.

Let us use the “useradd” command to create a user called “valheim” on your system. By using the “-m” option, the tool will also create a home directory, which we will use to store the server and the Valheim world data.

sudo useradd -m valheim

8. After creating the Valheim user, you can switch to it using the command below.

We will want to run the following commands as the Valheim user to ensure we don’t create any permission issues down the track.

sudo -u valheim -s

9. Once you have switched to the Valheim user, you will want to change to the newly created home directory.

The cd command makes changing to the users home directory super simple.

cd ~

Installing the Valheim Server

10. We can now install the Valheim dedicated server on Linux by running the following command.

This command uses the SteamCMD tool to download the latest version of the Valheim server to the “/home/valheim/valheimserver” directory.

/usr/games/steamcmd +@sSteamCmdForcePlatformType linux +force_install_dir /home/valheim/valheimserver +login anonymous +app_update 896660 +quit

Setting your Valheim Dedicated Server up as a Service on Linux

11. We are now finished setting up the Valheim server so we can exit and return to your normal user.

Switching back to the standard user is as simple as typing “exit” into the terminal.

exit

12. Our next step is writing a service file for our Valheim Dedicated server. This service is what will manage the server on your Linux system.

It will handle starting the server and updating the software when the service starts.

sudo nano /etc/systemd/system/valheimserver.service

13. Within this service file, you will want to enter the following lines. However, there are a few values that you must replace.

  • <SERVERNAME>: Replace this value with the name you want to use for your Valheim dedicated server.
  • <WORLDNAME>: Use this value to specify a name for your Valheim world.
  • <PASSWORD>: Finally, you can set a password for your server. You can remove this option if you want anyone to be able to connect to your server.
  • <ISPUBLIC>: You can set whether the server is public or private using this option.
    • 0: The server won’t be findable through the server browser.
    • 1: Your Valheim server will be available to connect through the in-game server browser.
[Unit]
Description=Valheim Dedicated Server
Wants=network-online.target
After=network-online.target

[Service]
Environment=SteamAppId=892970
Environment=LD_LIBRARY_PATH=/home/valheim/valheimserver/linux64:$LD_LIBRARY_PATH
Type=simple
Restart=on-failure
RestartSec=10
KillSignal=SIGINT
User=valheim
Group=valheim
WorkingDirectory=/home/valheim/valheimserver
ExecStartPre=/usr/games/steamcmd +login anonymous +force_install_dir /home/valheim/valheimserver +app_update 896660 validate +exit
ExecStart=/home/valheim/valheimserver/valheim_server.x86_64 -nographics -batchmode -port 2456 -public <ISPBULIC> -name "<SERVERNAME>" -world "<WORLDNAME>" -password "<PASSWORD>" -savedir "/home/valheim/valheim_save_data"

[Install]
WantedBy=multi-user.target

14. After filling out the service file, you can save and quit by pressing CTRL + X, Y, and then ENTER.

Starting up and testing the Valheim Server

15. We are now at the point where we can start up and test out the Valheim Dedicated server on your Linux system.

To get your Valheim server to start when your server powers on, you will want to enable the service we just wrote.

sudo systemctl enable valheimserver

16. With the service enabled, we can immediately start the server using the command below.

When you first run this command, it will take a few minutes as it will need to generate your Valheim world.

sudo systemctl start valheimserver

17. To verify that the server is up and running, you will want to get the status of the Valheim server service.

You can retrieve the status of this service by using the command below.

sudo systemctl status valheimserver

18. If the server is running, you should see the server status marked as “active: active (running)” as shown below.

Active: active (running)

Once your server is fully running and connectable, you should see the following at the bottom of the status output.

Feb 28 15:30:55 pimyubu valheim_server.x86_64[1678959]: 02/28/2024 15:30:55: Game server connected

19. Now, you should be able to connect to your Linux-based Valheim dedicated server.

If you have a firewall enabled, you must allow port 2456. Additionally, if you are running this on a home network, you may have to port forward this port to your Linux machine as well.

Configuring the Valheim Dedicated Server

In this section, we will explore the various ways you can configure your Valheim server. If something is missing from this section, feel free to leave a comment below.

Adding a User to the Admin, Banned, or Permitted List

1. Before you do anything, you must have the “steamid64” for the user you want to make an admin, ban, or add to a permitted list.

You can get the Steam ID you require in various ways. We will quickly cover how to get the value you require.

  • If you are connected to your Valheim Linux server, you can press F2 to bring up a menu that shows every user and their Steam ID’s
  • The server console will also print out the SteamID64 of a user when they connect to the server. You can grab the status of the server to see what has been output by the server.
  • Finally, you can also use third-party services such as steamid.io to retrieve the Steam ID you require.

An example of a valid ID is the one shown below.

76561198000656671

2. Below, we have included three commands to edit the admin, banned, and permitted lists.

These commands assume that you kept the save directory set to “valheim_save_data” earlier.

a. To edit the admin list, run the following command within the terminal.

sudo nano /home/valheim/valheim_save_data/adminlist.txt

b. Alternatively, you can use the command below to add a user to the banned list.

sudo nano /home/valheim/valheim_save_data/bannedlist.txt

c. It is also possible to set up a permitted list. Adding SteamIDs to this file will mean only the listed users can join your Valheim dedicated server.

sudo nano /home/valheim/valheim_save_data/permittedlist.txt

3. With the relevant list open, you will want to add your Steam ID to the bottom of the file.

For example, after adding our Steam ID to the admin list, the file looked like what we have shown below.

// List admin players ID  ONE per line
76561198000656672

4. After changing any of these lists, you can save and quit by pressing CTRL + X, Y, and then ENTER.

Conclusion

Hopefully, you will now have successfully set up a dedicated Valheim server on your Linux-based operating system.

Hosting a dedicated server gives you a central place to play your Valheim games and is a great option when playing with friends or when playing Valheim on the move.

Please feel free to leave a comment below if you have run into any issues with starting or connecting to your server.

If you found this tutorial helpful, we have many other game server tutorials.

4 Comments

  1. Avatar for Sysadmin-Cosplayer
    Sysadmin-Cosplayer on

    How do you update the Valheim server?

    1. Avatar for Emmet
      Emmet on
      Editor

      Hey,

      If you are using the service that we write during this guide, the easiest way is to simply restart your Valheim server by using the following command.
      The service has a line in it that will automatically check for updates before starting.

      sudo systemctl restart valheimserver

      Alternatively, if you aren’t using the service you will need to stop the currently running server.

      1. After stopping the server, you will want to temporarily switch to the valheim user we created

      sudo -u valheim -s

      2. Once you are running as the valheim user, use the following command to update the Valheim server.

      /usr/games/steamcmd +login anonymous +force_install_dir /home/valheim/valheimserver +app_update 896660 validate +exit

      3. When the update completes you can return to your usual user by using the exit command.

      exit

      Please let me know if you need any more assistance.

      Kind regards,
      Emmet

  2. Avatar for Sysadmin-Cosplayer
    Sysadmin-Cosplayer on

    Found the solution

    I know why the password was wrong on my end. Under the section of “” The actual password included ” ” and the . I had to remove ” ” and the for my actual password to work.

  3. Avatar for Sysadmin-Cosplayer
    Sysadmin-Cosplayer on

    Installed this on Proxmox as a container running ubuntu 22.04. Followed everything and everything went well. Except when I log into the server it and type in the correct password. It says “wrong password” and goes back to the screen. Look at the status log and I have the correct steamid64 and shows in the log Peer .(SteamID)…….. has wrong password….Disposing socket…Closing socket (SteamID)

    Have allowed the right ports of 2456-2458 from what I read on other threads and still nothing.

Leave a Reply

Your email address will not be published. Required fields are marked *