This question already has an answer here:

I just installed Open Office from the deb package. By default, it is installed in /opt so I can start OO writer with:


But, I want it to automatically open .docx files.

When I right-click on a docx file and select "Open With", it doesn't let me select Open Office. How can I tell Ubuntu to always open docx files with /opt/openoffice4/program/soffice ?

I have Ubuntu 12.04.

marked as duplicate by Eliah Kagan, RobotHumans, Eric Carvalho, Tim, nux Aug 12 '14 at 11:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can change defaults by following method:

  1. Open defaults.list by following command:

    sudo gedit /etc/gnome/defaults.list
  2. Wher you find following line which is default for Libre-office:

  3. Replace with open-office desktop file:

  4. Save file and exit.

Note: In file /etc/gnome/defaults.list you can change default applications with desktop file (for find extension or app name you can use Ctrl+F and Ctrl+H for replace).

Additional Information:

The file openoffice-writer.desktop should be exist in /usr/share/applications (Recommended to put/use provided desktop file) If not, then you can create as follows:

  • sudo gedit /usr/share/applications/openoffice-writer.desktop

  • Then put following data in file

    [Desktop Entry]
    Name=OpenOffice Writer
    Exec=/opt/openoffice4/program/soffice %U
  • Then save and close it.
  • Give execution permission by sudo chmod +x /usr/share/applications/openoffice-writer.desktop

Now set file as default as mentioned first.

Note: Here openoffice-writer.desktop is only suggested example name. Use provided desktop file if exist.

  • N.B. .desktop files can also have mimetypes - in this case something like MimeType=application/msword;application/vnd.ms-word;application/x-doc;application/x-hwp;application/vnd.ms-word.document.macroenabled.12;application/vnd.ms-works; could cover doc files. Adding Categories=Office;WordProcessor; may also mean it is sorted correctly in application menus/dash/whatever. If using gedit, gksudo or similar should probably be used as well - chmod/chown could also be used to give the file read-write permissions to non-root users. – Wilf Aug 11 '14 at 8:48
  • @Wilf Yes welcome to Improve this answer by adding proper MimeType – Pandya Aug 11 '14 at 8:51
  • Thanks so much for the detailed information! I followed your instructions and it worked perfectly. – Erel Segal-Halevi Aug 15 '14 at 8:45

Probably there was not been created .desktop files, i don't know where they are in ubuntu 12.04, but there are a lot of application to create these files. For instance https://apps.ubuntu.com/cat/applications/create-launcher/ but more standard and longer solution is explained in Add custom command in the open with dialog? , I havent tested these solutions on Ubuntu 12.04 but it should work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.