7 Days to Die

7 Days to Die

124 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.
3
7
2
   
Award
Favorite
Favorited
Unfavorite
Foreword
Update to alpha20 release. If you update from earlier version, remember polite toilet behavior: wipe old saves!

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

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 a video guide by [SAO] BigC90210.

Another important note:

Looks like older AMD's won't run anymore A20 version server. No can do. Anyways, for more than few players and large maps you'll want decent hardware and map generation took ages... installing server on new AMD hardware, for example Ryzen 9 3900X works fine.
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, try first the text editor nano which should be pre-installed already for you. See next section for list of suggested programs and how to install them. Otherwise just use whatever editor suits you.
Step 3: Install SteamCMD
Download SteamCMD:


Open the package:

tar xvzf steamcmd_linux.tar.gz

Remove install package:

rm steamcmd_linux.tar.gz

Step 3.1: Installing additional software

Note: if you don't have wget installed, you can install it (as root):

apt-get install wget

Problems running steamcmd on Ubuntu? You might need to install lib32gcc1:
apt-get install lib32gcc1

If you haven't used any command line editor before, let's install text editor nano (most likely this is pre-installed).

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 than screen, but screen is no-brainer.

apt-get install byobu
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>.

force_install_dir ./7daysded login anonymous 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.

Generation times for size 8192x8192 map:

Time
CPU
Server version
20 minutes
Intel i7-6700K
A19
1 hour
AMD Phenom II X4 B55
A19
5 min, 42 sec
AMD Ryzen 9 3900X
A20

Server should write information about generation on logs and on telnet console. If absolutely nothing happens, restart the server as it's stuck. And yes, generation is single threaded.
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

In case server is stuck, crashed or in zombie state and does not want to die gracefully, use signal 9 SIGKILL:

# DESTROY the server, RAAAH! 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.

About world generators: SiliconPenguin on comment section said that server saves the worlds to "server_folder/data/worlds/" folder and modifications are installed to "server_folder/mods". Save data location is unchanged though so you can find them under .local.

Step 11: Editing serveradmin.xml
There is serveradmin.xml file on the save game directory:

$HOME/.local/share/7DaysToDie/Saves/serveradmin.xml

If it's not there, it will be auto-generated on the first run. So you can generate the map on the first run and then close the server & edit the file.

You can change the admin config file name and relative path on serverconfig.xml if you want to specify the admin file per server or use common settings for all servers.

serveradmin.xml identifies admins by their long Steam ID-numbers. These same numbered files contain player data, located at the save game directory.

About long steam IDs, if you open your profile page 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).
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, 26902 and additionally 26903 for LiteNetLib.

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
UDP
26903

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

This is example output:

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

You can install telnet from Turn Windows features on/off (at least in Win Pro version).

telnet yourlanserver 8081

You need to set the password for telnet connection, serverconfig.xml option TelnetPassword, otherwise it's not bound to other interfaces than to localhost (127.0.0.1).

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. You can actually use plus-operator for user u but Steam censores this line so this works as replacement around censorship.
chmod u=rwx myserverupdate.sh


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

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.
Appendix D: Wiping old saves
If you have used earlier versions, there are old save games on your server.

Release instructions for A20 required that you delete your old saves.

These are found on hidden directory .local including dot at the front which makes it hidden.

cd ~/.local/share/ rm -rf 7DaysToDie/

Which removes everything including player records. If you like to save your players data, you can go through the directory and delete only world related files.
Appendix E: A20 server crashes on old AMD hardware
Looks like A20 server won't work on old AMD hardware like AMD Phenom(tm) II X4 B55 Processor. Rest well, old work horse. Server version A19 works fine on Phenom. A20 server works fine on newer AMD processors, i.e. Ryzen-series.
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, Burnt Mummy, mambo05, KieSeyHow, SiliconPenguin

Changes:
22.12.2014: original version
19.02.2018: added old/experimental builds install option.
24.11.2019: updated to 18.1
30.08.2020 tested on A19 and Ubuntu 20.04.
18.10.2020 removed notes about using real Steam user account on SteamCMD scripts
29.11.2020 tested on Ubuntu 20.10.
01.12.2020 serveradmin.xml notes updated
08.12.2021 updated to A20 b238
20.03.2022 confirmed A20 does work on AMD but not on old AMDs
25.05.2022 added port forwarding 26903 UDP for LiteNetLib.
156 Comments
Max Noskill  [author] May 3 @ 10:54pm 
Hmm, have they moved the world save location around? I haven't touched this in ages, waiting when NPCs and quests are in place Q4 2025... (at this point everyone goes to ":D")

Well, thanks, I'll just add part that to save games.
SiliconPenguin May 3 @ 12:14pm 
Okay, I just decided to run a test, and it worked fine. So if you generate a world via the regular game client, or use a third party world generator such as Teragon, you just copy the generated world folder into the "server_folder/data/worlds/" folder. The saved game goes into the ".local/share/7DaysToDie/Saves/" folder. And the mods just go into the "server_folder/mods" folder.
SiliconPenguin May 3 @ 10:36am 
If anyone is still listening... Great guide by the way! I have a couple of questions: If I wanted to copy a generated world to the server, where exactly would I put it? And if I wanted to copy a saved game as well(for the previously mentioned generated world) , does that just go to the saved games folder? And is there a per saved game mod folder? If not, where exactly do you put the mods?
Max Noskill  [author] May 12, 2023 @ 4:46pm 
@Loumos:
Ah well, at this point all I can do to help you is a checklist:

* map generation is still going on?
* steam networking disabled?
* is there anything else running on current ports (see other previous comments)
* can you access server control console by using telnet from server itself to localhost (SSH to server and then run telnet localhost 8081)?
* does scanning with nmap or similar tool from outside reveal the server (UDP scan, default ports 29000-29003)?
* does your ISP/server hosting allow game servers? if you run any other game server, does it work?
Loumos May 12, 2023 @ 8:23am 
I am also having issues getting a connection to work. The server log file shows the server has successfully started, but I can not connect. I have opened all the correct ports on my server's system. I did so using "sudo ufw allow [port](/tcp)", but the server seems not to be listening or something. I go into the game and try to connect via IP and it cant retrieve server info.
Max Noskill  [author] Dec 12, 2022 @ 5:59am 
@Plankton: I meant is there already server running on 26900 as:
CreateBoundSocket: ::bind couldn't find an open port between 26900 and 26900

it's not necessarily 7dtd server.
Astarion Dec 11, 2022 @ 10:26pm 
@Max Noskill
Not sure what you mean by bound to external IP, but my ports should be fine.
https://prnt.sc/mTXUMvYao_rn
Max Noskill  [author] Dec 11, 2022 @ 11:19am 
@Plankton: is it actually bound to external IP and port reserved for server? Is there something else already using it?

2022-12-11T22:27:20 66.935 EXC Address already in use
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint localEP) [0x00043] in <6fcfdd162b5d4836bef3c96f53194db6>:0

CreateBoundSocket: ::bind couldn't find an open port between 26900 and 26900

2022-12-11T22:27:21 67.071 ERR [ Steamworks.NET ] Could not initialize GameServer
Astarion Dec 11, 2022 @ 5:44am 
I can't seem to get it to actually work. The output file seems fine. It's here just in case
https://pastebin.com/hBNePGDM
But when I, or anyone try to connect, it never actually works. Is it something I've done relating to the server end?
Max Noskill  [author] Oct 25, 2022 @ 12:09pm 
@Toastypaws_YT: but there is $HOME/.local/share/7DaysToDie/ directory?
if you do "ls -laR" it shows everything under it.

If not, I have to re-check things again, maybe new game version changes how directories are structured.