I would like to inspect / change / remap the keybindings in my Ubuntu server terminal. (I'm not using any GUI. I'm referring the bare-bones terminal, TTY1).

My core question is this:

  • Where is the configuration file for terminal keybindings?

Context: (I'm writing this context to help readers understand where I'm coming from.)

  • I would like to understand my "low level" terminal keybindings so that I can better configure and use Byobu.

  • I would also appreciate if an answer could:

    • explain the process order / stack of how the terminal gets started (because this will help me understand which processes are 'stealing' keybindings)

    • clarify if I'm using any terminology incorrectly

  • Your interactive shell probably uses the readline library, whose default key bindings are configured in /etc/inputrc (overridable by a personal ~/.inputrc). Below that, there's terminfo - but that's uncharted waters for me, I'm afraid. Not sure if that's what you're looking for? – steeldriver Sep 21 '16 at 19:24
  • @steeldriver Yes, an answer along these lines would help, especially if you add some links for further reference. – David J. Sep 21 '16 at 21:16
  • You're asking first about TTY, but then go on asking about Byobu, then you ask about the process of terminal startup/logon. This is far too broad and all-over the place. I strongly suggest you clarify your question and narrow it down to a single, clear question. AskUbuntu isn't a forum, we deal with specific, clear-cut questions – Sergiy Kolodyazhnyy Sep 21 '16 at 21:19
  • @Serg: I'm a long-time user on Stack Overflow, so I can appreciate your meta-commentary. However, I wonder if perhaps you are misunderstanding what I wrote for some reason. To answer your points: Paragraph 1 of my post is about what I'm trying to do. Paragraph 2 is my core question: "Where is the configuration file for terminal keybindings?". The rest is about context. So, this question does have one clear question. The other parts are about giving context so that an answer can be maximally useful for me. – David J. Sep 21 '16 at 21:23

Short Answer

To answer the question directly:

Where is the configuration file for terminal keybindings?

In my case (Ubuntu 16.04 with bash), Serge's answer is useful. (Though I'm not quite sure that it is complete in covering all key bindings that might conflict, which is why I'm writing this longer answer.) Bash configures keybindings in these files:

  • default key-bindings: /etc/inputrc
  • custom key-bindings: ~/.inputrc

Long Answer

In this section, I would like to be a bit more comprehensive. While bash and readline affect key bindings, they are other processes involved. For example, how does ALT-2 get bound to TTY #2?


As an overview, here are the pieces involved on my Ubuntu Server 16.04 machine. I start with systemd, Ubuntu's current init system.

  • systemd starts systemd_logind.
  • systemd_logind starts TTY1 with login.
  • login starts bash.
  • bash uses the readline library.
  • bash runs ~/.bashrc which ultimately starts byobu
  • byobu, on my system, uses tmux as a back-end

(Note: systemd is used in Ubuntu 15.04 and 16.04. Upstart was the init system for Ubuntu 6.10 to 15.10, according to https://en.wikipedia.org/wiki/Ubuntu_version_history.)

Practically speaking, the following components trap some keypresses:

  • systemd-logind (traps ALT-1, ALT-2 etc).
  • login
  • bash using the readline library
  • tmux
  • byobu
  • the TTY (TODO: I don't know if this is a part of systemd or login?)


For Ubuntu 16.04, systemd-logind is where user logins start. According to the Ubuntu man page for systemd-logind .

systemd-logind is a system service that manages user logins. It is responsible for:

  • Keeping track of users and sessions, their processes and their idle state
  • Providing PolicyKit-based access for users to operations such as system shutdown or sleep
  • Implementing a shutdown/sleep inhibition logic for applications
  • Handling of power/sleep hardware keys
  • Multi-seat management
  • Session switch management
  • Device access management for users
  • Automatic spawning of text logins (gettys) on virtual console activation and user runtime directory management

See also the man page for logind.conf. I didn't see any mention there of terminal keybindings.

TTY / keyboard configuration

Related links about TTY / keyboard configuration:

Tools for TTY / keyboard layouts:

bash (with the readline library)

The gnu.org bash reference has nice documentation about bash and readline functions.

These configuration files affect key bindings:

  • default key-bindings: /etc/inputrc
  • custom key-bindings: ~/.inputrc


tmux key bindings are described here: https://wiki.archlinux.org/index.php/Tmux#Key_bindings

A user-specific configuration file should be located at ~/.tmux.conf, while a global configuration file should be located at /etc/tmux.conf.


Byobu has default key bindings which can be user defined in /usr/share/byobu/keybindings/.

Work In Progress

Note: this answer is a work-in-progress. There may be mistakes. (I find it easier to state what seems to be true based on my reading and reasoning, and correct it if it is wrong.) I will update this and remove this notice when it is closer to completion.


As per bash manual ( accessible via command line man bash ) , the custom keybindings can be configured via ~/.inputrc file. Custom keybindings are said to be set like this:

  When using the form keyname:function-name or macro, keyname is the name
   of a key spelled out in English.  For example:

          Control-u: universal-argument
          Meta-Rubout: backward-kill-word
          Control-o: "> output"

When the terminal starts and passes control to your shell(which is bash typically ), it reads the config files, including ~/.inputrc. The readline library is what in fact enables this behavior, and it also allows using vi or emacs editing mode. Other shells may not have support for readline, for example ksh, so you would really need to use vi/emacs editing more In this case, the shortcuts are the same as for vi and emacs text editors.

The byobu is not really related to ~/.inputrc and bash's readline: uses plenty of it's own custom keybindings and settings, which mostly come from the backend that it's using - screen or tmux. I suggest you read man pages and tutorials to get understanding of how these work.


Not the answer you're looking for? Browse other questions tagged or ask your own question.