Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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)

share|improve this question
3  
"They are installed in /opt so it needs root" is wrong. There are reasons why a program would need to run as root, but this is usually not one of them. –  Ignacio Vazquez-Abrams Aug 27 '12 at 4:12

2 Answers 2

up vote 0 down vote accepted

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
share|improve this answer
    
Thanks.Appriciated.It gave me an error "cant acces workplace" or sth when I try to run as a normal user.Now i got it.I shouldn't have installed it with "sudo" in the first place.I guess I just didnt want it to be installed in my home directory. –  JeyKey Aug 27 '12 at 11:22
    
If you install a program into /opt you have to use sudo, there's nothing wrong with that. What you shouldn't do is to start the program with sudo, especially the first time - on first startup it creates a number of directories and config files which are owned by root, so on subsequent startups the program won't be able to access those files, which is likely the cause of the error messages you see. –  Sergey Aug 27 '12 at 21:42

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.

share|improve this answer
    
it worked thanks –  JeyKey Aug 27 '12 at 11:12
    
While this answers the OP's question, the question itself has been based on misunderstanding, so the answer is rather harmful than helpful. –  Sergey Aug 27 '12 at 21:48
    
I don't agree. The asker wanted to know how to make a short cut. Not your definition of how to make a short cut. –  Goddard Jun 22 '13 at 6:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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