Is there anyway to permanently set some kind of rule to launch Android Studio as sudo, each and every time it is launched? I have been trying but I have not been able to set a "flag" to force it to launch under Sudo.

Any help is greatly appreciated! Thank You!

EDIT: I got it working. Both the answers worked, and I ran both of them to make sure I was not making any kind of mistake! Thank you!

  • You could try setting up the app short to point to a launcher script that actually uses the sudo command. – code_dredd Oct 18 '16 at 13:58
  • @ray i did try launching from terminal but it just pops up the installation dialogue. I will try your method, but I have very little knowledge on making launcher scripts. Would you have some kind of examples I could refer to? – premiumdrinkingrainwater Oct 18 '16 at 14:02
  • Why do you want to run it as root? – You'reAGitForNotUsingGit Oct 18 '16 at 14:10
  • i have to update it and there is a popup saying I can't update it unless it is in root. I followed the default installation guide and I installed it in /usr/locale – premiumdrinkingrainwater Oct 18 '16 at 14:12
  • 1
    You shouldn't need to run all the time as root to upgrade – user595510 Oct 18 '16 at 14:14

While I wouldn't recommend running the IDE as the root user, you could create (or modify) the .desktop file for the app and create a custom launcher script that uses sudo.

For example, I have $HOME/.local/share/applications/jetbrains-studio.desktop with the following content:

[Desktop Entry]
Name=Android Studio
Exec="/home/ray/.android-studio/bin/studio.sh" %f
Comment=Develop with pleasure!

You can modify the Exec line so that it points to a script of your own making, say, Exec="/home/<yourname>/.studio-launcher.bash"

This script could do something like this:


sudo /home/ray/.android-studio/bin/studio.sh %f

With the .desktop file under the directory mentioned above, you should also get the app to show up in the launcher, as shown in the example below, which is of my laptop using gnome-shell.

Android Studio App Launcher

This is a better long-term solution because:

  1. It's a one-time setup;
  2. You don't need to run terminal commands every time (e.g. alias);
  3. You don't need to launch it from the terminal every time (e.g. running the astudio command);
  4. You don't need to modify code in $HOME/.bashrc, etc.
  • much simpler to do it my way – user595510 Oct 18 '16 at 14:13
  • thank you so much! I will try it and update it here! Thank you for the detailed answer! – premiumdrinkingrainwater Oct 18 '16 at 14:14
  • @MarkYisri Only in the short-term. Mine is a more long-term solution that doesn't require opening the terminal every single time, which the OP does not appear to want to do. – code_dredd Oct 18 '16 at 14:15
  • thank you for the answer, but I cannot find the .home file for my studio. Do I have to create one or is there a specific location I have overlooked? If I do have to make one, can you tell me how to make one? – premiumdrinkingrainwater Oct 18 '16 at 14:37
  • You said you installed AS under /usr/locale/, so the actual executable of Android Studio should be there somewhere. In my case, I chose to install it under a new directory called .android-studio within my home directory (i.e. /home/ray/.android-studio). You can use the GUI to create the directory, noting that file/dir names that begin with a . are meant to be "hidden", so you'll need to set your file manager (e.g. Nautilus) to show hidden files. Let me know if you still have questions. – code_dredd Oct 18 '16 at 14:41

Use the alias command.

alias astudio=`sudo <ANDROID_STUDIO_EXECUTABLE>`
  • this seems simple enough. Do I make a script of some sort? Sorry for the dumb questions. – premiumdrinkingrainwater Oct 18 '16 at 14:15
  • @guywiththeredflare If used "as is", you'll need to 1) use the terminal to launch AS every time, and 2) and run the full alias command shown every time prior to launching AS (commands last only for a particular terminal session), or 3) edit your $HOME/.bashrc file to include the alias command as shown and then always do step 1 anyway. My solution is a one-time only thing, which I think is better long-term. – code_dredd Oct 18 '16 at 14:18
  • @guywiththeredflare you can just add it to the end of your .bashrc file – user595510 Oct 19 '16 at 10:49
  • 1
    this works for me alias astudio='sudo /opt/android-studio/bin/studio.sh' – Idham Choudry Aug 14 '18 at 9:30

You can do it simply and totally from GUI:

  • to create a root owned shell file to launch it as root from GUI do: sudo mousepad create a .sh file, from instance save it in /home/YOUR_USER/studio.sh
  • put in it this command: gksudo android-studio (if you don't have gksudo install package gksu to get it)
  • from terminal change file permissions to execute it: sudo chmod 775 /home/YOUR_USER/studio.sh
  • edit the menu entry to add the entry: settings -> menu edit (can change from your ubuntu version) add an entry for the shell script: /home/YOUR_USER/studio.sh, you could use the original android studio icon for it

now you can launch the studio from the menu providing the superuser password

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.