Skip to content

Config Files

Both the client and the server can execute config files containing console commands. The format and the location are identical for both; only the file names differ:

Component File When it runs
Client cfg/autoexec.cfg once, during client startup
Server cfg/server.cfg during server startup, before endpoints go live

Config files live in the cfg subdirectory of the installation.

Syntax

  • One command per line. A ; can also separate commands on the same line.
  • # starts a comment that runs until the end of the line.
  • Wrap arguments containing spaces in double quotes. The quotes are removed when the command executes; a literal " inside an argument is not supported.
cfg/autoexec.cfg
# Set a convar to a value containing spaces
cvar_example "You can set variables"

echo Config loaded

Execution model

Config files are read by the exec command, which tokenizes the file and feeds each command into the console input queue as if it had been typed.

  • The .cfg extension is optional when calling exec; it is appended automatically when missing.
  • exec only opens files inside the cfg directory. Paths escaping that directory (e.g. via ..) are rejected.
  • Some settings can only be changed from config files, while others refuse changes coming from them. The Flags column in the Console Reference tells you which applies.
  • exec cannot be used from UGC script code.

Server specifics

The server expects cfg/server.cfg to exist and executes it blocking during startup, before network endpoints are configured. If the file is missing, the server logs a hint to rename the shipped server.cfg.example and restart.

Because execution is blocking, server.cfg is the right place for settings that must be active before the server accepts connections, such as sv_bindaddr. See Server Configuration for a walkthrough.