10

I've got a problem during setup of apache. I am using Ubuntu version 18.04. I don't know what made this problem appeared...

I will just list all my commands.

apt-get update
apt-get upgrade

I saw an error after I tried to upgrade:

E: Sub-process /usr/bin/dpkg returned an error code (1) 

To solve it or a solution I used some commands below:

vi usr/sbin/policy-rc.d

contents:

#!bin/sh
exit 101

chmod +x /usr/sbin/policy-rc.d
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

These are from this documentation

apt-get install apache2
apt-get install php
apt-get install libapache2-mod-php
apt-get install php-mbstring
apt-get install php-gd
apt-get install php-curl php-xml
apt-get install mariadb-server
/usr/bin/mysql_secure_installation

use mysql;
update user set plugin='' where User='root';
flush privileges;
exit;
apt-get install php-mysql

adduser

a2ensite

I downloaded phpmyadmin.

After all these commands I wanted to reboot Ubuntu but it didn't work. After the command reboot I saw a message like this:

System has not been booted with systemd as init system (PID 1). Can't 
operate. Failed to talk to init daemon.

and for reboot -f:

Rebooting.
Failed to reboot: Invalid argument

I am complete newbie... I have no idea what I should do

I just reinstalled Ubuntu and I got the same messages mentioned above, though I did nothing but just tried reboot after reinstalling.

5
  • 1
    Did u try sudo shutdown -r now ?
    – Denny John
    Jun 26, 2018 at 11:55
  • 1
    Yes I did It does not work either. I got same message : System has not been booted with systemd as init system (PID 1). Can't operate. Failed to talk to init daemon.
    – user844006
    Jun 26, 2018 at 12:07
  • Are you using WSL? I am not sure whether WSL allows it. (Interestingly I can issue reboot in Babun on my Windows 7 and it does reboot Windows!)
    – Melebius
    Jun 26, 2018 at 12:10
  • If WSL means 'Windows Subsystem for Linux', yes. I am using it...
    – user844006
    Jun 26, 2018 at 12:17
  • I'm getting this error on an Ubuntu box after a LTS release upgrade to 18.04. Any idea?
    – Roy Tinker
    Sep 28, 2018 at 23:29

3 Answers 3

7

I have/had a similar problem when trying to install Docker using Docker's instructions to install on Linux (https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04) or (https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce-1).

The solution is to install Docker using the Windows installation process then linking your Windows Subsystem for Linux to the Windows Docker. As I understand, the reason for the failure is lack of access from the Windows Subsystem to files needed by docker, which are ultimately on Windows. The solution circumvents this. Hope this helps!

https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/

1
  • your comment enlightend me :), and then i carefully read this whole thread, found stackoverflow.com/a/61902994/4582240 this also helped me. I would not have followed that if i was not sure the key issue was the missing 'docker desktop' Sep 6, 2020 at 15:00
3

If you are using Docker, you may try an image that has Ubuntu with System D already active with this command:

docker run -d --name systemd-ubuntu --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro jrei/systemd-ubuntu

Then you just need to run:

docker exec -it systemd-ubuntu /bin/bash

and there you can just install, start and restart any service you need.

1

I had the same problem, accidentally removed the /bin/bash file. After that my server would not boot.

I mounted an old backup and copied the bash file from the mounted drive. Once dismounted, everything was fine except the mounted drive still appeared when I ran df.

I force dismounted the previously mounted back up and got stuck with the same problem.

Try doing the following:

bash --login
exec bash 
bash --login; exit

Here is my source:

https://superuser.com/questions/353723/how-do-i-reload-the-terminal-in-ubuntu

In addition, I also installed aptitude and ran aptitude reinstall bash.

I cannot exactly say what fixed it but the problem is resolved and I can ssh as usual.

You must log in to answer this question.

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