Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
It feels like you didn't really answer his question, which I interpreted to mean, "Why do we have to wrap up commands with 'gnome-terminal ...'". Maybe it's just my interpretation, and he was really just interested in the sudo details. What actually interprets/runs the custom keyboard shortcuts anyway? – BlueBomber Aug 8 '14 at 3:27

Your Answer


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.