When exec*
returns -ENOENT
, either the binary is missing or the interpreter is missing.
Obviously, /bin/ps
exists, otherwise it wouldn't be in hashed in the shell. But the dynamic linker it depends on probably doesn't exist on your system. If GNU binutils installed, you can easily determine if this is the case.
$ readelf -l /bin/ps
…
INTERP 0x0000000000000270 0x0000000000400270 0x0000000000400270
0x000000000000001c 0x000000000000001c R 1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
…
/lib64/ld-linux-x86-64.so.2
exists on my Debian Squeeze/Sid hybrid test machine.
One possibility is that you somehow installed 32-bit packages without the necessary 32-bit libraries. For example, if I try to run a 32-bit binary on a 64-bit-only system,
# on another system for 32-bit development
$ echo 'int main(){}' > 32bit.c
$ cc -m32 -o 32bit 32bit.c
# on a 64-bit system without 32-bit libraries
$ ./32bit
-bash: ./32bit: No such file or directory
$ readelf -l 32bit
…
INTERP 0x000154 0x08048154 0x08048154 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
…
$ ls /lib/ld-linux.so.2
ls: cannot access /lib/ld-linux.so.2: No such file or directory
Another possibility is that you are trying to run LSB binaries on a system without LSB base libraries installed, e.g. a scenario like https://stackoverflow.com/questions/1562071, or trying to use Glibc-based packages on a µClibc-only system, or a multitude of other similar situations.
I do have to ask — how was this system installed? None of this will be true by default, somebody had to go muck with things.
Resolution
Install systemd-sysv
:
apt install systemd-sysv
Explanation
Failed to get D-Bus connection: Unknown error -1
means that systemd is not running.
Here is my LMDE 2 installation, which is a lot like Debian 8:
lmde ~ # systemctl status ssh.service
Failed to get D-Bus connection: Unknown error -1
On your system, /sbin/init
probably isn't a symlink pointing to /lib/systemd/systemd
. Here's what it looks like on LMDE 2:
lmde ~ # file /sbin/init
/sbin/init: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=416c01d5df07b3a795694ff3360339b509daaf86, stripped
Here's what it looks like on Ubuntu 16.04 LTS, which runs systemd by default:
root@node51 [~]# file /sbin/init
/sbin/init: symbolic link to /lib/systemd/systemd
To resolve this, replace the package sysvinit-core
with systemd-sysv
:
lmde ~ # apt install systemd-sysv
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
sysvinit-core
The following NEW packages will be installed:
systemd-sysv
0 upgraded, 1 newly installed, 1 to remove and 533 not upgraded.
Need to get 32.7 kB of archives.
After this operation, 177 kB disk space will be freed.
Do you want to continue? [Y/n] Y
Get:1 http://packages.linuxmint.com/ betsy/upstream systemd-sysv amd64 215+12+betsy [32.7 kB]
Fetched 32.7 kB in 0s (81.1 kB/s)
dpkg: sysvinit-core: dependency problems, but removing anyway as you requested:
init depends on systemd-sysv | sysvinit-core | upstart; however:
Package systemd-sysv is not installed.
Package sysvinit-core is to be removed.
Package upstart is not installed.
(Reading database ... 159705 files and directories currently installed.)
Removing sysvinit-core (2.88dsf-58) ...
Processing triggers for man-db (2.7.0.2-5) ...
Selecting previously unselected package systemd-sysv.
(Reading database ... 159681 files and directories currently installed.)
Preparing to unpack .../systemd-sysv_215+12+betsy_amd64.deb ...
Unpacking systemd-sysv (215+12+betsy) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up systemd-sysv (215+12+betsy) ...
Now reboot with reboot
.
Once the system has rebooted, you'll be running systemd instead of SysV:
lmde ~ # file /sbin/init
/sbin/init: symbolic link to /lib/systemd/systemd
lmde ~ # systemctl status ssh.service
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
Active: active (running) since Wed 2017-02-08 06:58:27 CST; 1min 10s ago
Main PID: 598 (sshd)
CGroup: /system.slice/ssh.service
└─598 /usr/sbin/sshd -D
Feb 08 06:58:27 lmde sshd[598]: Server listening on 0.0.0.0 port 22.
Feb 08 06:58:27 lmde sshd[598]: Server listening on :: port 22.
Feb 08 06:58:29 lmde sshd[598]: Received SIGHUP; restarting.
Feb 08 06:58:29 lmde sshd[598]: Server listening on 0.0.0.0 port 22.
Feb 08 06:58:29 lmde sshd[598]: Server listening on :: port 22.
Feb 08 06:58:44 lmde sshd[1614]: Accepted password for root from 10.0.0.2 port 59703 ssh2
Feb 08 06:58:44 lmde sshd[1614]: pam_unix(sshd:session): session opened for user root by (uid=0)
Possible Cause?
You indicated that systemd on your Debian installation worked in the past. It is possible that a package or its dependencies required SysVinit instead of systemd and erased or disabled systemd.
Be on the lookout for broken dependencies if this is the case.
Additional Resources
Documentation
Description of sysvinit-core
lmde ~ # apt show sysvinit-core
Package: sysvinit-core
State: not installed
Version: 2.88dsf-59
Priority: extra
Section: admin
Maintainer: Debian sysvinit maintainers <pkg-sysvinit-devel@lists.alioth.debian.org>
Architecture: amd64
Uncompressed Size: 199 k
Depends: initscripts (>= 2.88dsf-13.3), sysv-rc | file-rc, sysvinit-utils (>=
2.86.ds1-66), libc6 (>= 2.15), libselinux1 (>= 1.32), libsepol1 (>=
1.14), debconf (>= 0.5) | debconf-2.0, debianutils (>= 4)
Conflicts: systemd-sysv, systemd-sysv, upstart, upstart, sysvinit-core
Replaces: systemd-sysv, systemd-sysv, sysvinit (< 2.88dsf-44~), sysvinit (<
2.88dsf-44~), upstart, upstart
Description: System-V-like init utilities
This package contains programs required for booting a Debian system and doing
basic process management.
The most important program in the package is /sbin/init. It is the first
process started on boot and continues to run as process number 1 until the
system halts. All other processes are descended from it.
Homepage: http://savannah.nongnu.org/projects/sysvinit
Description of systemd-sysv
lmde ~ # apt show systemd-sysv
Package: systemd-sysv
State: installed
Automatically installed: no
Version: 215+12+betsy
Priority: extra
Section: admin
Maintainer: Debian systemd Maintainers <pkg-systemd-maintainers@lists.alioth.debian.org>
Architecture: amd64
Uncompressed Size: 77.8 k
Depends: systemd (= 215+12+betsy)
PreDepends: systemd
Conflicts: sysvinit-core, sysvinit-core, upstart, upstart, systemd-sysv
Replaces: sysvinit (< 2.88dsf-44~), sysvinit (< 2.88dsf-44~), sysvinit-core,
sysvinit-core, upstart, upstart
Description: system and service manager - SysV links
systemd is a replacement for sysvinit. It is dependency-based and able to read
the LSB init script headers in addition to parsing rcN.d links as hints.
It also provides process supervision using cgroups and the ability to not only
depend on other init script being started, but also availability of a given
mount point or dbus service.
This package provides the manual pages and links needed for systemd to replace
sysvinit. Installing systemd-sysv will overwrite /sbin/init with a link to
systemd.
Homepage: http://www.freedesktop.org/wiki/Software/systemd
Best Answer
There must be a
/lib/systemd/systemd --user
process for the user you're running this for. Check with:ps aux | grep systemd
. In my case the process didn't exist because I was trying to setup background services on another account, and that user wasn't logged in (thesystemd --user
process is normally launched at login). The solution was to runsudo loginctl enable-linger $otherUser
, which keeps thesystemd --user
process running at all times.XDG_RUNTIME_DIR
must be set. In my case it wasn't, so my command had to besudo -u $otherUser XDG_RUNTIME_DIR=/run/user/$(id -u $otherUser) systemctl --user
.