Raspberry Pi+Minibian: Adjusting the Locale and Time Zone
I really have enjoyed playing with the Raspberry Pi, but many of my projects don't require a GUI (for example OpenVPN and web servers). For projects like these, I usually install Minibian which is a great, small version of Raspbian with all the GUI goodness removed. It is a perfect starting point for my headless projects, except that out of the box, it comes setup with locale and timezones configured for Great Britian. This causes some strange characters to come up when typing on the keyboard, and the clock doesn't reflect my local time zone.
Fortunately, these issues are easy to address, and I will show you the steps I take to configure my system for my locale and time zone (us-EN & America/Los_Angeles). Just use your locale and time zone in the steps below to configure your system as desired.
- Install Minibian on your SD card following the provided instructions. Insert the card into your Raspberry Pi, power it up, and log in. (The default username/password is root/raspberry). You may also want to change the name of your system from the default "raspberrypi" by editing the
/etc/hostname
file. - Change the keyboard locale. Run the following command:
dpkg-reconfigure keyboard-configuration
then- Set your "Keyboard model" to "Generic 105-key (Intl) PC".
- Set the "Country of origin for the keyboard" and "Keyboard layout" both to "English (US).
- Next for the "Key to function as AltGr" choose "The default for the keyboard layout".
- For "Compose key" I chose "No compose key".
- Finally, choose "No" for "Use Control+Alt+Backspace to terminate the X server".
- Now change the system local. Run the command
dpkg-reconfigure locales
and de-select "en_GB.UTF-8 UTF-8" and select "en_US.UTF-8 UTF-8", then set the default locale to "en_US.UTF-8" on the next screen. - Edit the
/etc/default/locale
file and change/add the following lines:LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANGUAGE=en_US.UTF-8
then log out and back in again to pick up the new locale. - Finally, run
dpkg-reconfigure tzdata
and select "America", then "Los_Angeles" to set the local time zone for your system. - Now that your system understands you a little better, it's probably a good time to update your system using
apt-get update apt-get upgrade
then reboot your system again.
Optional Tweaks
If you'd like to make your system a little more secure, you can enable sudo and disable the root login with the following steps:
- Install sudo:
apt-get install sudo
- Create your new user. For example, to add the user "bob" run the command
adduser bob
and follow the prompts. - Add your new user to the sudoer's list. Run
visudo
then add the following line (changing the username to the user you just added) after theroot ALL=(ALL:ALL) ALL
line:bob ALL=(ALL:ALL) ALL
- Now disable the root user with the command
passwd -l root
(note that is a lower-case L, not a one) - Now log out of your root session and log in as your new user.
sudo rm /etc/ssh/ssh_host_* sudo dpkg-reconfigure openssh-server
Now you should have a headless Raspberry Pi system that you can use for various server projects that is customized for your locale and timezone! If you have any questions or comments on this procedure, please feel free to leave a comment.
2 comments:
Thanks for the useful hints, lad.
Just started to explore my new minibian install and could make good use of these. Especially the openssh reconfiguration part I would have forgotten for sure.
Cheers,
Nix
Thanks for this article. Even in 2015 these changes still apply.
Post a Comment