Skip to content

Instantly share code, notes, and snippets.

@othyn
Last active November 12, 2025 13:31
Show Gist options
  • Save othyn/e1287fd937c1e267cdbcef07227ed48c to your computer and use it in GitHub Desktop.
Save othyn/e1287fd937c1e267cdbcef07227ed48c to your computer and use it in GitHub Desktop.

Revisions

  1. othyn revised this gist Mar 26, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,14 @@ So, with credit to [the Factorio wiki](https://wiki.factorio.com/Multiplayer#Lin
    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a Factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of Factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.

    *Just a note to newcomers:* If there are any issues with the installation steps, people in the comments are doing a good job at mentioning steps required by newer installations. I don't really play anymore and haven't setup or managed a Factorio server in years, so I'll advise if something isn't working to check the comments and forks. Much love <3

    ## Alternate
    If you prefer a simple, automated setup, [Bisa has a really handy init script that will do most of the work for you!](https://github.com/Bisa/factorio-init)

    ### Docker
    I'm very much into Docker these days, in which there is a [brilliant container setup and ready](https://github.com/factoriotools/factorio-docker) for this if you wish to use that instead.

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for Factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
  2. othyn revised this gist Nov 14, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -86,6 +86,8 @@ If you do make any configuration changes, you'll need to restart the service `su
    ## Step Finished :: Play!
    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and ~~play~~ spend hours labouring over tiny details to maximize efficiency!

    ##### TODO: How to upgrade. Install/setup bash script?
    #### TODO:
    - How to upgrade
    - How to create/scp your own save (re-apply chown)

    With a quick shout out to [dillinger.io](http://dillinger.io/) for making MD editing a more pleasant experience...
  3. othyn revised this gist Nov 14, 2016. No changes.
  4. othyn revised this gist Nov 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.
    The version of Factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.

    ## Alternate
    If you prefer a simpler setup, [Bisa has a really handy init script that will do most of the work for you!](https://github.com/Bisa/factorio-init)
    If you prefer a simple, automated setup, [Bisa has a really handy init script that will do most of the work for you!](https://github.com/Bisa/factorio-init)

    ## Prerequisites
    - *nix distro, setup and ready to go
  5. othyn revised this gist Nov 14, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,8 @@ If you prefer a simpler setup, [Bisa has a really handy init script that will do
    ## Step 0 :: Patches & Security!
    With it being a fresh installation, as with any OS, make sure to update your system. Run `sudo apt update && sudo apt full-upgrade`. This will first check the relevant repo's for package updates, then run the [update process](http://askubuntu.com/a/226213/437013).

    If your server is running from behind your edge router/firewall, then enabling the firewall isn't a necessary step. So skip to the next step if you don't want to enable it.

    I like to enable the firewall before getting started on setup, just personal preference. This is as simple as `sudo ufw enable`. UFW being [Uncomplicated Firewall](https://help.ubuntu.com/community/UFW), in which it really is!

    Let's allow Factorio through on its default port (or a port of your chosing), `sudo ufw allow 34197/udp`. You may also want to allow SSH connections through at this point, if you are using it.
  6. othyn revised this gist Nov 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ If you prefer a simpler setup, [Bisa has a really handy init script that will do
    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for Factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
    - *Optional* - Setup SSH for remote access, this may be handy if you wish to upload/download saves via `scp` [(?)](https://linux.die.net/man/1/scp)
    - *Optional* - Setup SSH for remote access, this may be handy if you wish to upload/download saves via `scp` [(?)](https://linux.die.net/man/1/scp). If you would like to do this, it's recommended that you [disable password login and use SSH keys](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04).
    - *Tip* - If you ever miss `sudo` from the beginning of a command, `sudo !!` will repeat it, but elevated.
    - That's it!

  7. othyn revised this gist Nov 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ If you prefer a simpler setup, [Bisa has a really handy init script that will do
    - That's it!

    ## Step 0 :: Patches & Security!
    With it being a fresh installation, as with any OS, make sure to update your system. Run `sudo apt-get update && sudo apt-get dist-upgrade`. This will first check the relevant repo's for package updates, then run the [update process](http://askubuntu.com/a/226213/437013).
    With it being a fresh installation, as with any OS, make sure to update your system. Run `sudo apt update && sudo apt full-upgrade`. This will first check the relevant repo's for package updates, then run the [update process](http://askubuntu.com/a/226213/437013).

    I like to enable the firewall before getting started on setup, just personal preference. This is as simple as `sudo ufw enable`. UFW being [Uncomplicated Firewall](https://help.ubuntu.com/community/UFW), in which it really is!

  8. othyn revised this gist Nov 14, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@ So, with credit to [the Factorio wiki](https://wiki.factorio.com/Multiplayer#Lin
    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a Factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of Factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.

    ## Alternate
    If you prefer a simpler setup, [Bisa has a really handy init script that will do most of the work for you!](https://github.com/Bisa/factorio-init)

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for Factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
  9. othyn revised this gist Nov 13, 2016. No changes.
  10. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -83,4 +83,4 @@ That's it! You should now have a working Factorio server. Head over to your clie

    ##### TODO: How to upgrade. Install/setup bash script?

    With thanks to [dillinger.io](http://dillinger.io/) as ever for making MD editing a more pleasant experience...
    With a quick shout out to [dillinger.io](http://dillinger.io/) for making MD editing a more pleasant experience...
  11. othyn revised this gist Nov 13, 2016. 1 changed file with 16 additions and 14 deletions.
    30 changes: 16 additions & 14 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    # [LINUX] Factorio Headless Server Guide
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records, with thanks to [dillinger.io](http://dillinger.io/) as ever for making MD editing a nice experience...
    So, with credit to [the Factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a Factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.
    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a Factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of Factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
    - The UDP port used for Factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
    - *Optional* - Setup SSH for remote access, this may be handy if you wish to upload/download saves via `scp` [(?)](https://linux.die.net/man/1/scp)
    - *Tip* - If you ever miss `sudo` from the beginning of a command, `sudo !!` will repeat it, but elevated.
    - That's it!
    @@ -16,16 +16,16 @@ With it being a fresh installation, as with any OS, make sure to update your sys

    I like to enable the firewall before getting started on setup, just personal preference. This is as simple as `sudo ufw enable`. UFW being [Uncomplicated Firewall](https://help.ubuntu.com/community/UFW), in which it really is!

    Let's allow factorio through on its default port (or a port of your chosing), `sudo ufw allow 34197/udp`. You may also want to allow SSH connections through at this point, if you are using it.
    Let's allow Factorio through on its default port (or a port of your chosing), `sudo ufw allow 34197/udp`. You may also want to allow SSH connections through at this point, if you are using it.

    As this is an internet facing server, you may want to install and configure something like `fail2ban` to help with repeated non-authorised login attempts, but that is up to you.

    ## Step 1 :: Download
    I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from factorio's download site via `wget` onto the server.
    I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from Factorio's download site via `wget` onto the server.
    ```
    wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.14.20/headless/linux64
    ```
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require (stable or experimental). Easiest way to find out the url is to go to [the factorio server download page](https://www.factorio.com/download-headless/stable) and find the url from the link provided under the version number.
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require (stable or experimental). Easiest way to find out the url is to go to [the Factorio server download page](https://www.factorio.com/download-headless/stable) and find the url from the link provided under the version number.

    Also, as they redirect download requests, `wget` will not name the file correctly. The easiest way to rectify it is to manually set the file name using the `-O` flag and manually providing the file name as used in the example above.

    @@ -36,20 +36,20 @@ Factorio runs out of the `/opt` directory, [a directory resevered in UNIX for no

    So before extracting the headless archive, lets change our working directory, `cd /opt`.

    Now its time to extract the headless archive, `sudo tar -xzf ~/factorio_headless.tar.gz`. The `-xzf` [flags](https://linux.die.net/man/1/tar) are basically; e`x`tract a g`z`ipped archive `f`ile. This will extract the downloaded archive to your current directory, and should have created a factorio folder. You can check that `/opt/factorio` exists by running `ls` [(?)](http://man7.org/linux/man-pages/man1/ls.1.html), and seeing if the `factorio` directory is listed, as we are working out of `/opt` already.
    Now its time to extract the headless archive, `sudo tar -xzf ~/factorio_headless.tar.gz`. The `-xzf` [flags](https://linux.die.net/man/1/tar) are basically; e`x`tract a g`z`ipped archive `f`ile. This will extract the downloaded archive to your current directory, and should have created a Factorio folder. You can check that `/opt/factorio` exists by running `ls` [(?)](http://man7.org/linux/man-pages/man1/ls.1.html), and seeing if the `factorio` directory is listed, as we are working out of `/opt` already.

    Just for the sake of keeping things tidy, I'd also delete the downloaded archive `rm ~/factorio_headless.tar.gz`, as we are now finished with it.

    If you wish to add any mods or saves, you can do so by first creating the `mods` and `saves` directories within `/opt/factorio`. `sudo mkdir /opt/factorio/saves` and `sudo mkdir /opt/factorio/mods` should achieve this, then you may copy the save & mod archives into the relevant folders.

    ## Step 3 :: Environment
    As you don't want factorio running as root, let's setup a user that it can run under. The user won't need a lot of functionality, as it's only going to be running factorio and won't need to be logged into, so let's provide some flags to create a really basic user:
    As you don't want Factorio running as root, let's setup a user that it can run under. The user won't need a lot of functionality, as it's only going to be running Factorio and won't need to be logged into, so let's provide some flags to create a really basic user:

    `sudo adduser --disabled-login --no-create-home --gecos factorio factorio`

    [The above command](http://www.unix.com/man-page/linux/8/adduser/) will add a user, not setting a password `--disabled-login`, without creating a home directory in `/home` `--no-create-home`, [without asking for user information](https://en.wikipedia.org/wiki/Gecos_field) `--gecos`, create user `factorio` and add them/create the group `factorio`.

    Now that the new user is created, we need to make it the owner of the factorio directory so that it can access and perform operations within it, `sudo chown -R factorio:factorio /opt/factorio`. The `-R` [flag being recursive](https://linux.die.net/man/1/chown).
    Now that the new user is created, we need to make it the owner of the Factorio directory so that it can access and perform operations within it, `sudo chown -R factorio:factorio /opt/factorio`. The `-R` [flag being recursive](https://linux.die.net/man/1/chown).

    ## Step 4 :: Factorio Configuration
    Factorio headless, as of 0.14.12, requires a [JSON formatted config file](https://wiki.factorio.com/Multiplayer#Dedicated.2FHeadless_server). They provide an example one to get you started, in which can be copied and then edited to suit your requirements.
    @@ -59,7 +59,7 @@ First, lets change directory `cd /opt/factorio/data` where the `server-settings.
    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server). Configure it as you wish, save, exit and proceed onto the next step.

    ## Step 5 :: systemd
    So, we want factorio to run as a service. So lets create a new service for factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do `sudo nano /etc/systemd/system/factorio.service`. The service should contain the following:
    So, we want Factorio to run as a service. So lets create a new service for Factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do `sudo nano /etc/systemd/system/factorio.service`. The service should contain the following:
    ```
    [Unit]
    Description=Factorio Headless Server
    @@ -70,15 +70,17 @@ User=factorio
    ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/{save_file}.zip --server-settings /opt/factorio/data/server-settings.json
    ```

    Change the `{save_file}` for the file name of your save. You may also want to swap out `--start-server /opt/factorio/saves/{save_file}.zip` for `--start-server-load-latest`, which will automatically pull through the latest version of your world across manual and auto saves.
    Change the `{save_file}` for the file name of your save. You may also want to swap out `--start-server /opt/factorio/saves/{save_file}.zip` for `--start-server-load-latest`, which will automatically pull through the latest version of your world across manual and auto saves. If you wish to look at more parameters, there is more information on the [Factorio multiplayer wiki](https://wiki.factorio.com/Multiplayer#Linux).

    Save the file and exit. Time to start the service and see if our setup has worked!

    Firstly, reload the available service daemons `systemctl daemon-reload`, now start the newly created service `systemctl start factorio` and see if it's running `systemctl status factorio.service`. That is the output from the factorio server, any errors or configuration issues will present themselves here if you ever need to debug.
    Firstly, reload the available service daemons `systemctl daemon-reload`, now start the newly created service `systemctl start factorio` and see if it's running `systemctl status factorio.service`. That is the output from the Factorio server, any errors or configuration issues will present themselves here if you ever need to debug.

    If you do make any configuration changes, you'll need to restart the service `sudo systemctl restart factorio.service`.

    ## Step Finished :: Play!
    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and ~~play~~ spend hours labouring over tiny details to maximize efficiency!

    ##### TODO: How to upgrade. Install/setup bash script?
    ##### TODO: How to upgrade. Install/setup bash script?

    With thanks to [dillinger.io](http://dillinger.io/) as ever for making MD editing a more pleasant experience...
  12. othyn revised this gist Nov 13, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -70,6 +70,8 @@ User=factorio
    ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/{save_file}.zip --server-settings /opt/factorio/data/server-settings.json
    ```

    Change the `{save_file}` for the file name of your save. You may also want to swap out `--start-server /opt/factorio/saves/{save_file}.zip` for `--start-server-load-latest`, which will automatically pull through the latest version of your world across manual and auto saves.

    Save the file and exit. Time to start the service and see if our setup has worked!

    Firstly, reload the available service daemons `systemctl daemon-reload`, now start the newly created service `systemctl start factorio` and see if it's running `systemctl status factorio.service`. That is the output from the factorio server, any errors or configuration issues will present themselves here if you ever need to debug.
  13. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ Factorio headless, as of 0.14.12, requires a [JSON formatted config file](https:

    First, lets change directory `cd /opt/factorio/data` where the `server-settings.example.json` config file is located, it's not necessary, but just the way I do things. Now to make a copy of the config file under its working name `sudo cp server-settings.example.json server-settings.json` and then edit it with a text editor of your choice, I like nano as its easy `sudo nano server-settings.json`.

    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server).
    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server). Configure it as you wish, save, exit and proceed onto the next step.

    ## Step 5 :: systemd
    So, we want factorio to run as a service. So lets create a new service for factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do `sudo nano /etc/systemd/system/factorio.service`. The service should contain the following:
  14. othyn revised this gist Nov 13, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,9 @@ Factorio runs out of the `/opt` directory, [a directory resevered in UNIX for no

    So before extracting the headless archive, lets change our working directory, `cd /opt`.

    Now its time to extract the headless archive, `sudo tar -xzf ~/factorio_headless.tar.gz`. The `-xzf` [flags](https://linux.die.net/man/1/tar) are basically; e`x`tract a g`z`ipped archive `f`ile. This will extract the downloaded archive to your current directory, and should have created a factorio folder. You can check that `/opt/factorio` exists by running `ls` [(?)](http://man7.org/linux/man-pages/man1/ls.1.html), and seeing if the `factorio` directory is listed, as we are working out of `/opt` already. Just for the sake of keeping things tidy, I'd also delete the downloaded archive `rm ~/factorio_headless.tar.gz`, as we are now finished with it.
    Now its time to extract the headless archive, `sudo tar -xzf ~/factorio_headless.tar.gz`. The `-xzf` [flags](https://linux.die.net/man/1/tar) are basically; e`x`tract a g`z`ipped archive `f`ile. This will extract the downloaded archive to your current directory, and should have created a factorio folder. You can check that `/opt/factorio` exists by running `ls` [(?)](http://man7.org/linux/man-pages/man1/ls.1.html), and seeing if the `factorio` directory is listed, as we are working out of `/opt` already.

    Just for the sake of keeping things tidy, I'd also delete the downloaded archive `rm ~/factorio_headless.tar.gz`, as we are now finished with it.

    If you wish to add any mods or saves, you can do so by first creating the `mods` and `saves` directories within `/opt/factorio`. `sudo mkdir /opt/factorio/saves` and `sudo mkdir /opt/factorio/mods` should achieve this, then you may copy the save & mod archives into the relevant folders.

  15. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -77,4 +77,4 @@ If you do make any configuration changes, you'll need to restart the service `su
    ## Step Finished :: Play!
    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and ~~play~~ spend hours labouring over tiny details to maximize efficiency!

    ### TODO: How to upgrade. Install/setup bash script?
    ##### TODO: How to upgrade. Install/setup bash script?
  16. othyn revised this gist Nov 13, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,6 @@ So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Lin
    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.

    *TODO: How to upgrade. Install/setup bash script?*

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
    @@ -77,4 +75,6 @@ Firstly, reload the available service daemons `systemctl daemon-reload`, now sta
    If you do make any configuration changes, you'll need to restart the service `sudo systemctl restart factorio.service`.

    ## Step Finished :: Play!
    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and ~~play~~ spend hours labouring over tiny details to maximize efficiency!
    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and ~~play~~ spend hours labouring over tiny details to maximize efficiency!

    ### TODO: How to upgrade. Install/setup bash script?
  17. othyn revised this gist Nov 13, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records, with thanks to [dillinger.io](http://dillinger.io/) as ever for making MD editing a nice experience...

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.18`, although should work for any version of Factorio `0.14.12` and higher.
    The version of factorio I shall be using is `0.14.20`, although should work for any version of Factorio `0.14.12` and higher.

    *TODO: How to upgrade. Install/setup bash script?*

    @@ -25,9 +25,9 @@ As this is an internet facing server, you may want to install and configure some
    ## Step 1 :: Download
    I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from factorio's download site via `wget` onto the server.
    ```
    wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.14.17/headless/linux64
    wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.14.20/headless/linux64
    ```
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require. Easiest way to find out the url is to go to [the factorio server download page](https://www.factorio.com/download-headless/stable) and find the url from the link provided under the version number.
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require (stable or experimental). Easiest way to find out the url is to go to [the factorio server download page](https://www.factorio.com/download-headless/stable) and find the url from the link provided under the version number.

    Also, as they redirect download requests, `wget` will not name the file correctly. The easiest way to rectify it is to manually set the file name using the `-O` flag and manually providing the file name as used in the example above.

  18. othyn revised this gist Nov 13, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    # [LINUX] Factorio Headless Server Guide [0.14.18]
    # [LINUX] Factorio Headless Server Guide
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records, with thanks to [dillinger.io](http://dillinger.io/) as ever for making MD editing a nice experience...

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.18`.
    The version of factorio I shall be using is `0.14.18`, although should work for any version of Factorio `0.14.12` and higher.

    *TODO: How to upgrade. Install/setup bash script?*

  19. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # [LINUX] Factorio Headless Server Guide [0.14.18]
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records, thanks to [dillinger.io](http://dillinger.io/) for making MD editing a nice experience
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records, with thanks to [dillinger.io](http://dillinger.io/) as ever for making MD editing a nice experience...

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.18`.
  20. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ Factorio headless, as of 0.14.12, requires a [JSON formatted config file](https:

    First, lets change directory `cd /opt/factorio/data` where the `server-settings.example.json` config file is located, it's not necessary, but just the way I do things. Now to make a copy of the config file under its working name `sudo cp server-settings.example.json server-settings.json` and then edit it with a text editor of your choice, I like nano as its easy `sudo nano server-settings.json`.

    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference.](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server).
    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server).

    ## Step 5 :: systemd
    So, we want factorio to run as a service. So lets create a new service for factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do `sudo nano /etc/systemd/system/factorio.service`. The service should contain the following:
  21. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ Factorio headless, as of 0.14.12, requires a [JSON formatted config file](https:

    First, lets change directory `cd /opt/factorio/data` where the `server-settings.example.json` config file is located, it's not necessary, but just the way I do things. Now to make a copy of the config file under its working name `sudo cp server-settings.example.json server-settings.json` and then edit it with a text editor of your choice, I like nano as its easy `sudo nano server-settings.json`.

    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference to help you decide what information you'd like to configure](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server).
    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference.](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server).

    ## Step 5 :: systemd
    So, we want factorio to run as a service. So lets create a new service for factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do `sudo nano /etc/systemd/system/factorio.service`. The service should contain the following:
  22. othyn revised this gist Nov 13, 2016. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -72,6 +72,9 @@ ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/{sav

    Save the file and exit. Time to start the service and see if our setup has worked!

    Firstly, reload the available service daemons `systemctl daemon-reload`, now start the newly created service `systemctl start factorio` and see if it's running `systemctl status factorio.service`. That is the output from the factorio server, any errors or configuration issues will present themselves here if you ever need to debug. If you do make any configuration changes, you'll need to restart the service `sudo systemctl restart factorio.service`.
    Firstly, reload the available service daemons `systemctl daemon-reload`, now start the newly created service `systemctl start factorio` and see if it's running `systemctl status factorio.service`. That is the output from the factorio server, any errors or configuration issues will present themselves here if you ever need to debug.

    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and play!
    If you do make any configuration changes, you'll need to restart the service `sudo systemctl restart factorio.service`.

    ## Step Finished :: Play!
    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and ~~play~~ spend hours labouring over tiny details to maximize efficiency!
  23. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Lin
    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.18`.

    TODO: How to upgrade. Install/setup bash script?
    *TODO: How to upgrade. Install/setup bash script?*

    ## Prerequisites
    - *nix distro, setup and ready to go
  24. othyn revised this gist Nov 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # [LINUX] Factorio Headless Server Guide [0.14.18]
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records, thanks to [dillinger.io](http://dillinger.io/) for making MD editing a nice experience

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.18`.
  25. othyn revised this gist Nov 13, 2016. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    http://dillinger.io/

    # [LINUX] Factorio Headless Server Guide [0.14.18]
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

  26. othyn revised this gist Nov 13, 2016. 2 changed files with 79 additions and 21 deletions.
    79 changes: 79 additions & 0 deletions factorio_headless_guide.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    http://dillinger.io/

    # [LINUX] Factorio Headless Server Guide [0.14.18]
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd` (just for this guide, not a factorio headless requirement, [although most distros use it as standard now](https://en.wikipedia.org/wiki/Systemd#Adoption_and_reception)).
    The version of factorio I shall be using is `0.14.18`.

    TODO: How to upgrade. Install/setup bash script?

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for factorio, default `34197`, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
    - *Optional* - Setup SSH for remote access, this may be handy if you wish to upload/download saves via `scp` [(?)](https://linux.die.net/man/1/scp)
    - *Tip* - If you ever miss `sudo` from the beginning of a command, `sudo !!` will repeat it, but elevated.
    - That's it!

    ## Step 0 :: Patches & Security!
    With it being a fresh installation, as with any OS, make sure to update your system. Run `sudo apt-get update && sudo apt-get dist-upgrade`. This will first check the relevant repo's for package updates, then run the [update process](http://askubuntu.com/a/226213/437013).

    I like to enable the firewall before getting started on setup, just personal preference. This is as simple as `sudo ufw enable`. UFW being [Uncomplicated Firewall](https://help.ubuntu.com/community/UFW), in which it really is!

    Let's allow factorio through on its default port (or a port of your chosing), `sudo ufw allow 34197/udp`. You may also want to allow SSH connections through at this point, if you are using it.

    As this is an internet facing server, you may want to install and configure something like `fail2ban` to help with repeated non-authorised login attempts, but that is up to you.

    ## Step 1 :: Download
    I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from factorio's download site via `wget` onto the server.
    ```
    wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.14.17/headless/linux64
    ```
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require. Easiest way to find out the url is to go to [the factorio server download page](https://www.factorio.com/download-headless/stable) and find the url from the link provided under the version number.

    Also, as they redirect download requests, `wget` will not name the file correctly. The easiest way to rectify it is to manually set the file name using the `-O` flag and manually providing the file name as used in the example above.

    Wait for the file to download before proceeding.

    ## Step 2 :: Directories
    Factorio runs out of the `/opt` directory, [a directory resevered in UNIX for non-default software installation](http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/opt.html).

    So before extracting the headless archive, lets change our working directory, `cd /opt`.

    Now its time to extract the headless archive, `sudo tar -xzf ~/factorio_headless.tar.gz`. The `-xzf` [flags](https://linux.die.net/man/1/tar) are basically; e`x`tract a g`z`ipped archive `f`ile. This will extract the downloaded archive to your current directory, and should have created a factorio folder. You can check that `/opt/factorio` exists by running `ls` [(?)](http://man7.org/linux/man-pages/man1/ls.1.html), and seeing if the `factorio` directory is listed, as we are working out of `/opt` already. Just for the sake of keeping things tidy, I'd also delete the downloaded archive `rm ~/factorio_headless.tar.gz`, as we are now finished with it.

    If you wish to add any mods or saves, you can do so by first creating the `mods` and `saves` directories within `/opt/factorio`. `sudo mkdir /opt/factorio/saves` and `sudo mkdir /opt/factorio/mods` should achieve this, then you may copy the save & mod archives into the relevant folders.

    ## Step 3 :: Environment
    As you don't want factorio running as root, let's setup a user that it can run under. The user won't need a lot of functionality, as it's only going to be running factorio and won't need to be logged into, so let's provide some flags to create a really basic user:

    `sudo adduser --disabled-login --no-create-home --gecos factorio factorio`

    [The above command](http://www.unix.com/man-page/linux/8/adduser/) will add a user, not setting a password `--disabled-login`, without creating a home directory in `/home` `--no-create-home`, [without asking for user information](https://en.wikipedia.org/wiki/Gecos_field) `--gecos`, create user `factorio` and add them/create the group `factorio`.

    Now that the new user is created, we need to make it the owner of the factorio directory so that it can access and perform operations within it, `sudo chown -R factorio:factorio /opt/factorio`. The `-R` [flag being recursive](https://linux.die.net/man/1/chown).

    ## Step 4 :: Factorio Configuration
    Factorio headless, as of 0.14.12, requires a [JSON formatted config file](https://wiki.factorio.com/Multiplayer#Dedicated.2FHeadless_server). They provide an example one to get you started, in which can be copied and then edited to suit your requirements.

    First, lets change directory `cd /opt/factorio/data` where the `server-settings.example.json` config file is located, it's not necessary, but just the way I do things. Now to make a copy of the config file under its working name `sudo cp server-settings.example.json server-settings.json` and then edit it with a text editor of your choice, I like nano as its easy `sudo nano server-settings.json`.

    The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. [Here is the configuration reference to help you decide what information you'd like to configure](https://wiki.factorio.com/Multiplayer#How_to_List_Your_Server-Hosted_Game_on_the_Matching_Server).

    ## Step 5 :: systemd
    So, we want factorio to run as a service. So lets create a new service for factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do `sudo nano /etc/systemd/system/factorio.service`. The service should contain the following:
    ```
    [Unit]
    Description=Factorio Headless Server
    [Service]
    Type=simple
    User=factorio
    ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/{save_file}.zip --server-settings /opt/factorio/data/server-settings.json
    ```

    Save the file and exit. Time to start the service and see if our setup has worked!

    Firstly, reload the available service daemons `systemctl daemon-reload`, now start the newly created service `systemctl start factorio` and see if it's running `systemctl status factorio.service`. That is the output from the factorio server, any errors or configuration issues will present themselves here if you ever need to debug. If you do make any configuration changes, you'll need to restart the service `sudo systemctl restart factorio.service`.

    That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and play!
    21 changes: 0 additions & 21 deletions guide.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    # [LINUX] Factorio Headless Server Guide
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd`.

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for factorio, default `34197`, forwarded through your router
    - *Optional* - Setup SSH for remote access
    - That's it!

    ## Step 1
    I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from factorio's download site via `wget` onto the server.
    ```
    wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.14.17/headless/linux64
    ```
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require. Easiest way to find out the url is to go to [the factorio server download page (experimental)](https://www.factorio.com/download-headless/experimental) and find the url from the link provided under the version number.

    Also, as they redirect download requests, `wget` will not name the file correctly. The easiest way to rectify it is to manually set the file name using the `-O` flag and manually providing the file name as used in the example above.

    ## Step 2
  27. othyn created this gist Nov 1, 2016.
    21 changes: 21 additions & 0 deletions guide.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # [LINUX] Factorio Headless Server Guide
    So, with credit to [the factorio wiki](https://wiki.factorio.com/Multiplayer#Linux) and [cbednarski's helpful gist](https://gist.github.com/cbednarski/3ada27b2c401cc163dc4), I managed to eventually setup a factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

    The specific distro/version I'm using for this guide being `Ubuntu Server 16.04.1 LTS`. Although, that shouldn't matter, as long as your distro supports `systemd`.

    ## Prerequisites
    - *nix distro, setup and ready to go
    - The UDP port used for factorio, default `34197`, forwarded through your router
    - *Optional* - Setup SSH for remote access
    - That's it!

    ## Step 1
    I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from factorio's download site via `wget` onto the server.
    ```
    wget -O factorio_headless.tar.gz https://www.factorio.com/get-download/0.14.17/headless/linux64
    ```
    Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require. Easiest way to find out the url is to go to [the factorio server download page (experimental)](https://www.factorio.com/download-headless/experimental) and find the url from the link provided under the version number.

    Also, as they redirect download requests, `wget` will not name the file correctly. The easiest way to rectify it is to manually set the file name using the `-O` flag and manually providing the file name as used in the example above.

    ## Step 2