I'm trying to set up a chroot environment with only bash in it. This is what I have so far:

[root@free]# tree .
├── bin -> usr/bin/
├── dev
├── etc
│   ├── bash.bash_logout
│   ├── bash.bashrc
│   ├── inputrc
│   └── profile
├── lib -> usr/lib/
├── lib64 -> usr/lib64/
├── proc
├── sys
└── usr
    ├── bin
    │   └── bash
    ├── lib
    │   ├── libc.so
    │   ├── libc.so.6
    │   ├── libdl.so
    │   ├── libdl.so.2
    │   ├── libncursesw.so.6
    │   ├── libreadline.so
    │   ├── libreadline.so.7
    │   ├── libreadline.so.7.0
    │   ├── libtinfo.so
    │   └── libtinfo.so.6
    └── lib64
        └── ld-linux-x86-64.so.2

11 directories, 16 files

ldd lists the following for bash:

[root@free]# ldd /bin/bash
    linux-vdso.so.1 (0x00007ffd388a3000)
    libreadline.so.7 => /usr/lib/libreadline.so.7 (0x00007fa6e0baa000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fa6e09a6000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007fa6e05ea000)
    libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007fa6e037d000)
    /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fa6e10d8000)

Entering the chroot environment already works (I have no name! is fine since i have not jet copied the passwd file):

[root@free jail]# chroot .
[I have no name!@jail]#

The problem is that if I type in p e backspace w d the line will look like:

[I have no name!@jail]#pe wd

executing it with enter will execute pwd and print


also the arrow keys (left and right) acting weird like printing multiple characters but not moving the cursor p d left w leads to pdwd . This does not happen in bash outside of the chroot.

How can I fix this?

Did I forget to copy a library or something? Is it a libreadline problem (I already copied etc/inputrc)? Or could it be a libncursesw problem?

2 Answers 2


I took a look at a script to generate minimal chroots and noticed that you're missing the /usr/share/terminfo/ directory, which is used by libcurses and deals with terminal command sequences. In addition to some other files that will likely be necessary (/etc/resolv.conf, etc.), that's what I'd look at trying.


Reading /etc/terminfo/README, as seen on http://web.archive.org/web/20120621035133/http://www.ibb.net/~anne/keyboard/keyboard.html, helped me finding out where terminfo was located:

cat /etc/terminfo/README

This directory is for system-local terminfo descriptions. By default, ncurses will search ${HOME}/.terminfo first, then /etc/terminfo (this directory), then /lib/terminfo, and last not least /usr/share/terminfo.

As /usr/share/terminfo/ was empty (but a common answer on many websites), on a recent distro it seems that /lib/terminfo/ is the good location.

So copy to your chrooted directory the directory which is not empty, be it:

  • /etc/terminfo/
  • /lib/terminfo/
  • /usr/share/terminfo/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .