Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I was wondering is it possible to bind say F5 to output sudo apt-get update so I can press one key to write this into the terminal?

share|improve this question
Why not use alias? refer to man alias for details – ashofphoenix Sep 20 '10 at 8:56

Add the following to `~/.inputrc":

"\e[15~": "sudo apt-get update\n"

The character sequence to put in the beginning can be gotten by using od -c <<< "CtrlV F5" and changing the 033 that shows up to \e. The change won't take effect until you open a new shell though.

share|improve this answer
bind '"\e[[E": "sudo apt-get update\n"' – Jamie Sep 10 '10 at 14:40
using ~.inputrc didnt work but the finding the key thing with od -c did work – Jamie Sep 10 '10 at 14:45
extra space will render "bash: alias: sudo apt-get update: not found" it should be alias update= sudo apt-get update' "just removed one space between = and sudo"' – swapyonubuntu Aug 1 '15 at 6:15

Try using this to assign shortcuts: alias

alias update= 'sudo apt-get update' >> enter or return

So now if you type "update" (without the quotes) in the terminal it will automatically run update. "alias" is not needed unless you are assigning the shortcut.

alias {the name of the shortcut}= '{the command line}'
alias agi= 'sudo apt-get install'

Remember one thing though; try the shortcut name in the command line first to make sure it is not already a terminal command.

"install" is already a terminal command itself, this is why agi was used.

I just came across your post and it is quite a bit late for my response, but maybe this will help others if you see this response or not.

share|improve this answer

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.