I recently downloaded the Buster lite installation package and have the latest updates. I get systemctl not found. The systemd files it uses are present. Apt-get systemctl fails. I need to run commands such as systemctl daemon-restart. I have researched this and found 'get the latest OS' but I have the latest OS. How do I get systemctl ?
-
2Pls add exact command and full error msg to your question – Dirk Oct 25 '20 at 15:57
3 Answers
There are two likely possibilities:
systemctlis gone- your shell cannot find it
To see if systemctl is still there, you can do find / -name systemctl. If it is there, try to execute it with the whole pathname (like /bin/systemctl).
If find does not find it, it is gone. Then you may try to copy /bin/systemctl from an image that has the same version of OS as your Pi, but there is no guarantee tat it will work. That depends on what other files are missing. I would try this only as part of the actions to backup data before re-imaging your system.
To see if systemctl is still there, you can do find / -name systemctl. If it is there, try to execute it with the whole pathname (like /bin/systemctl). If that works, then you must look at your PATH in your shell:
echo $PATH
The output should contain the directory where systemctl is
Example:
$ sudo find / -name systemctl 2> /dev/null
/usr/share/bash-completion/completions/systemctl
/bin/systemctl
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
$
You seen here that /bin/systemctl exists and you see /bin in the PATH. So, on my system, systemctl works.
- 2,491
- 9
- 15
-
There is at least one more possibility: the command was typed wrong. We know nothing and everything is guessing. – Ingo Oct 26 '20 at 12:31
-
1@ingo There may be even more possibilities. That is why I tried to include some basic problem determination in the answer, instead of just saying that the system is corrupt and tell to re-image. – Ljm Dullaart Oct 26 '20 at 13:51
If the error is really this:
pi> systemctl
sh: systemctl: command not found
And the output of echo $PATH includes:
/bin:/sbin:/usr/bin:/usr/sbin
Then something went very wrong, most likely SD card corruption, the usual cause of which is not shutting the Pi down properly before killing the power/pulling the plug.
In any case, there is no point in you trying to repair this. You will have to start again by re-imaging the card. If you did pull the plug arbitrarily, try not to do it again.
- 58,849
- 17
- 112
- 227
Probably the "Buster lite" package does not ship with systemd installed by default. (Perhaps provide a link so we can confirm?)
You can install it just like any other package.
# Make sure package index is up to date
apt-get update
# Install
apt-get install -y systemd
You will probably have to enable some services and reboot before it becomes fully operational. Alternatively, use a less "lite" image if you need the full system, not a stripped-down one.
- 128
- 1
- 8