How-To Geek

Assign Custom Shortcut Keys on Ubuntu Linux

Ubuntu includes a very limited shortcut key configuration utility which doesn’t allow you to assign hotkeys to your own applications or scripts. To get around this limitation, we can use the built-in gconf-editor utility to assign them ourselves.

First you’ll want to load up gconf-editor by typing it into the Alt+F2 Run dialog.

Once in the application, navigate to the following key. If you are familiar with regedit on Windows, this is very similar.

apps \ metacity \ keybinding_commands

You’ll notice a bunch of values on the right. These are the available commands that you can create for assigning to shortcut keys in the next step.

Double-click on command_1 and enter in the full path to your script or executable that you are trying to run. (Note that you can use the which command from the shell to find the path most of the time)


Now navigate to the key “global_keybindings”, which is directly above the one we were on.

Here you will want to select run_command_1. Enter in the shortcut key in plain text. For instance, for Alt+T, you’ll do <Alt>T. You could use <Ctrl>T or <Alt><Ctrl>T, or whatever you want to assign to the key.

You can also create custom commands in the keybinding_commands and assign them in the global_keybindings if you want. Just remember that the keybindings will start with run_(name of command).

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 05/1/07

Comments (38)

  1. invid

    I have a question related to hotkeys. I can switch between the desktop
    and the tray, using Tab – but from there I can only move
    from one panel to another. Ins’t there a way to – for example – restore
    a KDocked app solely using the keyboard, by moving to the notification
    panel and somehow picking its icon and hitting Enter or something like
    that (similar to what can be done with the Windows tray)?

    Thanks! This article was AMAZINGLY helpful btw!! Thanks!!!

  2. The Geek


    I’m working on some articles to cover that type of scenario. The short answer is: It’s not built-in.

    If you want a more configurable GUI experience, you should try Kubuntu or install KDE on top of Ubuntu, and try that out.

  3. dooglus

    I just tried doing what you describe, but can’t get it to work at all.

    Could it be that it only works if you’re not using “Desktop Effects” (ie. compiz)?

  4. Erik

    Or do it the Unix way:

    Reading values:

    gconftool-2 -g /apps/metacity/keybinding_commands/command_1

    Recursive list below a certain key:

    gconftool -R /apps/metacity/keybinding_commands
    gconftool -R /apps/metacity/global_keybindings

    Writing values:

    gconftool-2 -s /apps/metacity/keybinding_commands/command_1 -t string rxvt-unicode
    gconftool-2 -s /apps/metacity/global_keybindings/run_command_1 -t string ‘F1’

  5. invid

    Thanks! I have always liked the smaller taskbar in gnome as opposed to the default KDE one – but I haven’t really used KDE enough to uncover all of its customizing power. I’ll give KDE on Ubuntu a try – perhaps my next build will be Kubuntu!

  6. Geeky

    Great tip, thanks.

    Now how about switching between apps with a keystroke? I have a term with all my good stuff in it and if I’m two workspaces across it’s a pain to navigate back and find the term.

    This tip launches a new app each time you do the keystroke. I just want to switch. Like with Quicksilver on the Mac.

    Thank you!

  7. The Geek

    I know, I want a hotkey specifically assigned to a particular window. What you can try is the drop-down console called Tilda:

    You can assign that console to a hotkey, and there are options to make it show up on all desktops. It’s what I use when on Ubuntu.

  8. JDS

    Noob to Ubuntu trying to figure out how to have hotkey “type” email address and other repetitive text?

  9. invid

    I am LOVIN KDE now that I am actually running it and digging into it. But I still haven’t figured out how to navigate through the items in my taskbar items via the keyboard. Anyone know of a reference or guide that would shed some light on this?


  10. eythor

    Hey, I am trying to get xmms working with global hotkeys, so this is what I tried:
    keybinding_commands: command_1, value: xmms –play
    global_keybindings: run_command_1. value: Up
    Any idea why it doesn’t work?

  11. eythor

    keybinding_commands: command_1, value: xmms –play
    global_keybindings: run_command_1. value: Control Up (with the triangular characters around Control)

  12. arin

    Thanks very much for sharing, this makes opening common applications so much easier.

    Er, sorry if this sounds like a dumb question, but how do I enter a command that would open up a particular webpage (say, wikipedia) in Firefox (my default browser) withing gnome? I know in KDE it would be as easy as typing the web address (I think).

    Thanks again tho!!

  13. Adaptr010

    I’ve got a laptop, wich has four keys right top of keyboad (wifi on/off, webcam on/off, open mail and laptop on/off) three keys work as advertised by the icon, but the webcam key doesn’t, it switches me to tty2 (bummer) So my webcam can’t work, because it’s getting no power.

    My question is: How do i change this key to it’s advertised function?

  14. david

    Is it possible in Feisty to assign a particular key combo to perform an action on an explicit window? For example, I would like to bind, say, F4 to raise the Thunderbird window (*not* re-execute thunderbird which is already running)?

    When I am done reading my mail, I minimize the thunderbird window. But getting it re-raised again to read new is a hassle – one problem, is that the alt-tab window list has the minimized windows *at the bottom* – which is exactly what I don’t want!


  15. hemant

    I assigned a short cut key to start up tomcat in a xterm window. I would like to have a custom icon to this xterm window. Does anyone know how i can do that. I tried looking up the man page for xterm, didnt get any clue.
    appreciate any help on this.

  16. nqsonk9

    Guys, anybody happen to know how to view every process done by Ubuntu ? Eg: After starting Rhythmbox, what terminal command can be use to play or stop a song ? I think it would become useful with scripting.

  17. Joshi

    Hi All,

    I am facing some issues iwth my fedora core 5 desktop. I cahnged the resolution of my desktop with root previlges. It happenedeto all the users and root’s desktop, but it is not happening for a particular user’s desktop. I used the command system-config-display for this. Is there any way to change it using the gconf-editor. How can I set up my browser to connect to internet only through proxy server allways(mandatory for all the users-they will not be able to change it).



  18. John David

    @JDS: Check out Snippits:
    @How-To Geek: How can I map special keys such as the “windows” key or the “pause/break” key using this method?

  19. John David

    Found it!

    Super_L = Left Win key
    Super_R = Right Win key

  20. Miikka

    It says:
    “There was an error running the command “/home/myname/”:
    Starting the child process “/home/myname/” failed (Permission denied).”
    (Translated it from Finnish)
    It says it for every file in my home directory. Even for .txt files! If i write “firefox” to the command_1 it opens it easily.
    What is wrong? And btw I have Ubuntu 8.04.

  21. memordial

    @ John David : what about pause n break keys?? did you find it

  22. Ugur

    Firstly thanks for the article..

    I have the same problem with Miikka and Ubuntu 8.04

    Is there a solution.

  23. Ugur

    I figure out that one of the problem is numpad cannot be used with this. Is there a way that I can appoint a function to numpad ‘8’?

  24. Sy

    Thank you for this it was just what I was looking for. I have mentioned this thread here (, I hope that is ok.

    Thanks again


  25. Timmyson

    You can access the keypad numbers with something like “<Super>KP_5”

    Question for the masses:
    I can get this to work with any of the keypad except number 9. When I set a command to 9, it gets recorded as such in the Configuration Editor, however the previous value remains active, and 9 doesn’t work. Eg. If I change “KP_5” to “KP_9” (in conjuction with <Control> and <Super>then pressing 5 works, and 9 does not. Is this how it works for other people?

    And Ican’t get any punctuation keys, or symbols around the numpad to work. Does anyone know of a comprehensive list of the names of the keys? Google has been failing me.

  26. ugur

    Thanks for replies.

    I have another question:

    Is it possible to appoint key combinations other than alt and control, like a+s or KP_8+KP_9

  27. Ajesh

    This article was really helpful. But I think one needs to write the Control key at instead of . At least for me, on Ubuntu 8.10, the latter didn’t work.

  28. NoLongerValid

    This was a useful article for me last year (Thanks alot, I needed it), but the development team has taken notice with Ubuntu 9.04. The steps given are no longer valid, and they added the ability to easily create custom commands using the Keyboard configurator that was nearly worthless beforehand.

  29. fry

    I had some difficulty assigning window_keybindings to numpad keys like +. The name for this key is apparently KP_Add. The . on the keypad is KP_decimal. Google those 2 to find more.

    Oh, great, I assigned a shortcut to shift-d somewhere and can’t find it, so now I can’t type a capital d.

  30. Mike

    Thanks… I love your solution… yippee! :D

    I’ve just added E to bring up a File browser :) [same as Windows XP]

    I set ‘command1’ to be ‘nautilus’.

    (Just in case some people don’t realise the ‘Super’ key in Ubuntu refers to the ‘Windows’ key on PC keyboards).

  31. Mike

    “I’ve just added E” should read “I’ve just added <Super>

    Note that as <Super> isn’t an HTML tag then it should post OK here. I would also specify what the posting policy is in regard to ordinary HTML tags, i.e. they are rendered.

    I’m also wondering if you’re not checking HTML tags (i.e. <Super> behaved unexpectedly), if you’re performing any security checks on postings.

  32. Pete-PeAks

    i have installed ubunto (to run along side windows) how do i work it how do i get my mobile dongle to work how do etc etc

  33. dalton

    how do you make a shortcut when you’re in the xterm window of x-win32?

  34. Joliea

    Thanks!!! It worked.

  35. thyme676

    Btw, I tried this and found out that control is not Ctrl, but Control in ubuntu. Changed from former to latter and it worked.

  36. vineel

    d can be set to show_desktop to simulate win+D

  37. ssas

    i want to know about the shortcut keys and all.. inubuntu os and i want to know about the terminal in ubuntu so friend please post me the name of the book from where i can get all these

  38. Noob

    Hi I tried this but nothing happens when I press Alt+F3. Can somebody please help?



    contents of
    echo hello

    If I replace the keybinding_commands to “firefox”, it works okay so I’m thinking either it’s the script or the keybinding_command is wrong

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!