Garry’s Mod on CentOS 7
Updated by Linode Contributed by Julian Meyer
This is a Linode Community guide. Write for us and earn $250 per published guide.
Garry’s Mod enables complete control and modification of the video game engine, Source Engine. With Garry’s Mod, you can create almost any game you want. Setting up a Garry’s Mod server is a great way to play with friends over the internet while maintaining control over the server.
This guide shows how to create, maintain, and secure a Garry’s Mod server.
Before You Begin
Complete our guide: Install SteamCMD for a Steam Game Server. This will get SteamCMD installed and running on your Linode and this guide will pick up where the SteamCMD page leaves off.
This guide is written for a non-root user. Commands that require elevated privileges are prefixed with
sudo. If you’re not familiar with the
sudocommand, you can check our Users and Groups guide.
Prerequisites for Garry’s Mod
From the SteamCMD guide, two additional steps are needed specifically for Gmod.
Add a firewall rule. This command assumes that you have only the firewalld rules in place from the SteamCMD guide. This inserts a rule for port 10999 after the pre-existing rules for SteamCMD.
sudo firewall-cmd --zone=public --add-port=27000 27030/udp --permanent
Install an additonal 32-bit package:
sudo yum install ncurses-libs.i686
Install Garry’s Mod
Be sure you are in the directory
~/Steam, then access the
cd ~/Steam && ./steamcmd.sh
From the SteamCMD prompt, login anonymously:
Or log in with your Steam username:
Install Gmod to the
Steamuser’s home directory:
force_install_dir ./gmod app_update 4020 validate
This can take some time. If the download looks as if it has frozen, be patient. Once the download is complete, you should see this output:
1 2 3
Success! App '4020' fully installed. Steam>
To update Gmod, run the above 4 commands again.
Configure Garry’s Mod
This section configures different aspects of the server, including gamemode and workshop addons.
Create a startup script for Gmod with the following contents:
1 2 3 4
#!/bin/sh cd ./Steam/gmod screen -S "Garry's Mod Server" ./srcds_run -game garrysmod +maxplayers 20 +map gm_flatgrass
When run, the script will change directories to
~/Steam/gmodand execute Garry’s Mod in a Screen session. The
srcds_runbinary can take many more arguments which you can see at Valve’s Developer wiki.
Make the script executable:
chmod +x ~/startgmod.sh
The Garry’s Mod wiki has instructions to use a script to update Gmod rather than manually through SteamCMD. See under Installing Garry’s Mod.
Automatic Startup After Server Reboots
This will automatically restart Garry’s Mod when your server reboots.
Open Crontab (this will open in
Enter the startup command. Be sure that the binary flags are the same as in your startup script.
@reboot /home/steam/Steam/gmod/srcds_run -game garrysmod +maxplayers 20 +map gm_flatgrass
vim, press Esc, then type :x and hit Enter.
Server Config File
server.cfg file is blank, and any configuration options you want to specify for the server must be added. This are optional, but below is a sane starting point.
1 2 3 4 5 6 7 8
hostname "server_hostname" sv_password "server_password" sv_timeout 60 rcon_password "rcon_password" mp_autoteambalance 1 mp_limitteams 1 writeid writeip
Create a collection of addons you want to install on your server at Garry’s Mod Collections. You will need to be logged in to Steam.
Note the collection ID. It is located at the end of the url, denoted by the ‘X’s here:
Acquire a Steam API key from the Steam API Keys page. Note the key.
Paste the Steam API key and Workshop Collection ID into your startup script. For example:
./srcds_run +maxplayers 20 +gamemode terrortown +map cs_office -authkey YOURKEYGOESHERE +host_workshop_collection 157384458
This sets the game for the Trouble in Terrorist Town (TTT) gamemode, but can be changed to your desired gamemode, if you have it downloaded.
For more info on Workshop Addons, see Workshop for Dedicated Servers in the Garry’s Mod wiki.
Using the Server
Now that your server is installed and configured, it can be launched by running the
startgmod.shscript from your
steamuser’s home directory.
cd ~/ && ./startgmod.sh
From this point, do not press the Control+C keys while in the console unless you want to stop Gmod.
To detach from the screen session running the server console, press these two key combinations in succession:
To bring the console back, type the following command:
To stop the server, bring back the Gmod console and press CONTROL + C.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This guide is published under a CC BY-ND 4.0 license.