permanently adding specific variable to the PATH variable

Asked by bhaskar on 2011-09-04

I am using Ubuntu 11.04 Natty Narwal and recently i tried to install MATLAB 2010a and the result is that i am unable open the installed matlab.
And i found that if i add /usr/local/matlab2010a/bin/ to the existing PATH variable then my shell is recognising the matlab as a shell command and executing the matlab. And after immediate closing of Terminal my added path variable is missing from the original PATH variable.
The procedure i followed for adding matlab path variable is shown below:
export PATH

PATH variable before adding matlab: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PATH variable after adding matlab: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/matlab2010a/bin/

Now one more problem is that i am unable to add matlab under desktop shortcut because i don't want to run matlab from terminal every time.

My system architecture details from command uname -a are shown below:
Linux bhaskar-Inspiron-1525 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011 i686 i686 i386 GNU/Linux

Question information

English Edit question
Ubuntu bash Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
mycae (mycae) said : #1

there are two ways to do this.

PATH=$PATH:/new/path matlab

would work.

Also, modifying your .bash_profile to add

export $PATH

and then in gnome-terminal, ensure you check the box that says "login shell" in the preferences menu (edit->profile preferences->edit->title and command->run command as login shell)

Also, you may want to (for future reference only), be aware of the scilab package. As this is free software it is maintained to work out-of-the-box.

bhaskar (hinduvsp) said : #2

Sorry mycae, the process mentioned above is not holding my new PATH variable and i am requesting some more solution.

if you add it in ~/.bashrc it will apply it. You can add:

export PATH=$PATH:/usr/local/matlab2010a/bin/

Should be ok

bhaskar (hinduvsp) said : #4

Thanks actionparsnip, now the shell holding my matlab PATH variable into the existing PATH variable.Can you help me to create a desktop shortcut for this matlab application in order access matlab from desktop.

Right click desktop and click to make a new launcher. Then navigate to the binary you want to run.

bhaskar (hinduvsp) said : #6

When i try the procedure you mentioned and i am getting the following error from the desktop shortcut:

There was an error launching the application.
Details: Failed to execute child process "matlab" (No such file or directory)

Can you give the output of:

ls -la /usr/local/matlab2010a/bin/


bhaskar (hinduvsp) said : #8

bhaskar@bhaskar-Inspiron-1525:~$ ls -la /usr/local/matlab2010a/bin/
total 608
drwxr-xr-x 7 root root 4096 2011-08-20 02:38 .
drwxr-xr-x 16 root root 4096 2011-08-20 02:38 ..
-r-xr-xr-x 1 root root 21615 2010-01-04 18:11
-r-xr-xr-x 1 root root 20450 2010-01-04 18:11
-r-xr-xr-x 1 root root 18652 2009-12-11 15:23 deploytool
-r-xr-xr-x 1 root root 10418 2010-01-04 18:09
-r-xr-xr-x 1 root root 12101 2010-01-04 18:09
drwxr-xr-x 7 root root 36864 2011-08-20 02:37 glnx86
-r--r--r-- 1 root root 19 2009-05-15 16:32 insttype.ini
-r--r--r-- 1 root root 109093 2009-05-15 16:32 lcdata.xml
-r-xr-xr-x 1 root root 1541 2009-05-15 16:32 lcdata.xsd
-r-xr-xr-x 1 root root 12651 2010-01-04 18:09 ldd
-r--r--r-- 1 root root 1640 2009-11-13 03:35 license.txt
drwxr-xr-x 2 root root 4096 2011-08-20 02:35 m3iregistry
-r-xr-xr-x 1 root root 54915 2010-01-04 18:09 matlab
-rwxr-xr-x 1 root root 12869 2011-08-20 02:38
-r-xr-xr-x 1 root root 10417 2010-01-04 18:09
-r-xr-xr-x 1 root root 81107 2010-01-04 18:09 mbuild
-r-xr-xr-x 1 root root 10829 2010-01-04 18:09
-r-xr-xr-x 1 root root 43736 2010-01-04 18:09 mcc
-r-xr-xr-x 1 root root 47744 2010-01-04 18:09 mex
-r-xr-xr-x 1 root root 10594 2010-01-04 18:09 mexext
-r-xr-xr-x 1 root root 12979 2010-01-04 18:09
-r-xr-xr-x 1 root root 758 2009-05-15 16:32 mw_mpiexec
-r-xr-xr-x 1 root root 567 2009-05-15 16:32 mw_smpd
-r-xr-xr-x 1 root root 7217 2010-01-04 18:09
-r-xr-xr-x 1 root root 212 2009-05-15 16:32 ProductRoots
drwxr-xr-x 2 root root 4096 2011-08-20 02:35 registry
drwxr-xr-x 2 root root 4096 2011-08-20 02:29 scripts
drwxr-xr-x 3 root root 4096 2011-08-20 02:29 util
-r-xr-xr-x 1 root root 531 2009-05-15 16:32 worker

Then make the launcher point to:


Should be ok

bhaskar (hinduvsp) said : #10

Hi actionparsnip,
Now the matlab opening from the launcher but after 2 sec it closes automatically that mean the matlab dialogue box opening but closing immediately.

I'm not that conversant with Matlab, if you find out what binary you need to run then you can set that up, you may need to run the start matlab command before running it, you'll find out with websearches

bhaskar (hinduvsp) said : #12

Thanks actionparsnip,
You did the right job but in the launcher it needs extra desktop word and i found from the
The same weblink is posting here in order to help for others:

The necessary launcher command is /usr/local/matlab2010a/bin/matlab -desktop
Now my matlab works great and i will be thankful for your continuous help.

bhaskar (hinduvsp) said : #13

Thanks actionparsnip, that solved my question.