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

I found a nautilus script I would like to use. How do I install it?

share|improve this question
up vote 26 down vote accepted

Say you want to install the following script you found while browsing Ask Ubuntu:

## Sample Script 0.1
## Dependencies: notify-osd

notify-send "Sample nautilus script" "You Selected $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"


The first thing you'll notice is that many scripts won't just run out of the box. Sometimes they depend on other packages you might or might not have installed. In this case our script depends on notify-osd, which comes with Ubuntu by default.

On other distros this might not be the case and you'll have to install the dependencies before using the script. If the dependency is part of the official repositories you can easily install it with apt-get, e.g.:

sudo apt-get install notify-osd

Setting the script up

Now that we've satisfied all dependencies we can move on and copy the script to our system. To do so we first create a new document in our scripts folder, which is ~/.gnome2/nautilus-scripts or ~/.local/share/nautilus/scripts/ on Ubuntu 13.04 and above. This is a hidden folder. In order to head to it you will have to open your file manager, press CTRL+L and paste the directory path into the Location bar.

Next we will create a new empty document by right clicking and selecting Create new DocumentEmpty Document. Name it anything you want, but beware: The title you choose is how the script entry will later appear in the nautilus context menu. So better choose a descriptive name for the document:

enter image description here

Open the new document up in a text editor of your choice and proceed to copy and paste the contents of the code box above into it. Save it and exit the text editor.

Making it executable

At this point your script is set up correctly but still won't work as the system does not recognize it as an executable file yet. To make it executable, right click on your file and head to PropertiesPermissions. Set the checkmark at Allow Executing as program and close the dialogue:

enter image description here


You should now be able to access the script from your nautilus context menu. Just right click on a file of your choice and head to Scripts --> Script name (here: Sample Script). Click on the entry to execute the script on the files you selected:

enter image description here

Assigning a keyboard shortcut to the script

Keyboard shortcuts for Nautilus scripts can be assigned by editing Nautilus' keyboard accelerator file. On Ubuntu 12.04 and below this file can be found under ~/.gnome2/accels/nautilus. On newer releases this file has been moved to ~/.config/nautilus/accels. Please note that your script will only appear in the accelerator file after restarting Nautilus (execute nautilus -q, then launch Nautilus again by clicking on its launcher).

The syntax of the accelerator file might look a bit overwhelming at first but it's actually pretty easy. Take a look at this excerpt, for instance:

; (gtk_accel_path "<Actions>/ShellActions/ZoomInAccel2" "<Primary>KP_Add")
; (gtk_accel_path "<Actions>/ShellActions/TabsNext" "<Primary>Page_Down")
; (gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sglutanimate\\s.gnome2\\snautilus-scripts\\sSample%20script" "")
; (gtk_accel_path "<Actions>/ShellActions/Search" "<Primary>f")
; (gtk_accel_path "<Actions>/ShellActions/Forward" "<Alt>Right")

Every line represents a single key assignment. The first double-quoted segment designates the action, the second one the assigned key combination. Lines starting with a semicolon are commented and currently inactive.

In order to assign a shortcut to your script you will have to search this file for the name of the script and uncomment the corresponding line by removing the semicolon. Then proceed to type in the keyboard shortcut you would like to assign.

These are the available modifiers and their corresponding keycodes:

  • CTRL = <Primary>
  • ALT = <Alt>
  • SHIFT = <Shift>

You can find valid keycodes for all other keys by using xev.

Here's how you would have to modify the section above to assign your sample script to ALT + SHIFT + S:

; (gtk_accel_path "<Actions>/ShellActions/ZoomInAccel2" "<Primary>KP_Add")
; (gtk_accel_path "<Actions>/ShellActions/TabsNext" "<Primary>Page_Down")
(gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sglutanimate\\s.gnome2\\snautilus-scripts\\sSample%20script" "<Alt><Shift>s")
; (gtk_accel_path "<Actions>/ShellActions/Search" "<Primary>f")
; (gtk_accel_path "<Actions>/ShellActions/Forward" "<Alt>Right")

On Ubuntu 12.04 (and perhaps later releases as well) Nautilus will sometimes overwrite the accelerator file before you can make any changes. So it might be a good idea to perform all of the changes you make while Nautilus isn't running (nautilus -q). Either way, you will have to restart Nautilus to see the changes.

Automating the installation

This Nautilus script will automatically install Nautilus scripts for you. Please take a look at the comments to see what's going on behind the scenes:

# AUTHOR:       Glutanimate (
# LICENSE:      GNU GPLv3 (
# NAME:         Nautilus Scripts Installer
# DESCRIPTION:  This script will install Nautilus scripts on Ubuntu 12.04 and above.
#               Note: scripts of the same name in the destination folder will be
#               overwritten without warning

# general purpose notification function
    notify-send -i gnome-app-install "Nautilus Scripts Installer" "$1"

# check if any files selected
if [[ -z "$@" ]]
      gui_notify "Error: No files selected."
      exit 1

RELEASE="$(lsb_release -r | cut -f2)"   # detect Ubuntu release

if [[ "$RELEASE" = "12.04" ]]           # set script folder accordingly

for Script in "$@"; do

  ScriptFilename="${Script##*/}"                # get filename via bash string manipulation

  cp "$Script" "$ScriptFolder/"                 # Move script to destination
  chmod u+x "$ScriptFolder/$ScriptFilename"     # Make it executable for the user


gui_notify "The following scripts have been installed: $@"

As an aside: Here's the nautilus script I used to record the screencasts of this answer.

share|improve this answer
Nice answer with screen cast. :) – TheKojuEffect Feb 13 '14 at 2:52
@MestreLion Thank your for the note. I took this and all of your other comments into consideration and modified the answer accordingly. – Glutanimate May 30 '14 at 12:57
An amazing answer just got even better! The screencast gifs are awesome, and the new section about keyboard accelerators is great! Wish I could upvote this more... – MestreLion Jun 1 '14 at 12:58
Possibly, this answer could be even more enhanced including information about assigning icons to scripts using Nautilus file properties window or command line (e. g. ). – dess Jul 12 '15 at 9:19

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.