Read / Write permissions in /opt directory
Solution 1
I changed the owner of the android studio directory from root
to my user
account and it worked. Here is the command, where $USER
will change by itself to your current active user:
sudo chown -R $USER:$USER /opt/android-studio
Solution 2
You can move the directory from /opt
to your home using comand:
sudo cp -r /opt/android-studio ~/
Or to give permissions you have to use chmod
:
sudo chmod +w /opt/android-studio/some-file
to add permissions to all dir recursive:
sudo chmod +w -R /opt/android-studio/some-file
Take a look on my answer https://askubuntu.com/a/638799/150504 that explain a little about chmod and how to use
Solution 3
I did set the group of /opt/android-studio (and /opt/android-sdk) to users and added write permission to the group.
In my case, the group users existed already. But as hint:
sudo addgroup users
I had to add my user to the users group:
sudo adduser $USER users
Then set the group of the directory:
sudo chown -R root:users /opt/android-studio
Because updates need to write files:
sudo chmod -R g+w /opt/android-studio
I used this instructions once, I hope i did not forget something
edit: This way, files shall not be too wide accessible, but still usable by selected users
Solution 4
I had a similar problem with Rubymine.
sudo chown -R $USER:$USER /opt/Rubymine
worked for me too, but it can be dangerous changing permissions in system folders. Probably better just to run the installation once as root to allow updating. eg.
sudo updatedb && sudo locate rubymine.sh
sudo /path/to/rubymine.sh
Related videos on Youtube
wayneeusa
Updated on September 18, 2022Comments
-
wayneeusa almost 2 years
I installed Android Studio in my /opt directory without a hitch and have been using it. Recently, though, Android Studio informed me of an update. It won't perform the update, however, because it says it doesn't have Read / Write permissions in the opt directory where it's installed.
Can anyone recommend the best remedy for this situation? I would prefer not to move my installation to another directory. I also don't know that I want to change permissions on the directory, though I might be tempted to do so for the update, then revert it back.
Error message:
Studio does not have write access to /opt/android-studio. Please run it by a privileged user to update
-
Mark Kirby almost 9 yearsHow are you trying to update ? How did you install ? PPA ? Can you run android studio as root ? ie
sudo /opt/android-studio
and then update ? -
Gayan Weerakutti almost 9 yearsI guess you copied it to the /opt/ directory. I won't recommend keeping it there, so you don't have to bother with the permission issues. It is best to use umake to set up your Android development environment.
-
wayneeusa almost 9 years@markkirby I copied it there and used the installation script studio.sh I would run by sudo, but studio.sh starts the installation again. Surprised that I don't see a file to run to just start the program. Maybe I should gedit the installation script to see where the executable is ..
-
tony gil almost 8 yearsi recommend awarding one of the answers the status of correct answer. otherwise, it may be misleading for users who come by this post in the future - if a correct answer has not been awarded 1 year after, it means that neither answer is correct. When, in fact, both efficiently address the problem at hand. i UPVOTED your question, BTW : )
-
tgm1024--Monica was mistreated over 3 yearsI ran into permission trouble routinely by leaving /opt at default root permissions, and I will not leave everything in my home directory; That has its own pitfalls. There just isn't enough double checking done by install scripts to guide you through potential pitfalls, and
sudo
just will not save the day. For the love of Mike, this is still happening in 2020. I gave up opened up permissions on /opt and called it a day. Does it worry me? You bet. But for a non-server system; notsomuch....
-
-
wayneeusa almost 9 yearsDo I need to specify the specific executable file that will have this permission for the folder? I tried it with the studio.sh, but I don't think that's the actual file that's running when I click the icon to run android studio.
-
Ranjithkumar about 8 yearsreally works for me.. My 10 days search end here
-
Yannick almost 8 yearsThis will work, but are there disadvantages in having all the files and directories in some random subdirectory of /opt owned by a random user? If the installation is in /opt this might mean that it's intended for multiple users, so one might expect other users on the system to be running studio. Might this be a problem somehow?
-
David Foerster almost 8 yearsSetting file permission masks to 777 is almost always bad advice. -1
-
david over 7 yearsdidnt work for me. When creating directory. tried
sudo chmod +w -R /opt/android-sdk-linux
-
david over 7 yearsIts bad advice, but for now it worked so I upvote.
-
Steer360 over 7 yearsused this trick to configure php editor like Geany to xampp installations's /opt/lampp/htdocs directory to write and run in xampp server. hth..
-
Mostafa Ahangarha about 7 years@david 777 means anyone (including anyone through internet) can access, modify and delete the file. "it worked" is not a good excuse to open such a critical vulnerability to your system.
-
mltsy about 7 yearsMe too! But when I try your solution, it asks for license information again, so I'm not sure what to do at that point... put it in again? I don't want to mess up my license terms...
-
dev_ry over 6 yearsFirst we have to run studio.sh from bin directory using sudo then only the write permission is reflected.
-
Tahir Yasin over 6 yearsyou are the man !
-
Bron Davies over 5 yearsgood point @Yannick but who in the world has more than one user on their Ubuntu setup 😂
-
Blood-HaZaRd over 5 years@BronDavies : :) True Story!!
-
Jon Bentley over 5 years@david Smashing your PC to bits, going to the shop and buying a new one, then installing the latest version of Android Studio on it would also "work" but is bad advice and shouldn't be upvoted. The point is there are often multiple ways to "solve" a problem, some of which are the "wrong" way and some are the "right" way. This answer is almost certainly the wrong way.
-
Ajmal V Aliyar about 5 yearsThat is a very simple and effective solution. Good job!
-
tgm1024--Monica was mistreated over 3 yearsI'm not 100% sure I would consider /opt a system folder, despite it's "official" categorization as such. It's not in the same category as /usr, /etc, and the like. Its design is to be a central repository for app installations that are accessible to any user. To this extent, it fails miserably unless (IME) unless /opt is simply opened up to the universe, which I've been forced to do. Very unsafe. But I've basically had it up to ^^^ here with fighting my own system during development and have learned the very hard and expensive way that not doing so yields a miserable waste of my time.
-
tgm1024--Monica was mistreated over 3 yearsUpvoted back up 1. Dangerous? Yes. But so is the crazy expense of chasing down permission problems endlessly with app after app when all I want to do is develop. Would I do this on a server machine? No. Have I learned the hard way to simply open up /opt to the universe? Yep. It solves a very expensive problem: losing my time. The risk is absolutely worth it, and being a purist here is just not helpful. Good grief, I've even run into trouble with Intellij Idea in /opt with their plugins when /opt was at default permissions.