Linux

Install a Teamspeak server on Linux

Teamspeak is a popular voice chat program that allows you to have an audio conference with your friends, family, or coworkers; it is very useful especially when you need to hold a voice chat with many people at the same time.

If are interested in voice chats, you may have already used the similar feature provided by many instant messengers, like MSN Messenger or Skype. They work well, but they have a limit: they can support only few people on the chat at the same time (usually 5/10 people at maximum).
This limit is more than enough for many home users, but you may have experienced cases where you needed to support many more people. Playing a multi-players game is often a scenario for needing support for so many people.
Beside the above presentation, in this guide I am assuming that you are familiar with the Teamspeak’s client and probably you have already used it to connect to a third-party’s server, but eventually you found the need to host your own server.
Furthermore, as the title suggest, this guide only cover (for the moment …) the installation of the server on a Linux platform. In specific I tested it on Kubuntu since the 7.04 version and later versions; for the most parts this guide should work on any major Linux distribution, but be ready to have to adapt some step.
So, how do you get a Teamspeak server working:

  1. First, download the Teamspeak server package from the Teamspeak’s Download page;
  2. Open a terminal windows;
  3. For security reasons you should NOT run the server as either root nor as your regolar user account, so you should create a dedicated user account for the server (for the sake of simplicity, we call it “teamspeak” as the server.
    First you need to create the teamspeak group by typing:

    sudo groupadd teamspeak

    Then you can create the teamspeak user by typing:

    sudo useradd -g teamspeak teamspeak -s /sbin/nologin

    The “-g” flag indicates the group where the user will be added to and “-s” will disallow this user from logging interactively in to the system (since it is used to manage a single service, it should have no other access to the system).

  4. Normally when you create an user you should automatically get its directory in /home/; if it is not the case, type:

    sudo mkdir /home/teamspeak

  5. Go to the directory where you downloaded the install package of Teamspeak and copy it to the /home/teamspeak/ directory (noted that in the following commands I will use the file name of the latest version available when writing this guide – you should change the names accordingly):

    sudo cp ts2_server_rc2_202319.tar.bz2 /home/teamspeak

  6. Go to the /home/teamspeak/ directory and uncompress the package:

    sudo tar -jxvf ts2_server_rc2_202319.tar.bz2

  7. The extraction should have created a “tss2_rc2” directory inside “/home/teamspeak/”; in order to have a standardized installation (that in many cases should be compatible with the future versions of Teamspeak) we should set the /home/teamspeak/ as base directory for the server:

    cd tss2_rc2

    sudo cp * -R /home/teamspeak

    cd ..

    sudo rm tss2_rc2 -R -f

  8. As for today, May, 23rd 2008, the developers of Teamspeak are offering an update to the server executable, but they are offering it as separate and uncompressed download instead of rebuilding the install package. If you downloaded the update in this way, go back to the download directory and directly copy it to /home/teamspeak/:

    sudo cp -f server_linux /home/teamspeak

  9. Now you need to set the “teamspeak” user you created earlier to own all the Teamspeak’s files. Type:

    sudo chgrp -R teamspeak /home/teamspeak

    sudo chown -R teamspeak /home/teamspeak

  10. In some system, once unpacked from the .tar.bz pacakge, the Teamspeak executable is not actually executable. In order to make it so, type:

    sudo chmod a+x /home/teamspeak/server_linux

  11. Some Teamspeak’s files, like the configuration file and the database of the channels and users, are created only after the first run of the server, so before continuing with the configuration lets run the plain Teamspeak for few second. First type:

    sudo -u teamspeak ./teamspeak2-server_startscript start

    Wait a couple of seconds and than type:

    sudo -u teamspeak ./teamspeak2-server_startscript stop

  12. Now you can create the system service needed to run the Teamspeak server when your system boot (unfortunatelly this is still a manual process). To create the service file type:

    sudo vim /etc/init.d/teamspeak

    I suggested to use vim since we are working from the console, but you can use any graphical editor without problems (from example kwrite o gedit). The code of the service is the following:

    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: teamspeak
    # Required-Start: networking
    # Required-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop: S 0 1 6
    # Short-Description: TeamSpeak Server Daemon
    # Description: Starts/Stops/Restarts the TeamSpeak Server Daemon
    ### END INIT INFO
    set -e
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DESC=”TeamSpeak Server”
    NAME=teamspeak
    USER=teamspeak
    DIR=/home/teamspeak
    DAEMON=$DIR/server_linux
    #PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    # Gracefully exit if the package has been removed.
    test -x $DAEMON || exit 0
    d_start() {
    start-stop-daemon –start –quiet
    –chuid $USER
    –chdir $DIR
    –exec $DAEMON
    > /dev/null
    || echo -n ” already running”
    }
    d_stop() {
    start-stop-daemon –stop –quiet
    –chuid $USER
    –chdir $DIR
    –exec $DAEMON
    || echo -n ” not running”
    }
    case “$1” in
    start)
    echo -n “Starting $DESC: $NAME”
    d_start
    echo “.”
    ;;
    stop)
    echo -n “Stopping $DESC: $NAME”
    d_stop
    echo “.”
    ;;
    restart|force-reload)
    echo -n “Restarting $DESC: $NAME”
    d_stop
    sleep 15
    d_start
    echo “.”
    ;;
    *)
    echo “Usage: $SCRIPTNAME {start|stop|restart|force-reload}” >&2
    exit 3
    ;;
    esac
    exit 0

    Save and exit from the text editor.

  13. Next you need to make the above script executable:

    sudo chmod a+x /etc/init.d/teamspeak

  14. To test if the script will work as expected, type:

    sudo /etc/init.d/teamspeak start

    “Unfortunately” in my case it worked right away, so right now I do not have any idea about possible errors. If you find some please post it as a comment. 😀

  15. The above script is not yet fully capable to automatically work on all init run levels. To finish the job you have to input the follwing commands:

    cd /etc/rc0.d

    sudo ln -s ../init.d/teamspeak K21teamspeak

    cd /etc/rc1.d

    sudo ln -s ../init.d/teamspeak K21teamspeak

    cd /etc/rc2.d

    sudo ln -s ../init.d/teamspeak S21teamspeak

    cd /etc/rc3.d

    sudo ln -s ../init.d/teamspeak S21teamspeak

    cd /etc/rc4.d

    sudo ln -s ../init.d/teamspeak S21teamspeak

    cd /etc/rc5.d

    sudo ln -s ../init.d/teamspeak S21teamspeak

    cd /etc/rc6.d

    sudo ln -s ../init.d/teamspeak K21teamspeak

    Now the server will always start when you boot your machine and properly shut down when you either shut down the computer or merely reboot it.

When dealing with server applications, the install process is only half of the job and a great dealing of attention must be made to the configuration. Unfortunately, for the moment my guide stops here. I am already thinking to continue it with the configuration steps, but if you have the urge to finish the job now, you can find information on the below links and by Goolging around.
Links
Teamspeak’s home page: https://www.teamspeak.com/
Teamspeak’s download page: https://www.teamspeak.com/?page=downloads.
A (very good and especially complete) alternative guide: https://ubuntuforums.org/showthread.php?t=236834
This guide has been inspired by a similar guide made by the user “tja” in the Ubuntu’s forum; you can find the original post at https://ubuntuforums.org/showthread.php?t=236834.
The Teamspeak’s logo is copyrighted by TeamSpeak Systems GmbH.

Marco Di Fresco