Ubuntu: How to make shortcuts to executables



Question:

I'm a little bit noob. I can run a program in terminal with;

$sudo /opt/eclipse/eclipse  

but I don't know how to create a shortcut that starts it with root privileges (They are installed in /opt so it needs root)


Solution:1

ALL of the default programs which come preinstalled with Ubuntu or which can be installed from repositories are "installed as root" in system directories, yet you do not need to superuser privileges to run them.

You're confusing the permissions necessary to read/execute a program with permissions necessary to override or delete the file. The program file may be owned by root, but if your user has execute privileges, you'll be able to run the program. The running process will have User ID of your user, so it won't be able to modify files owned by root.

This is an important security measure and running with super-user privileges should be reserved only for a small set of trusted applications which actually require this (i.e. the ones which make change to system configuration (Software Center and Update Manager) or directly access hardware devices (gparted).

Eclipse does not require root privileges regardless of whether it is installed in /opt or in your home directory (which I personally prefer). What's probably happening is that you started it as root the first time so the directory in your home folder which stores Eclipse configuration (home/(yourusername)/.eclipse) is owned by root. You need to change the directory's owner to give Eclipse to write there when started as non-privileged user:

chown -R yourusername:yourusername ~/.eclipse  


Solution:2

Usually the easiest way is just making a shell script. What ever command you use to launch eclipse use the same.

You probably want to use "gksudo" and then your command which looks like

gksudo /opt/eclipse/eclipse

Then put that in a regular file with a .sh extension. Right click the file and add execution permissions. You can also use chmod +x filename.sh

Here is a good tutorial to get you the basics of bash scripts. Its really easy and powerful.

http://linuxconfig.org/Bash_scripting_Tutorial

I haven't tried launching eclipse from the command line, but I believe it is built with java. If that is the case you might also need to specify java -jar in there some where, but I'm not sure.

Hope this helps.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »