7 Days to Die

7 Days to Die

78 ratings
Installing Linux dedicated server for 7 days to die
By Max Noskill
Step-by-step guide: installing 7 days to die dedicated server on Linux.
   
Award
Favorite
Favorited
Unfavorite
Foreword
This guide is for 10.4 b9. Update to alpha18.1 stable release.

Guide is for Ubuntu systems as that's what Valve is supporting. However, it's extremely easy to install this on RedHat systems too.

I assume that you're at least somewhat familiar with unix commands. If you don't understand what commands will do, look them up on search engine and do some learning before proceeding. If you're completely new to linux systems, you should remember that files are case-sensitive.

Also I assume that you run SSHd on your server. It's installed as "openssh-server" on Ubuntu.

Important note:

If you want to install Windows-server, there is video guide by [SAO] BigC90210.
Step 1: Log in to your server with SSH
ssh -l youraccount yourserver

Step 2: Choose account for 7days dedicated server
Option 1: install on your own user account

You can skip this step.

Option 2: create new dedicated server account (recommended)

This requires you have root access.

# get root permissions sudo su (type your password) # add a new user account useradd --comment "7days to die Server" -m 7days # change shell to bash chsh -s /bin/bash 7days # change the password passwd 7days (type 7days account password here)

Test your new account by logging in from the remote computer.

You need to edit server config files. Easiest way to do this is to use text editor on the server. You can also edit them locally on your computer and transfer them to server with SFTP.

