Setting up a CS2D (formerly known as Counter-Strike 2D) server on Ubuntu can be a straightforward process when you have the right instructions. In this guide, we’ll walk you through each step, from adding necessary architecture and packages to configuring the service to start on boot.

Add i386 Architecture and Install Dependencies

First, ensure your system is equipped with the necessary architecture and packages by executing the following commands:

sudo dpkg --add-architecture i386
sudo apt update -y
sudo apt install -y curl nano unzip libc6:i386

Add a New Linux User

Create a dedicated user for running the CS2D server with the following command:

sudo adduser cs2d

Download CS2D Server Files

Move to the directory of the newly created user and download the CS2D server files using the following command:

cd /home/cs2d
curl -sSL https://cs2d-serverlist.erpa.cc/cs2d_server_downloader.sh | bash

Grant Permissions and Change Ownership

Ensure the server files have the necessary permissions and are owned by the ‘cs2d’ user:

sudo chmod +x cs2d_dedicated
sudo chown -R cs2d:cs2d /home/cs2d

Create a Service Unit File

Create a service unit file for CS2D server:

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

Paste the following contents into the file:

[Unit]
Description=CS2D Dedicated Server
After=network.target

[Service]
Type=simple
User=cs2d
WorkingDirectory=/home/cs2d
ExecStart=/home/cs2d/cs2d_dedicated
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Reload systemd and Enable Service

Reload systemd to apply the changes and enable the cs2d service to start on boot:

sudo systemctl daemon-reload
sudo systemctl enable cs2d

Add IP-Tables Rule

To prevent CS2D from crashing due to empty UDP packets, add the following IP-Tables rule:

sudo iptables -A INPUT -p udp --dport 36963 -m length --length 0:28 -j DROP

Start the Service

Finally, start the cs2d service:

sudo systemctl start cs2d

With these steps completed, your CS2D server should now be up and running smoothly on your Ubuntu system. Enjoy gaming with your friends on your very own server!