How to install Postgres on Ubuntu 18 (via WSL)

After installing postgres on Ubuntu 18 (via WSL) using official documentation, I run into multiple issues. This article might help someone who also wants to install postgres on WSL (same problems might be happening on native Ubuntu version). First follow instructions in official documentation, then follow steps below.

Change ownership of place where you'll be saving logs to postgres user:

sudo chown postgres /var/log/postgresql

Next create symlinks for postgres configuration, not sure why this is not happening by default, perhaps you should setup your own configs, but in my case I just wanted to get it running because I was just following an online course:

sudo ln -s /etc/postgresql/10/main/postgresql.conf /var/lib/postgresql/10/main/postgresql.conf
sudo ln -s /etc/postgresql/10/main/conf.d /var/lib/postgresql/10/main/conf.d

Finally start server as postgres user:

sudo -u postgres /usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/10/main -l /var/log/postgresql/logfile start

After that, in order to start working with Postgres from command line I used following command:

sudo -u postgres psql postgres

Good luck :)