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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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