First thing I will say: Do not change the ownership of /opt
or /usr
. You will cause masses of problems. For instance, if you change the ownership of /usr
from root, then sudo
will no longer work properly (in fact, it could render the computer unbootable from what I have heard). Indeed, there's very little that's owned by root
by default that I would ever advocate changing the ownership of - once you do something like that recursively it becomes incredibly difficult to undo it.
If you need to create a file within one of them, use sudo
. So, if you had instructions to install a program under /opt
, in a folder called /opt/myprogram
that needed to belong to you, you would perform the following commands; cd /opt
; sudo mkdir myprogram
; sudo chown $USER myprogram
.
But as I say, for the sake of your system's stability, ONLY change the ownership on files or folders you yourself have created. If you need to edit something owned by root
, use sudo
ahead of the command rather than taking ownership.