I will leave it as a memo.
I write postgres10 as a prerequisite. Basically, you can do it by changing the path including the version described later. It also assumes that the default user is postgres.
sudo service postgresql stop
sudo su - postgres
/usr/lib/postgresql/10/bin/postgres --single -D /etc/postgresql/10/main/
alter user postgres with superuser; #Ctrl when done+Exit with D.
sudo service postgresql start