I have Matlab installed under /home/fer/Matlab, with the main exec file being /home/fer/Matlab/R2014b/bin/matlab. There is something weird with it and it only works if I open it with the terminal using sudo. If I run it without sudo it throws a permission error and closes (I guess it's reading somewhere).

Anyway, I was trying to create a .desktop file to be able to open it from the menu, and because it needs to run under sudo, in the exec line I wrote:

Exec=gksudo -u root /home/fer/Matlab/R2014b/bin/matlab

When I click on the shortcut, it asks me for my password, then the Matlab splash appears, then closes, and nothing happens. This looks a lot like a problem with Matlab itself, but am I doing it right with the exec line of the .desktop file? Do I need to add anything else? If a program requires a terminal to run from, is there anyway I can emulate one from the desktop file?

EDIT: As asked in comments: whoami outputs fer and all files and subdirectories in Matlab/R2014b are owned by user fer and group fer. The error is written in a Matlab window, saying tht there is not write permission on /home/fer/.matlab/R2014b/temp0x... I will try to look into that directory.

  • You should not have to start Matlab as root. What error messages are issued when you start it as a normal user and Please post the output of this command in your question: ls -la /home/user/Matlab
    – A.B.
    Apr 19 '15 at 10:50
  • Not directly to your question, but you may omit the-u root argument of gksudo, as it runs the following executable as root by default, if no user is specified.
    – Byte Commander
    Apr 19 '15 at 10:56
  • When you run Matlab in the terminal without sudo, do you get any error messages like "permission denied on /path/to/file"? That would be helpful to see what it wants to access and changing your user account's permissions to be able to access this file or directory.
    – Byte Commander
    Apr 19 '15 at 10:59
  • Please post the output of this command in your question: whoami and groups.
    – A.B.
    Apr 19 '15 at 10:59
  • Can you put the executable in / ? Apr 19 '15 at 12:56

Cut out and reworded from @MyUserIsThis' edits to his question:

Ok, I chowned recursively the whole directory /home/<user>/.matlab so I would have permissions to write on it and it was fixed.

BTW, in case someone else runs into this, the exec line of the desktop file should include the option -desktop for the script to work properly when not called from the terminal:

Exec=/home/<user>/Matlab/R2014b/bin/matlab -desktop
  • @MyUserIsThis Please accept this answer, because AskUbuntu is a Q&A site which implies that if a question is solved, it should have an accepted answer. If you want to add something, feel free to edit it - it's a community wiki which means every user my contribute to it.
    – Byte Commander
    Apr 19 '15 at 14:03

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.