Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I make a custom shortcut with gnome (gnome-control-center keyboard) I can't set it to a command. Why?

Example: I can't set a shortcut for sudo apt-get update. Instead I must first invoke a graphical terminal, then bash, then execute the command (something like: gnome-terminal -e "bash -c \"sudo apt-get update ; exec bash\""

Also is there another (better) workaround?

share|improve this question

1 Answer

up vote 2 down vote accepted

You can. You've just shown you can! You can even simplify it a little:

gnome-terminal -x bash -c "sudo apt-get update"

It needs a terminal because it's interactive (because of sudo). If you just want to suppress the password request, you could edit your /etc/sudoers file so it doesn't require a password for apt-get. In my opinion, this isn't great because it might be abused.

For this command there is another option: Aptdaemon. This is what the Software Centre and Update Manager now use for permissions (it uses PolicyKit and it's designed on PackageKit). To update apt, just run:

aptdcon -c

That shouldn't require a password and if it does, it should be able to pop up a PolicyKit box without needing a terminal to be spawned.

share|improve this answer
Thank you so much Oli. Nevertheless, I suspect that some programs need the terminal to run, even if not interactive. Example: echo password | sudo -S apt-get update. And a sequence of commands is not possible too: sleep 2 && gedit Your thoughts?. – desgua Feb 23 '12 at 12:56

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.