How can I change the keyboard layout in the TTY aka text mode reached through the combinations Ctrl+Alt+F1 through F6 permanently?
I tried sudo echo 'KEYMAP=de' > /etc/conf.d/keymap
and echo 'KEYMAP=de' > /etc/vconsole.conf
without success.
Your idea is correct, just the required command is off. sudo echo > whatever
only executes echo
with elevated privileges, the redirect is applied by the shell and so is not elevated. To write with sudo privileges, a common idiom is to pipe to tee
and elevate that with sudo
, so your command would become:
echo 'KEYMAP=de' | sudo tee /etc/vconsole.conf
An alternative would be to edit the file with your editor of choice launched with sudo
.
If you only want to append to a file, you may use tee -a
, or to modify a files contents use some other utility such as sed:
sudo sed -i 's/\(KEYMAP\).*/\1=dvorak-de/' /etc/vconsole.conf
echo 'KEYMAP=de' | sudo tee /etc/vconsole.conf
does the job, provided you don't make any typos. You may confirm with
cat /etc/vconsole.conf
echo 'KEYMAP=de' > /etc/vconsole.conf
.