MacOS – Equivalent of Linux “service” command on Mac OS to stop a running process/service

command linemacosterminal

I want to stop a running driver on Mac OS then overwrite it with another version then restart. The files are overwritten to the same location.

When I overwrite and reboot the new driver starts as expected, but I would like to be able to do this without the reboot. When I use "ps -9" to kill the processes they start up again. Is there a command similar to Linux "service" to control such processes?

Best Answer

Just need some clarification on your question. How do you know this is a driver?

Process control is typically achieved with some variation of the launchctl command:

https://support.apple.com/en-hk/guide/terminal/script-management-with-launchd-apdc6c1077b-5d5d-4d35-9c19-60f2397b2369/mac

The above link is pretty good at detailing the service list. Let me know if that helps.

Driver control is a bit different. The driver equivalent on macOS is a kernel extension (kext). Are you able to try the following?

# get root access
sudo bash -
# Attempt to unload kext
kextload | grep -i DRIVER_NAME

*if found*
kextunload DRIVER_NAME

This should unload the driver. You can then force replace it in /System/Library/Extensions or whatever directory it resides in. Then do the following:

# fix permissions
sudo chmod -R 755 /path/to/name.kext
sudo chown -R root:wheel /path/to/name.kext

# Attempt to load driver
kextload -v DRIVER_NAME

Some more information would be key, but this is the general procedure I would follow.

PROCEED AT YOUR OWN RISK!!