FreeBSD: Customize Home, Del, Insert keys for BASH shell

By default when you use FreeBSD’s BASH shell and if you hit Home, Del, Insert keys all of them just prints ~ (some garbage is printed ). To get rid of this problem, edit /etc/profile file and define key binding.

1) Open your bash global profile file:
# vi /etc/profile

2) Add following line to it:
export INPUTRC=/usr/local/etc/inputrc

3) Close and save the file

4) Open the file /usr/local/etc/inputrc and define / modify key binding:
# vi /usr/local/etc/inputrc

5) Append following config data:

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word

6) Close and save the file

7) Now logout and login back again to test your new key settings.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 14 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
14 comments… add one
  • BOK Jul 20, 2005 @ 17:15

    And another one:
    “x7F”: backward-delete-char

    PS Nice hints ‘n tips on your site!

  • PotatoSalad Jul 17, 2006 @ 19:42

    You can just copy /usr/compat/linux/etc/inputrc to /etc/inputrc and add “export INPUTRC=/etc/inputrc” to /etc/profile. Not sure if everyone has the /usr/compat/linux/etc/inputrc file, though. I’m on FreeBSD 6.1

  • 🐧 nixcraft Jul 18, 2006 @ 19:05


    I am also not sure about freebsd 4.x. If you have the file just copy and use it 🙂

  • Dan Dascalescu Nov 29, 2006 @ 1:24

    BTW, it’s
    “x7F”: backward-delete-char

    Forget the backslash like BOK and your keyboard will be crippled off the ‘x’ key

  • kace Sep 20, 2007 @ 20:31

    Don’t forget the ‘ctl-v’ trick though. (I mentioned it here.) I’ve found some of those codes are different on different keyboards/machines!

  • Steve Kamerman Sep 26, 2007 @ 17:38

    WOW! Thanks – I just switched two dedicated servers from Fedora Core 4 to FreeBSD 6.1 and this was driving me crazy!!!

    Here’s some more handy things to put in your /etc/profile

    alias pico="nano -w"
    alias slocate="locate"
    alias cd..="cd .."
    export EDITOR=/usr/local/bin/nano
    export INPUTRC=/etc/inputrc

  • Dagur Mar 5, 2008 @ 13:44

    It’s also worth noting that if you don’t have permission to edit /etc/inputrc you can at least create a .inputrc file in your home directory

  • BK May 4, 2008 @ 10:18


  • Robvdl May 25, 2008 @ 2:25

    Thanks a lot, that fixed the keys in bash, but there’s one more: the END key in the nano editor doesn’t work.

    How would I get that going?

  • uhoo Nov 16, 2009 @ 16:40

    Thanks, but…
    How to do this in (T)cshell ? I’ve no the program ‘export’.
    I’m freebsd 7.1.

    • Lucas Saliés Brum Nov 2, 2012 @ 22:31


  • Giofe Dec 21, 2010 @ 1:47

    it works very well on bash – Solaris 10.

  • diegomichel Jan 25, 2011 @ 9:35

    Thanks alot, i got a vps with freebsd and have been hard just because this issue, now even the paste and copy from mouse works perfectly.

  • LeLutin Mar 27, 2017 @ 0:45

    Hey there,

    This post is kindof old but still relevant.

    In freebsd 9.x I’ve had to add the following to the inputrc file to really make ctrl-arrow work:

    "e[1;5C": forward-word
    "e[1;5D": backward-word
    "ee[C": forward-word
    "ee[D": backward-word

    hope that can be useful for ppl stumbling here.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum