Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service command isn't working #18

Open
Sirred01 opened this issue Jun 26, 2023 · 1 comment
Open

service command isn't working #18

Sirred01 opened this issue Jun 26, 2023 · 1 comment

Comments

@Sirred01
Copy link

I freshly installed Arch WSL from microsoft store. After registering and setting proxy when I tried to run this command while being root "service ssh enable" it gives the following output "bash: service: command not found". I guess the system is using SysVinit as its init system, but still service command don't work.

@lubuoren
Copy link

lubuoren commented Aug 14, 2023

it uses systemd.If you want to uses systemctl ,you should install daemonize form AUR,
add

SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')

if [ -z "$SYSTEMD_PID" ]; then
   sudo /usr/bin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
   SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')
fi

if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then
    exec sudo /usr/bin/nsenter -t $SYSTEMD_PID -a su - $LOGNAME
fi

to /etc/profile
add

%sudo ALL=(ALL) NOPASSWD: /usr/sbin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
%sudo ALL=(ALL) NOPASSWD: /usr/bin/nsenter -t [0-9]* -a su - [a-zA-Z0-9]*

to /etc/sudoers
and run

sudo -s
source /etc/profile

to apply them.
Then you can use systemctl
@Sirred01

vineelsai26 added a commit that referenced this issue Mar 2, 2024
…ownload-artifact-4

github-actions: bump actions/download-artifact from 3 to 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants