bind command in Linux is basically a builtin Bash shell command used for setting Readline key bindings and variables. In simple words, we use this command to set keybindings (keyboard actions) to a certain function. Doing this can also change how the bash will react to keys or key combinations while pressed on keyboard.
Syntax of using bind command in Linux
bind [-m keymap] [-lpsvPSV] bind [-m keymap] [-q function] [-u function] [-r keyseq] bind [-m keymap] -f filename bind [-m keymap] -x keyseq:shell-command bind [-m keymap] keyseq:function-name
Options for bind command and its description
- -m keymap: Using this option, KEYMAP scheme is used for the duration of current command sequence. There’s various keymap names available that includes emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-command and vi-insert.
- -L: Used for displaying names of functions.
- -P: Used for displaying function names and bindings.
- -p: Used for displaying functions and bindings in a form which can be reused as input.
- -S: Used for displaying key sequences that invoke macros and their values.
- -s: Used for displaying key sequences which invoke macros and their values in a reusable input form.
- -V: Used for displaying variable names and values.
- -v: Used for displaying readline variable names and values that can be re-read.
- -f filename: Reads keybindings from a specified filename.
- -q function : Used for querying about which keys invoke the named function.
- -u function: Unbinds keybindings to a named function.
- -r keyseq: Removes current keybindings for keyseq.
- -x keyseq:shell-command: It causes the shell-command to be executed whenever the keyseq is entered.
- -X: Displays key sequences bound with -x and associated commands in a reusable input form.
Examples of bind commands
bind -l
The above command will display all readline function names. By default, around 150 functions are available.
bind -p
This will display the keybindings and associated function names.
bind -f servonode
It will read key bindings from a specified FILENAME servonode.

Nishant Verma is a senior web developer who love to share his knowledge about Linux, SysAdmin, and more other web handlers. Currently, he loves to write as content contributor for ServoNode.