Why there is no nsenter in util-linux?
I frequently using nsenter
command for my purposes in my main system under Arch Linux. Now I have to work on Ubuntu to test my apps on it, but there isn't nsenter
in util-linux. Maybe it's a separate package?
UPD. Ok, I checked that version of util-linux
in Ubuntu is still much older than 2.23. How can I install new version of package without any after problems on Ubuntu?
Solution 1:
Update:
As of 14.10, the util-linux
provides the nsenter
command. The solution below has been tested with 14.04.
The Debian/Ubuntu version is as you said quite old now, even in Trusty.
There's an opened bug and so far no progress unfortunately.
You could try to build it from source:
wget https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.1.tar.gz -qO - | tar -xz -C ~/Downloads
Make sure to install the following build dependencies:
sudo apt-get install libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool
And just run in the source directory (~/Downloads/util-linux-2.24.1
):
./autogen.sh
./configure && make
IMPORTANT
Do NOT sudo make install
this package on Ubuntu 14.04 LTS until it is officially ready for use, as it definitely demands an unavailable version of libmount
, breaking your boot. (If you do this, reinstall the mount
package before rebooting your machine, if you can.)
Credits: Trevor Alexander for his comment.
Finally you'll get:
sylvain@sylvain-ThinkPad-T430s:~/Downloads/util-linux-2.24.1$ ./nsenter -V
nsenter from util-linux 2.24.1
Note: as nsenter is not available in the ubuntu util-linux version, you can install just this file in /usr/bin (or sbin):
sudo cp ./nsenter /usr/bin
Solution 2:
If you use docker you can install nsenter in a container and then copy the nsenter command to the host.
From my gist: https://gist.github.com/mbn18/0d6ff5cb217c36419661
# Ubuntu 14.04 don't have nsenter - the straight forward way required me to install build tools and etc.
# I preferred to keep the system clean and install nsenter in a container and then copy the command to the host
# Note - its also possible to run nsenter from a container (didn't tried) https://github.com/jpetazzo/nsenter
# start a container
docker run --name nsenter -it ubuntu:14.04 bash
## in the docker
apt-get update
apt-get install git build-essential libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool
git clone git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git util-linux
cd util-linux/
./autogen.sh
./configure --without-python --disable-all-programs --enable-nsenter
make
## from different shell - on the host
docker cp nsenter:/util-linux/nsenter /usr/local/bin/
docker cp nsenter:/util-linux/bash-completion/nsenter /etc/bash_completion.d/nsenter