Skip to content

Instantly share code, notes, and snippets.

@cmackenzie1
Created February 2, 2026 03:16
Show Gist options
  • Select an option

  • Save cmackenzie1/c8a873e176cfd719ad0783e3e2de66b7 to your computer and use it in GitHub Desktop.

Select an option

Save cmackenzie1/c8a873e176cfd719ad0783e3e2de66b7 to your computer and use it in GitHub Desktop.
# Install dependencies
sudo apt update
sudo apt install -y xz-utils
# Create factorio user
sudo useradd -m -r -s /bin/bash factorio
# Download and extract Factorio headless server
cd /opt
sudo curl -L -o factorio-headless.tar.xz "https://factorio.com/get-download/stable/headless/linux64"
sudo tar -xf factorio-headless.tar.xz
sudo chown -R factorio:factorio /opt/factorio
sudo rm factorio-headless.tar.xz
# Generate initial save file
sudo -u factorio /opt/factorio/bin/x64/factorio --create /opt/factorio/saves/world.zip
# Create systemd service
sudo tee /etc/systemd/system/factorio.service > /dev/null <<EOF
[Unit]
Description=Factorio Dedicated Server
After=network.target
[Service]
Type=simple
User=factorio
Group=factorio
WorkingDirectory=/opt/factorio
ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/world.zip --server-settings /opt/factorio/data/server-settings.json
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
# Copy and edit server settings
sudo cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json
sudo chown factorio:factorio /opt/factorio/data/server-settings.json
# Edit settings (set name, description, password, etc.)
sudo nano /opt/factorio/data/server-settings.json
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable factorio
sudo systemctl start factorio
# Check status
sudo systemctl status factorio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment