This is actually poor advice. The right way on Ubuntu is to use the packages provided by PostgreSQL Development Group (https://wiki.postgresql.org/wiki/Apt), and in that setup you use pg_createcluster instead of initdb.
The snippet in the original article was so hacky because it fixed an existing cluster instead of destroying it and creating a new one in UTF-8.