Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Files under /usr/bin not able to delete

It seems files present under /usr/bin is not easy to delete even when I get sudo privileges.


----

sudo rm /usr/bin/javac 

override rwxr-xr-x root/wheel restricted,compressed for /usr/bin/javac? yes

rm: /usr/bin/javac: Operation not permitted

-----


Can somebody suggest any solution? I am a software developer and keep updating my machine with new and old versions of development tools.




MacBook Air, macOS 12.6

Posted on Sep 30, 2022 12:54 PM

Reply

Similar questions

11 replies

Sep 30, 2022 3:13 PM in response to veekeay

As a Java developer. you should be familiar with the hoops for running multiple versions of Java on your system. The way to do this has been well known for year (and it applies to all OSes, not just MacOS).


The short version is that you need to install other Java versions in parallel (e.g. in /usr/local/bin, or anywhere else you prefer), then either invoke the specific version of Java you want at run time (by providing the full path of the javac binary you want to use), or set your $JAVA_HOME environment variable to provide a hint.


Repeatedly removing and reinstalling Java versions on a regular basis is not something that most people are prepared to do.

Sep 30, 2022 3:30 PM in response to veekeay

> Please suggest way to delete the file and I don't like apple controlling my Mac book so tightly


Short version: wipe your drive and install some other OS.


Apple have long marched down a part of locking down parts of the OS to prevent unauthorized change to parts of the file system.

In 99% of cases nobody notices

In 0.99% of the rest of the cases those changes prevent malware or malicious activity directed towards the system - at least to the point where it acts as a barrier to malware and users have to go out of their way (at least to authenticate and acknowledge the change) before changes can be made. That's helped maintain the perception of MacOS being a more secure OS than others.

The remaining 0.001% of cases are users like yourself who demand absolute control over their filesystem, no matter what the advantages or disadvantages may be. At the end of the day, Apple are not catering to the 0.001%, so if that's a hill you're prepared to die on, you'll need to find another platform to do it on.


Yes, you can do it - you can disable all the OS protections, file system security and whatnot, and install whatever binary you want in the place of /usr/bin/javac, but it will slow you down every time you need to switch Java versions - most people would follow the standard model of installing multiple Java versions that have existed for years and get on with the job of coding.

Oct 1, 2022 11:44 AM in response to veekeay

The problem you want to solve is not clear to me. If you do not want Java on your Mac then uninstall it according to its instructions: https://www.java.com/en/download/help/mac_uninstall_java.html


As it states, "Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS."


Then, if you need Java or the JDK install the version you want: https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html

Oct 1, 2022 7:30 PM in response to veekeay

Here is the gist of things here


a) With Catalina OS apple divided the disk volumes into at least two parts

i) Data

ii) System Volume


b) With concert of firmlinks the data stored in "Data" is a link is created read only on the System Volume. For e.g. /usr/ which is in data volume - RW is actually mounted read only on the system volume. This ensures any corruption on the seen /usr/ is not possible


c) Apple also introduce a service called csrutil, which when enabled ensures the r only mount is protected by throwing the error - operation not permitted


d) This csrutil service can be disabled by going into recovery disk process though the disable of the service does not ensure W access to the volume


e) Firm links is a new concept and are not visible to the users using ls -l calls. Thus on first glance it is not easy to understand as how to make change to the volume, for e.g. in above case where I could not delete javac.

Files under /usr/bin not able to delete

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.