MacOS – can’t delete unused kext in mojave

deletingkernel-extensionsmacos

I can't delete this High Sierra kext: AirPortAtheros40.kext
I tried in single user mode, or as root. It won't delete!
The kext is not loaded.
This is the output from terminal

Desktop $ sudo rm -rf AirPortAtheros40.kext/
Password:
rm: AirPortAtheros40.kext//Contents/_CodeSignature/CodeResources: Operation not permitted
rm: AirPortAtheros40.kext//Contents/_CodeSignature: Directory not empty
rm: AirPortAtheros40.kext//Contents/MacOS/AirPortAtheros40: Operation not permitted
rm: AirPortAtheros40.kext//Contents/MacOS: Directory not empty
rm: AirPortAtheros40.kext//Contents/Info.plist: Operation not permitted
rm: AirPortAtheros40.kext//Contents/version.plist: Operation not permitted
rm: AirPortAtheros40.kext//Contents: Directory not empty
rm: AirPortAtheros40.kext/: Directory not empty

Best Answer

System kexts are protected by System Integrity Protection (info)

Originally introduced with OS X El Capitan, System Integrity Protection, usually referred to as SIP, is a security feature built into the Mac operating system that’s designed to protect most system locations, system processes, and Kernel extensions from being written to, modified, or replaced.

So you won't be able to remove this kext unless you disable SIP which is not recommended.