If you haven't used any command line editor before, let's install text editor nano (if it already isn't installed).

Otherwise just use whatever editor suits you.

apt-get install nano

As you can't daemonize the server with command line switches, you most likely want to install screen.

apt-get install screen

There is also byobu which offers more functionality, but screen is no-brainer.
Step 3: Install SteamCMD
Download SteamCMD:


Open the package:

tar xvzf steamcmd_linux.tar.gz

Remove install package:

rm steamcmd_linux.tar.gz

Note: if you don't have wget installed, you can install it:

apt-get install wget

Problems running steamcmd? You might need to install lib32gcc1:
apt-get install lib32gcc1
Step 4: Download dedicated server with SteamCMD
You can download the dedicated server anonymously without logging in. Otherwise use your account credentials on login and authenticate yourself with Steam Guard.

# Start SteamCMD ./steamcmd.sh

SteamCMD shell appears after a while and you can type commands in SteamCMD prompt. Note that SteamCMD prompt always begins with Steam>.

login anonymous force_install_dir ./7daysded app_update 294420 quit

You can use this same procedure to UPDATE THE SERVER.

Updating might overwrite your config files! You might want to backup and/or rename them later when everything works.

Note: You can insert all SteamCMD-commands in the text file and run it with crond whenever you want to update your server.


Experimental and old server builds:

You can see available server builds from Steam:
Go to Library > Tools > 7days > Properties > Beta

Old build:

app_update 294420 -beta alpha13.8
Note that's "alpha13.8" without spaces!

Latest experimental:

app_update 294420 -beta latest_experimental

Revert to current build from old:

app_update 294420 -beta NONE
Step 5: Location of startup script startserver.sh
Server was installed in "7daysded" directory. It contains startup script and config files.

On new versions startup script works as it should so you don't have to edit it.
Step 6: Edit serverconfig.xml file
Setup the server anyway you want. There is explanation text after each of the options in serverconfig.xml.

Here are the most important options:

  • ServerName -- name of your server
  • ServerPort -- do you want default game port and if you're inside LAN, please think about how you're going to route the port out. Usually this means you have to edit NAT settings on your WAN/xDSL/router box.
  • ServerVisibility -- do you want private server for friends or public internet server. Option 0 means private server which is not published on the game server lists.

  • ServerPassword -- if you run private server, you might want to set a password
  • ServerMaxPlayerCount -- your server might not support lots of players without lagging. It's best to test which value is suitable for you.
  • ServerDescription -- type brief description of your server here
  • EACEnabled -- anti-cheat, if you get bad lag and weird behaviour, you might want to turn this off, especially on private servers.

Game world is the map you'll see in the game. Navezgane is the default map.

  • GameWorld -- Navezgane is the default map, or you might want to try "RWG" for randomized map. Note that RWG generation takes lots of time when you start the server up but on next startup it should load up fairly fast.
  • GameName -- you can name your save game here. Do not use : in the name or windows players can't connect.
  • WorldGenSeed -- for RWG, random seed for changing the map layout
  • WorldGenSize -- for RWG, map size options. Note that larger numbers like 8192 will increase the generation time.
  • DayNightLength -- length of the game day in real time (minutes).
  • LootRespawnDays -- game days before loot respawns.

This is "PvP setting".

  • PlayerKillingMode -- are players able to damage each others. This is important if you have public server and do not want player to kill each others.

You'll need some way to shut your server down and possibly manipulate it. Here is how to enable the telnet interface.

  • TelnetEnabled -- if your server is directly connected on the internet, consider blocking direct connects to this port
  • TelnetPort -- you can change the default port (e.g. 12345)
  • TelnetPassword -- documentation claims that telnet is only bound to local interface if the password is empty.

Section 6.1: Map generation times

Important: if server "does not start" and you have RWG selected, just wait. That will take LOOONG time on slower computers. For testing, it's best to try on smaller map size, Navezgane or use pregenerated maps.

Size 8192x8192 map takes about:

Time
CPU
20 minutes
Intel i7-6700K
1 hour
AMD Phenom II X4 B55

It should write information about generation on logs. If not, restart the server as it's stuck. And yes, generation is single thread.
Step 7: Start the server
As server does not start automatically as background process, you may want to start the server inside screen or use nohup.

You can always kill the server by telnetting in and do "shutdown". After that you need restart the server manually unless you write the loop which does restarting automatically.

Option 7.1: Quickly testing the server (you can press Ctrl-C to end it)

./startserver.sh -configfile=serverconfig.xml

Note that when you close the connection to the server, it will die.
Press Ctrl-C to kill the server.

Option 7.2: nohup

nohup will leave process in the background after you log out and it will output all information into nohup.out text file. Easy to use and no fuss.

nohup ./startserver.sh -configfile=serverconfig.xml &

Option 7.3: Screen

screen is left to run on the server after you log out. If you're new to screen, you may want to read how you can instruct screen with keypresses by reading the manual (man screen).

screen commands are given by pressing Ctrl+a and then followed by command key. You can "detach" the screen by pressing Ctrl+a and then pressing d-key. Sounds harder than it is.

screen cd 7daysded ./startserver.sh -configfile=serverconfig.xml (press Ctrl+a and then d)

Section 7.3.1: About screen

To get back to your session, resume the screen:

screen -r

Note that you can easily kill the server by resuming screen session and pressing Ctrl-C.

For adventurous, Ctrl+a c makes new window and Ctrl+a n switches between them.

Multiple sessions on separate screens:

screen -list

There are screens on: 5399.pts-1.dogville (24.11.2019 17.54.05) (Detached) 3441.pts-1.dogville (24.11.2019 16.56.31) (Detached) 2 Sockets in /run/screen/S-zombiserv.

screen -r 5399

Type exit on screen to quit the screen (closes the terminal so screen quits).
exit [screen is terminating]
Step 8: Observe output_log.txt
After you have started the server, there is output_log-dateandtimehere.txt in the data-directory.

tail ~/7daysded/7DaysToDieServer_Data/output_log.txt

For reading whole log you may want to use less:

less ~/7daysded/7DaysToDieServer_Data/output_log.txt

Observing the log changes until you hit Ctrl-C

tail -f ~/7daysded/7DaysToDieServer_Data/output_log.txt # or watch -n 1 tail -n 15 ~/7daysded/7DaysToDieServer_Data/output_log.txt

Note: you will see same information if you'll access your server via telnet.

Mental note: If the uppercase letters and random timestamp numbers will cause heartburn condition for you, just edit startserver.sh to write it to somewhere more sensible place!

./7DaysToDieServer.x86_64 -logfile $SERVERDIR/log/server1-output.log -quit -batchmode -nographics -dedicated $PARAMS
Step 9: Observing server with telnet and killing the server
You may want to shutdown the server.

Step 9.1: Use telnet

If you set up telnet, you can log in with it and use "shutdown". See tips-section about safe use of telnet over internet.

telnet localhost 8081 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. *** Connected with 7DTD server. *** Server version: Alpha 18.1 (b8) Compatibility Version: Alpha 18.1 *** Dedicated server only build Server IP: Any Server port: 26900 Max players: 16 Game mode: GameModeSurvival World: RWG Game name: YourGameNameHere Difficulty: 3 Press 'help' to get a list of all commands. Press 'exit' to end session. (type exit to close telnet or type shutdown to save and close the server)

Step 9.2: You can't use telnet

You can kill the server process if you want to take server down right now. Note that server does autosave every minute, but it will lose the latest game information if you kill it.

ps wuax | grep 7Days (observe which is the server process id, e.g. 22222) kill 22222

Server is stuck, crashed or in zombie state and does not want to die gracefully:

kill -9 22222
Step 10: Information about save game directory
After you have started your server, a new directory is created.

Server saves games into "hidden" directory on server account. Directory is named as .local (with dot).

It looks like this (tree -d .local):
tree -d .local/ .local/ └── share ├── 7DaysToDie │   └── Saves │   └── Joyofo Mountains │   └── fusrohdah │   ├── Player │   └── Region

If you have problems with spaces, you can always use TAB-key to autocomplete the name. Space characters should be shielded with \ or you should type quote marks around the directory name.

If you change GameName in your serverconfig.xml, a new save game is created.

Game information is also saved on the player's computer.

Completely unrelated side note: you can transfer player inventories and even map world pieces between servers if you copy appropriate files to another save directory. Player inventories did work on earlier versions so you can "save" your character progress between maps. Same method works on single player Windows-games too. Chances are that something will be broken though, so don't be disappointed if your inventory is missing or character stats are gone.

Step 11: Editing serveradmin.xml
There is serveradmin.xml file on the server installation directory. It identifies admins by their long Steam ID-numbers. These same numbered files contain player data in the save game directory.

Steam does it's best to hide them from you, but if you get your profile page open with normal web-browser or use "copy this page url" from your profile page you'll find out what's yours. There are examples on serveradmin.xml file what those numbers look like (17 numbers at least).

There is also several steam-ID finders on the internet if you just can't find it.
Step 12: Backup
By now you're familiar with server files and scripts. You should do a backup of most important ones. Even just copying them to backup-directory saves lots of work if something happens. Here's simple backup example. To be safe, you should copy them from the server and store on your computer.

mkdir ~/backup cp ~/7daysded/startserver.sh ~/backup/ cp ~/7daysded/serverconfig.xml ~/backup/ cp ~/7daysded/serveradmin.xml ~/backup/
Step 13: Port forwarding, troubles connecting from the internet
Server reserves by default TCP port 26900 and UDP ports 26900, 26901 and 26902.

On official forum there is a list of used ports:
7days forum post 426481[7daystodie.com]

Additionally it reserves TCP 8081 for telnet and if you have webadmin enabled, it's on 8080.

So, you need to open up from your WAN/xDSL/router-device following ports:

Type
Number
TCP
26900
UDP
26900
UDP
26901
UDP
26902

Do not open port 8081 used by telnet unless you're adventurous type and have the password set.

Also note that exposing game server to internet is security risk if there are any coding errors on the server. Oh well, our Internet of Things devices are already mining bitcoins so why not zombie-servers can't do that...

.. but joking aside, you should head to your router device control panel and create config like this:



If you scan your server with nmap, it should show something like this:

UDP scan: nmap -v -sU -T5 -p1024-60000 addr

PORT STATE SERVICE
26900/udp open|filtered hexen2
26901/udp open|filtered unknown
26902/udp open|filtered unknown

Appendix A: Using telnet
How to use telnet when you're logged on the server (on any user account)

telnet localhost portnumber

(e.g. telnet localhost 8081)

How to use telnet when you're in same LAN as server

telnet yourserver 12345

Use telnet over the Internet with SSH-tunnel

If you have to use telnet over Internet, you probably want to do it in secure way. Also you should block connections the telnet port if your server is directly connected to the Internet. SSH-tunneling works too in that case. Following example tunnels server telnet port 8081 to your local port 2222.

ssh -N -f 7days@yourserver.dot.com -L 2222:yourserver.dot.com:8081 telnet localhost 2222

Tunnel stays open as long you keep your local computer on. See man 1 ssh for explanation about command line switches.

Note: sshd running on the server should be configured properly to allow forwarding.

You may want to check if you already have tunnel with netstat:

netstat -tupan

Kill SSH process off if you want to destroy the tunnel.
Appendix B: Error 267 for Windows-player
Windows-players can't join

Windows-player informs you that following message is shown on the game client console:

IOexception win32 IO returned 267 Path: c:\whatever

Error code 267 is simply: The directory name is invalid

Check your serverconfig.xml. If you used character : in the GameName, Windows-players can't join as it's illegal character for file- and pathnames. Game saves are also on the player's computer.

See http://support.microsoft.com/kb/177506 for more information.

Appendix C: crond server update
You can periodically run automatic updates. Valve has added some messy scripts on SteamCMD-page, but here's easy one:

Save this as myserverupdate.sh on 7days home dir:
#!/bin/sh cd /home/7days/ ./steamcmd.sh +runscript update_server.txt

Set executable flag:
chmod u=rwx myserverupdate.sh

Create new textfile named update_server.txt:
@ShutdownOnFailedCommand 1 login yourSteamAccountName yourSteamPass force_install_dir ./7daysded app_update 294420 quit

Use quotes around account name and password if they contain spaces.

See that you have already authenticated your server with SteamGuard!

Test your script and check that update does not overwrite your config files (move them around and change paths!)

Add the script in the cron (I'll assume you don't want vi-editor;-)
env EDITOR=nano crontab -e

You should see crontab for 7days account, add following line:
0 5 * * * /home/7days/myserverupdate.sh &

Now your server updates at 05 every morning. Adding server.pid to text file and sending kill to server with that pid would be nice addition, but if you have players in the server, that's too nasty.

Have fun, gg.
Notes
If you want to add something constructive to this guide, please write to the comment section.

I'm not going to help you with basic shell command usage, you will find lots of guides and information on the internet. Please use the search engine.

Also unix command line tools will give you plenty of help with man commandname (q to quit help page) or just type the command and write switch --help after it.

Big thank you to following people for contributing: Red_Nalf, StockholmSyndrome, Zerock

Changes:
22.12.2014: original version
19.02.2018: added old/experimental builds install option.
24.11.2019: updated to 18.1
< >
87 Comments
Max Noskill  [author] Mar 18 @ 2:13pm 
Hmm, I tried to update the server and it works fine.

Some pages I found from search claimed that's related to "disk full". Note that server needs to DL files and extract them so it might even double the space requirements.

"df" to check if the if the disk is actually full.

/dev/sda1 474822784 72041228 378638864 16% /

Links:

https://steamcommunity.com/app/4000/discussions/1/357288572127851177/
https://oxidemod.org/threads/error-app-state-is-0x202-after-update-job-out-of-space.17980/
https://docs.linuxgsm.com/steamcmd
https://github.com/GameServerManagers/LinuxGSM/issues/1684
https://steamcommunity.com/groups/linuxgsm/discussions/0/135508031951230808/


If there is enough free space, are you absolutely sure that files are owned by your new account, not by root?
MATU Mar 18 @ 1:50pm 
ok I used a normal user account now. steamcmd.sh did not give any error. but app update still doesn't work.

Steam>login anonymous

Connecting anonymously to Steam Public...Generated client id: 5857151639274013961
Listening for IPv4 broadcast on: 27036
Logged in OK
Waiting for user info...OK

Steam>force_install_dir ./7daysded

Steam>app_update 294420
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Update state (0x11) preallocating, progress: 0.00 (0 / 12080234933)
Error! App '294420' state is 0x202 after update job.

I use Ubuntu Server 19.10 so an old version is not the issue.
Max Noskill  [author] Mar 18 @ 12:02pm 
@MATU: there are several things.

1) See my earlier comment 27 Feb 12:41am. Does it work if you DO NOT install it under ROOT account and just create normal user account for it? I never received answer from the user, but this is just a guess that might be reason. I mean: during installation use normal user account in all installation stages so all files are writable (if it's root.root server can't write on it).

