Posted on 12-14-2021 07:43 PM
The Mac sometimes cannot connect to a wifi network even though there is no profile showing for that particular network. A search on the web seems to suggest that the following files need to be deleted from /Library/Preferences/SystemConfiguration/:
I just wonder if there could be a script to do this. I tried using a bash script but always has "no such directory" "no permission" etc errors.
Any help would be appreciated.
Solved! Go to Solution.
Posted on 12-17-2021 05:24 AM
Click on the link I posted. It will take you directly to the current release which works very well in all the latest releases including Monterey.
Posted on 12-15-2021 05:53 AM
You have to be careful deleting files pertaining to the network configuration while performing actions that come over the network. I've often found that difficulty connecting to networks (wifi or ethernet) can be caused by too many remembered SSIDs. Take a look at this for one possible avenue. That being said, if you post the script you're trying to use, we can take a look to determine what might be askew.
12-15-2021 01:17 PM - edited 12-15-2021 01:23 PM
Hi AVmcclint
I have this problem on several macs at different times and each time I managed to solve the problem by deleting the files. It just tedious to do it manually. Here is one of the script I tried:
#!/bin/bash
sudo chmod -R 755 /Library/Preferences/SystemConfiguration
cd /Library/Preferences/SystemConfiguration
rm -f 'com.apple.airport.preferences.plist'
rm -f 'com.apple.network.eapolclient.configuration.plist'
rm -f 'com.apple.wifi.message-tracer.plist'
rm -f 'NetworkInterfaces.plist'
rm -f 'preferences.plist'
and here is the error message:
Other things that I've tried:
using the full path in the rm statements
use sudo chown before chmod.
not much success either.
Thanks.
Posted on 12-16-2021 04:45 AM
It does appear that the com.apple.Boot.plist file is probably protected by SIP (I checked on my Macs too). If that's the case, there is nothing you can do to delete SIP protected files other than disable SIP (which is not a good idea). It does look like the other files are free from SIP protection. A better way to do your script would be to skip the chmod and chown altogether. If all you're doing is running the script as sudo with "rm filename" commands in the script, then chmod and chown are irrelevant. If you only focus on deleting the specific files you want to remove, that will avoid the error you're seeing.
Posted on 12-16-2021 12:36 PM
Hi AVmcclint
I've modified the script to
#!/bin/bash
sudo rm -f '/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist'
sudo rm -f '/Library/Preferences/SystemConfiguration/com.apple.network.eapolclient.configuration.plist'
sudo rm -f '/Library/Preferences/SystemConfiguration/com.apple.wifi.message-tracer.plist'
sudo rm -f '/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist'
sudo rm -f '/Library/Preferences/SystemConfiguration/preferences.plist'
Now there is no error message. However, the files are not deleted either.
Thanks.
Posted on 12-16-2021 12:43 PM
You don't need to put them in quotes. If I were to do it, I'd make it like this:
#!/bin/bash
rm -f /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
rm -f /Library/Preferences/SystemConfiguration/com.apple.network.eapolclient.configuration.plist
rm -f /Library/Preferences/SystemConfiguration/com.apple.wifi.message-tracer.plist
rm -f /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
rm -f /Library/Preferences/SystemConfiguration/preferences.plist
and then run the script as a whole with a sudo command:
sudo scriptname.sh
12-16-2021 12:57 PM - edited 12-16-2021 01:06 PM
Hi AVmcclint
Thanks again. When I type at the terminal on the usb drive (ICT02):
sudo rmwifi1.sh
It said: sudo: rmwifi1.sh: command not found
when I type:
sudo ICT02/rmwifi1.sh
It said sudo: ICT02/rmwifi1.sh: command not found
Posted on 12-16-2021 01:33 PM
My apologies. I should have been more clear. You should run:
sudo /path/to/scriptname.sh
The easiest way to do that is to type sudo (and a space) then just drag the script file into the Terminal window so there is no doubt as to what you want to run.
Posted on 12-16-2021 01:48 PM
Hi AVmcclint
when I do as you suggested, now it said:
sudo: unable to execute /Volumes/ICT02/rmwifi1.sh: Operation not permitted
when I ls -lO, it shows:
-rwxrwxtwx@
Posted on 12-17-2021 03:44 AM
Try copying the script to the desktop and running it from there.
Posted on 12-17-2021 04:52 AM
Hi AVmcclint, just another bunch of errors. The last one does not have an error but the files are not deleted either.
Posted on 12-17-2021 04:58 AM
What program did you use to edit the script? Rule of thumb: Never use Apple's TextEdit to work on scripts. Use something like TextMate. I especially like TextMate because when you save scripts, it automatically sets the execute bit.
Posted on 12-17-2021 05:05 AM
Hi AVmcclint
I've looked up TextMate but it said it is not suitable for OSX 10.9 or later. I am using 11.2.3 so no luck. The script was created using TextEdit but I am using the plain text mode, not rich text
Thanks again
Posted on 12-17-2021 05:24 AM
Click on the link I posted. It will take you directly to the current release which works very well in all the latest releases including Monterey.
Posted on 12-17-2021 07:43 PM
Hi AVmcclint
Thank you for all your help. This works.