How do you set a locale non-interactively on Debian/Ubuntu?

view full story

http://serverfault.com – Usually, I run aptitude -y install locales then dpkg-reconfigure locales to set up locale. Now I want to put it into a shell script, how can I reliably do the following, automatically / non-interactively? Choose en_US.UTF-8 and set it as system default Disable all other locales (Optional) Verify if /etc/default/locale contains one-and-only entry of LANG=en_US.UTF-8 as expected (HowTos)