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 have always recommended pressing ALT+F2 and typing for example gksu nautilus or gksudo nautilus both are equivalent; to run graphical programs with root privileges. However, I have just installed raring on a test system and this no longer works.

gksu and gksudo are not installed as part of a default raring install; though they are in the repositories. In 12.04 at least gksudo was just a symbolic link to gksu

The reasons I have always done this are because while it is often safe to use sudo under some circumstances it can cause problems with graphical applications because gksu has you running the program as root while with sudo you are running as yourself but with elevated privileges.

This can mean you inadvertently change the owner of critical system files. This can cause problems.

This reasoning is explained better here:

Why was command removed from a fresh install and what should we be using instead?

share|improve this question
    
See gksudo missing in Ubuntu forum. –  user68186 Apr 22 '13 at 19:58
2  
As a clarification, gksudo and gksu are not identical, even though one is a symbolic link to another (the program detects how it was initiated). There is a subtle difference that, in rare cases, can lead to the loss of selected system files. Therefore, until you start to use pkexec, please always use gksudo instead of gksu. –  Paddy Landau Apr 30 '13 at 10:07
    
@PaddyLandau I like many others here always 'gksu` and gksudo were the same see What is the difference between gksudo and gksu?. Can you add an answer to that question that explains the difference please; or give us a link to a website that explains it so one of us can. –  Warren Hill Apr 30 '13 at 10:17
    
@WarrenHill - I have posted an answer on that thread for you. –  Paddy Landau Apr 30 '13 at 13:42
    
@PaddyLandau thanks –  Warren Hill Apr 30 '13 at 13:50
show 2 more comments

4 Answers 4

up vote 31 down vote accepted

After a long discussion on #ubuntu-devel I now understand the thinking.

gksu can be installed on 13.04 with sudo apt-get install gksu and it will work.

If you decided to install gksu and are using the 64-bit version you'll need to run gksu-properties once to set the authentication to sudo. There is no need to do this on 32-bit as it's set to sudo by default.

However gksu is not recommended any more and it may be removed entirely from future issues of Ubuntu. In general the development team would prefer us not to use GUI applications as root but to use sudo and the command line instead.

In the long term pkexec is preferred however it's not very easy to use at the moment.

pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.

see the man page man pkexec for more information.

In the mean time you can open a terminal CTRL+ALT+T or search for terminal in dash.

Do not close the terminal until you have finished this is important as the GUI program is a child of the terminal and if you close it the GUI program will also close.

Enter sudo -i

You are now logged on as root so can make the changes you want for example

gedit path_to_file 

to edit a configuration file, or

nautilus 

to run the file manager

When you are finished close the GUI application then in the terminal

exit

You can now close the terminal.

share|improve this answer
27  
Telling users to use the command line instead of running graphical applications as root isn't going to go over well with Windows converts... –  Seth Apr 29 '13 at 20:19
2  
@Seth I'm just reporting what I was told in #ubuntu-devel. Personally I don't have a problem with the command line but I know not everyone is comfortable with it. –  Warren Hill Apr 30 '13 at 5:50
2  
I didn't mean it anyway personally.. I'm commenting on the information not you ;-) –  Seth Apr 30 '13 at 22:42
2  
By the way, you can void the "closing the terminal kills all spawned programs" issue by launching the program with the & suffix so that it runs as a background process and then issuing disown %1 in bash -- or whatever job number the program is. Then you can safely close the terminal. So, it could be something like: sudo my-program &;disown %1;exit; –  Githlar May 18 '13 at 22:45
4  
However gksu is not recommended any more and it may be removed entirely.... Care to elaborate on why? –  MestreLion May 21 '13 at 0:14
show 5 more comments

I just installed 13.04 : GKSU is already installed...

share|improve this answer
    
i have just checked .....its installed ....... –  Qasim May 1 '13 at 23:40
1  
I was going to make a command about this answer but took a second to check if gksu was there. It is. I even installed a fresh 13.04 64 bit and it was also there. –  Luis Alvarado May 2 '13 at 1:14
1  
I've just checked again on my system. Still not there see these threads on Ubuntu Forums here and here. Perhaps it has been added to a recent update, or is it possible you have bought it in by installing something else? –  Warren Hill May 2 '13 at 5:49
add comment

According to its changelog, it was dropped as it wasn't ported to Gnome 3 and that was blocking the transition to Nautilus 3.

share|improve this answer
    
See pkexec as an alternate to gksudo. –  user68186 Apr 22 '13 at 21:35
8  
That's nautilus-gksu, not gksu. –  psusi Apr 29 '13 at 13:57
1  
-1 as per psusi. This is wrong information. –  ignis Jul 5 '13 at 16:10
add comment

Simply use:

alias gsudo='/usr/bin/sudo -H'

This way its OK to use gsudo for GUI applications.

share|improve this answer
8  
This will not work when you need a GUI; for example, running the command from Alt+F2 or using it a script that is called from the Launcher. –  Paddy Landau Apr 30 '13 at 10:05
    
To clarify what (I believe) @PaddyLandau is saying: Although this may work to run graphical programs, it will not display a graphical authentication window. So if you have to authenticate, it will fail silently. –  Eliah Kagan Jul 1 '13 at 18:05
7  
@EliahKagan - No… it's because an alias is not recognised in Alt+F2 or from within scripts. It will work from the command line in the terminal. –  Paddy Landau Jul 2 '13 at 15:23
    
I believe @PaddyLandau suggestion offers a nice alternative and example for those of us who are often in a shell. Obviously this is not intended to answer why gksu was removed.* That said, the sudo -H option usually works and it's effect seems similar to sudo -i .. however I setup my gsudo alias using -i. The main difference I've identified (using printenv)is that -i includes the environment variable QT_QPA_PLATFORMTHEME which I believe is for the theme for QT apps. –  mike stewart 2 days ago
add comment

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.