This tutorial explains how to setup a Counter-Strike: Global Offensive server on Arch Linux.
This tutorial assumes that you logged in with a standard user account and have sudo privileges. We will be using a normal user account because building packages with AUR should not be done from the root account.
Before You Begin
If you are using a 64-bit version of Arch Linux, it is very important that you have the
multilib repository enabled. If it is not enabled, SteamCMD cannot download or run the game server files. To enable multilib, simply uncomment the following lines in
[multilib] Include = /etc/pacman.d/mirrorlist
This does not apply to 32-bit Arch Linux systems.
There is an AUR package for SteamCMD. It is possibly the easiest way to install SteamCMD on Arch. There are a few things to note about it though:
- All relative paths are relative to
- To upgrade SteamCMD itself, you must be on the root account.
If you are on a 64-bit server, you must install the package
sudo pacman -Sy lib32-gcc-libs
Now we must build the package. Using curl, download the tarball for the package.
curl -O https://aur.archlinux.org/packages/st/steamcmd/steamcmd.tar.gz
Once the download finishes, extract and change to the directory created.
tar -xvzf steamcmd.tar.gz cd steamcmd
Now, using makepkg, build the package.
If you didn’t pass the
-i flag to the makepkg command, then use the following command to install it.
sudo pacman -U *.pkg.tar.xz
You now have SteamCMD installed and ready to download Counter-Strike: Global Offensive server.
Install The Counter-Strike: Global Offensive Server
This guide uses a separate user to run the server, so we will create a new csgo user and group with it’s own home folder in
sudo groupadd csgo sudo mkdir /var/lib/csgo sudo useradd -d /var/lib/csgo -g csgo -s /bin/bash csgo sudo chown csgo.csgo -R /var/lib/csgo
Now to install the server.
sudo -u csgo steamcmd +login anonymous +force_install_dir ~csgo/server +app_update 740 validate +quit
Once that finishes downloading, you have the server installed.
Although you can run the server, some configuration should be done so that the server isn’t too generic. The main file that we put settings in is the
server.cfg file. Below is a very basic
To open/create the file, use your favorite editor. I use vim in this example.
sudo -u csgo vim ~csgo/server/csgo/cfg/server.cfg
Add the following. More settings can be found on the Valve Developer Wiki. Be sure to change some of the settings to suit your needs.
hostname "Server Name" rcon_password "password" sv_password "" sv_contact "firstname.lastname@example.org" sv_tags "" sv_region "255" sv_lan "0" exec banned_user.cfg exec banned_ip.cfg writeid writeip
Running Your Server
To run your server unattended, you will need a multiplexer like GNU Screen or tmux. In this article, I am going to use tmux to run the server, but if you prefer and know how to use screen, feel free to use it.
Install tmux by using pacman.
sudo pacman -Sy tmux
You can start the server with the following command. You can change the map if desired. Please read the “Final Notes” for more information on the
game_mode values. This example is for a classic casual server.
sudo -u csgo tmux new-session -d -s csgo-console -d 'cd /var/lib/csgo/server/; ./srcds_run -console -game csgo -usercon +game_type 0 +game_mode 0 +mapgroup mg_active +map de_dust2'
If you ever need to attach to the console, run the following.
sudo -u csgo tmux attach -t csgo-console
You can leave the server console by typing CTRL + B then releasing those keys and then pressing D.
Running With systemd
Running the server with systemd is convenient for many reasons. The main one is that you can have it start when the VPS starts. This requires a script and a systemd unit to be written. Even though this is a good idea, it is optional.
The first thing to write is the start script. To create the script, use your favorite editor. Here vim is used, but you can use any text editor like nano.
sudo -u csgo vim ~csgo/server/csgo.sh
Add the following and be sure to look at the line with the start command as it has the game mode and type.
#!/bin/sh USER=$2 if [ -z $2 ]; then USER="csgo" fi case "$1" in start) sudo -u $ tmux new-session -d -s csgo-console -d 'cd /var/lib/csgo/server/; /var/lib/csgo/server/srcds_run -console -game csgo -usercon +game_type 0 +game_mode 0 +mapgroup mg_active +map de_dust2' ;; stop) sudo -u $ tmux send-keys -t csgo-console 'say Server shutting down in 10 seconds!' C-m sleep 10 sudo -u $ tmux send-keys -t csgo-console 'quit' C-m sleep 5 ;; *) echo "Usage: $0 user" esac exit 0
Now you need to make the systemd unit.
sudo vim /usr/lib/systemd/system/csgo.service
Add the following.
[Unit] Description=Counter-Strike: Global Offensive Server (SRCDS) After=local-fs.target network.target [Service] ExecStart=/var/lib/csgo/server/csgo.sh start ExecStop=/var/lib/csgo/server/csgo.sh stop Type=forking [Install] WantedBy=multi-user.target
Now make sure the
csgo.sh file is executable.
sudo chmod +x ~csgo/server/csgo.sh
After all that, you can use
systemctl to start and stop the server. Also you can use it to make it start on boot.
sudo systemctl start csgo.service
sudo systemctl stop csgo.service
sudo systemctl restart csgo.service
To enable at boot:
sudo systemctl enable csgo.service
To disable at boot:
sudo systemctl disable csgo.service
Even though systemd handles starting and stopping the server, you can access the console with the following command.
sudo -u csgo tmux attach -t csgo-console
SteamCMD is installed in an area where only root can change files (see note in the “Install SteamCMD” section). If you ever need to upgrade SteamCMD itself, just run it as root.
sudo steamcmd +quit
If you need to update the server. First stop the server and then use SteamCMD to update (using the same command to install).
sudo systemctl stop csgo.service sudo -u csgo steamcmd +login anonymous +force_install_dir ~csgo/server +app_update 740 validate +quit sudo systemctl start csgo.service
The game mode and game type in the starting command are important depending on what kind of server you want. Here’s a quick table of the possible values.
Game Mode | game_type | game_mode Classic Casual | 0 | 0 Classic Competitive | 0 | 1 Arms Race | 1 | 0 Demolition | 1 | 1 Deathmatch | 1 | 2
There are a lot more configuration topics not covered in this tutorial. If you need more information, please refer to the Valve Developer Wiki.