How to Setup Valheim Server on Linux

This guide will help you to set up Valheim Server on Linux. You have to first allow your ports, install Steam CMD, and then run your script. After that, start the server, check the status of the firewall, and generate the config files.

Allowing your Ports

In this section, we will take you through the steps to allow your ports to set up Valheim Server on Linux. You must write specific commands in the command prompt to allow your ports.

  • First, open the terminal and add a user with the name Valheim.
sudo adduser Valheim
  • Now, add the password:
su - Valheim

This command is used to switch the current user to the user account “Valheim” and open a new shell session with that user’s environment.

  • Next, input the following command to make a new directory.
mkdir server

You can change the current working directory to a directory named “server” within the current location or path.

  • After that, input this command to change the directory.
cd server/
  • Input the following command to put your password in the directory.
pwd

It will put your password into the current working directory, display the path of the directory you are currently in.

Install Steam CMD

This section describes how to install Steam CMD to set up Valheim Server on Linux.

  • Now you have to remember your home path where you have saved your Linux file.
  • Input the following command in the command prompt box to start the steam CMD process.
steamcmd

This command-line tool is used to install, update, and manage games and dedicated servers on the Steam platform.

Please Reload/Refresh this tab.
  • Once the steam CMD process is done, input the following command to install the server forcefully.
force_install_dir (your home path)
  • You need to write the following command to log into your server anonymously.
login anonymous

It will log you into the server anonymously, without requiring a username or password.

  • After that, use the following command in the command prompt box.
  • You have to wait for the files to process as it depends on the speed of your internet connection.
app_update 896660 validate

This command is used to update and validate the game or application with the ID number 896660.

  • Once the game is downloaded, input the following command to close the command prompt and quit the server.
exit
Please Reload/Refresh this tab.

Running your script files

This section explains how to run the script to set up your Valheim Server on Linux. By following the steps below, you will be able to input specific commands to run your script files.

  • If you want to see all your server files in the command prompt, use the following command.
    It will open all the server files.
ls
  • Now to open the server, input the following code.
nano startserver.sh

This command is used to open the file named “startserver.sh” in the Nano text editor, allowing for editing or viewing its content.

Please Reload/Refresh this tab.

Once the next window is opened, you can change the server name and password settings.

  • Press the Ctrl+ X keys on your keyboard and then hit the Y button to save the modified buffer.
Please Reload/Refresh this tab.
  • Once the new screen session has been created, input the following command to generate the config files.
cp startserver.sh myserverstart.sh

It is used for various server-related tasks or functions.

  • Now you have to write the following command.
ls

It is used to list the files and directories in the current working directory.

Please Reload/Refresh this tab.

Start the server

This section describes how to start the server to set up your Valheim Server on Linux.

  • You will need to input the following command in the command prompt box to create a new session on the screen with the specified name.
screen -S (You server name)

It allows you to identify and reconnect to the session later.

Please Reload/Refresh this tab.
  • Once the new screen session has been created, input the following command to generate the config files.
./myserverstart.sh

It can be executed to perform various server-related tasks or functions.

  • Press the Ctrl + A keys and then hit the D button to detach the screen.
Please Reload/Refresh this tab.
  • Now input this code to see all the running screens.
screen -r

It will allow you to kill or completely quit the screen.

Please Reload/Refresh this tab.
  • Once you are on the next window, press the Ctrl+ A buttons from your keyboard and hit the K button to kill the screen.
  • After that, input the following code for confirmation.
Y

This command represents yes to allow the confirmation to run the script. 

Please Reload/Refresh this tab.

Checking the status of the firewall

This section explains how to check the status of your firewall to set up Valheim Server on Linux.

  • Upon reaching the previous window, you have to write the following codes.
su - your_username

It will switch the current user to another user account and open a new shell session with that user’s environment.

sudo ufw allow 22

It gives you administrative privileges to allow incoming network traffic on port 22, which is the default port for SSH (Secure Shell) connections.

  • If your firewall is inactive, then you have to activate it by writing this code.
sudo ufw status

This command is used with administrative privileges to check the status of the Uncomplicated Firewall (UFW) and display the current firewall rules and settings.

  • After that, input your sudo password and the following command.
sudo ufw enable

It allows you to secure the socket shell into the server.

  • Now you have to write these codes in the recently opened window.
sudo ufw allow 2456

It is used with administrative privileges to allow incoming network traffic on port 2456.

sudo ufw allow 2457

It provides you with administrative privileges to allow incoming network traffic on port 2457.

  • You need to check your firewall again by writing this code.
sudo ufw status

This command is used with administrative privileges to check the status of the Uncomplicated Firewall (UFW) and display the current firewall rules and settings.

Please Reload/Refresh this tab.
  • Now input the following command inside it to get back to the Valheim user.
  • After that, input your sudo password.
su - Valheim

It will switch the current user to another user account and open a new shell session within Valheim ‘s environment.

  • After that, write this command in the command prompt box to create a new session on the screen with the specified name.
screen -S (You server name)

It allows you to identify and reconnect to the session later.

Please Reload/Refresh this tab.

Generate config files

This section will take you through the steps to generate the config files to set up Valheim Server on Linux.

  • Once the new window is opened, input these commands to change the directory.
cd server/

It is used to change the current working directory to a directory named “server” within the current location or path.

./myserverstart.sh

It can be executed to perform various server-related tasks or functions.

Please Reload/Refresh this tab.