2) About errors, this is just stab to the dark but if the system distribution is old as Wery Old, it might be that there aren't required packages installed. This thread here complained about same thing and it was solved by installing requirements, list is in the thread:

https://steamcommunity.com/discussions/forum/14/494631967655819107/

3) about locales, there are pre-packaged locales available. If you want all of them they are in "locales-all" so you can be full of win by typing "Örkit älisee Åålannin rannikolla!"
MATU Mar 18 @ 11:24am 
I also get this error afterwards:

Steam>app_update 294420
Update state (0x3) reconfiguring, progress: 0.00 (0 / 0)
Error! App '294420' state is 0x202 after update job.

I have no idea why ? I think i did everything exactly the same way like last time.
MATU Mar 18 @ 11:19am 
I just tried to setup a new more powerful machine. And get the following error when starting steamcmd.sh

root@mserver:/home/matu# ./steamcmd.sh
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/root/Steam/logs/stderr.txt'
[ 0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...applicationmanager.cpp (4030) : Assertion Failed: CApplicationManager::GetMountVolume: invalid index
applicationmanager.cpp (4030) : Assertion Failed: CApplicationManager::GetMountVolume: invalid index
applicationmanager.cpp (4193) : Assertion Failed: m_vecInstallBaseFolders.Count() > 0
Failed to init SDL priority manager: SDL not found
Failed to set thread priority: per-thread setup failed
Failed to set thread priority: per-thread setup failed
OK.

Steam>
Max Noskill  [author] Mar 8 @ 9:10am 
.. and addition to previous, before you say I like to scare people. :skullz:

About every update before that worked about 100%, 15.x versions, 18.x so on...
Max Noskill  [author] Mar 8 @ 9:01am 
No, your savegame is safe... sort of. You most likely lose serverconfig.xml though.

Game is playable after minor version (18.x) updates but it could be 'off' in certain ways.

For example: I had unfortunate accident with 18.2 config and even I think I restored it with same values, the biomes and ground height were a bit off. Player build structures remained and ground level was unchanged on those.

This is alpha version game anyways so everything is possible and I rather think losing that the savegame during the update is eventuality, not only possibility. Game developers usually warned if saves totally break on release notes.

MATU Mar 8 @ 6:25am 
When I update the server to a newer version, do I lose the savegame ? Or can I continue the same savegame when the version changes ?
Max Noskill  [author] Feb 28 @ 3:25pm 
Would my :lunar2019coolpig: pokerface hold?
Max Noskill  [author] Feb 26 @ 2:41pm 
If you create an user for the server which does not have root privileges, install the server via steamcmd etc., does the server work normally under that account?

https://developer.valvesoftware.com/wiki/SteamCMD

I'm sort of betting my money on that... :lunar2019coolpig: