Take the 2-minute tour ×

Is there any way to make programs ask for password when root is required? For example I want to extract some files with File Roller into /usr/share/ where apparently root is required but instead of the error that it gives me I would like a password prompt.

share|improve this question

4 Answers 4

up vote 5 down vote accepted

To directly answer your question: No, there is no way (as far as I am aware) to make a program to ask for a password instead of failing when it doesn't have enough permissions to perform an operation. There are two options:

  • Some programs are aware that they need administrative privileges for some operations and ask for a password before doing something (i.e. Software Center asks for a password before installing programs).

  • Most other programs need to be started with necessary privileges. As it has been mentioned, you need to use sudo [command] (in terminal), gksu [command] (in Gnome/Unity) or kdesu [command] (in KDE) for that.

share|improve this answer

The usual way is to go in command line mode (alt + F2 xterm, or dash terminal) then use gksudo file-roller and enter your password.

sudo and gksudo will give you root privileges.

share|improve this answer
Why a downvote? I don't see anything wrong with the answer –  Sergey Oct 30 '11 at 10:00
Just a guess, but if you open a terminal, why not use sudo instead of gksudo? –  Alexis Wilke Nov 7 '11 at 19:17

You'd have to start File Roller using gksu as mentioned by the previous user. When you add items to your startup bar, you can use a command such as faxanswer that requires privileges:

gksu faxanswer ttyS4

If you are using that File Roller once to update stuff in /usr/share, it's better to just use the Run command than create a permanent icon.

share|improve this answer
Thanks for the edits Scott. I just tried and indeed gksu and gksudo both work... –  Alexis Wilke Oct 30 '11 at 21:54


Yes - with the helper scripts.

Here is an example with the bash copy (cp). The copying (backup) is wrapped in the perl script to check the owner of the file. The script is using the perl stat /1/ command. Here the script is called from the KDE service menu /2/. If the file is owned by the root /3/ then the KDE frontend for sudo is used /4/, /5/.


usage: "backup.pl filename"

#!/usr/bin/perl -w


$MARKER = "_Backup_";

($DAY,$MONTH,$YEAR) = (localtime)[3,4,5];
$DAY_STAMP = sprintf '%04d%02d%02d', $YEAR+1900, $MONTH+1, $DAY;

for ( $I=0; $I<101; $I++ ) {
   if ( $I > 99 ) { die system ("kdialog --sorry '...too many copies'"); }
   $INDEX = sprintf '%02d', $I;
   last unless (-e $NEW_NAME);

$UID = (stat("$FILENAME"))[4];

@Q_COPY_COMMAND = ("\"", "cp", "$FILENAME", "$NEW_NAME", "\"");

if ( $UID == 0 ) {
   system ("kdesudo bash -c @Q_COPY_COMMAND");
} else {
   system ("@COPY_COMMAND");

enter image description here


  1. http://perldoc.perl.org/functions/stat.html
  2. http://techbase.kde.org/Development/Tutorials/Creating_Konqueror_Service_Menus
  3. https://help.ubuntu.com/community/RootSudo
  4. http://kde-apps.org/content/show.php?content=72106
  5. https://launchpad.net/kdesudo
share|improve this answer
I suppose this could be done for Gnome? –  abruski Oct 30 '11 at 13:37

Your Answer


