Ubuntu Tutorial

List Desktop Applications : ubuntu store desktop application programs or files in /usr/share/applications directory, with extension desktop. these files or programs are used to open application.

ls /usr/share/applications command will print all .desktop files.

image
list .desktop applications

following command will result the same.

  • for app in /usr/share/applications/*.desktop; do echo "${app:24:-8}"; done : this will print name of files without extension and every file name will be on separate line.
  • Execute *.desktop File (Open Application) : to execute desktop file use gtk-launch command. we have to move /usr/share/applications directory to execute gtk-launch command.

    Note : gtk-launch command does not accept path.

    syntax : gtk-launch filename

    in following example we are opening firefox application. when we close the application we get notified on terminal (but the cursor was not pointing on it's normal position, so i pressed ctrl + c to stop that. you can see ^c used at the end.)

    image
    open .desktop applications

    Open Application Without *.desktop File : instead of going to any specific path to open application. we just need to know command to open the application. if we execute that command the application will get open.

    1. list gnome application commands : many of the ubuntu application are gnome applications. eg. gnome-control-center command open ubuntu systems settings. to see these applications type gnome- on terminal and press tab 2 times. this will print all commands that start with gnome-.

      image
      list gnome application or gnome application commands

    2. list libreoffice applications : LibreOffice is a free office suite. it is similar and compatible to microsoft office suite.

      run libreoffice command. this will open libreoffice application, see following example. select your libreoffice application that you want to open. like writer, calc, draw, impress, global, math, base, web.

      image
      list libreoffice application

      OR you can open individual libreoffice software application. to open file with application. pass file name to application. for example libreoffice --writer file-name

      • libreoffice --writer : this will open empty libreoffice word document.
      • libreoffice --calc : this will open empty libreoffice spreadsheet document.
      • libreoffice --draw : this will open empty libreoffice paint document.
      • libreoffice --impress : this will open empty libreoffice presentation document.
      • libreoffice --base : this will open empty libreoffice database management document.
      • libreoffice --global : similar to libreoffice command.
      • libreoffice --math : this will open empty libreoffice math document (mathematical formula creation and editing).
      • libreoffice --web : this will open empty libreoffice HTML document.

    3. other applications : following are some commands to open other applications.

      • nautilus : open file explorer with home path.
      • nautilus --browser ~/path : open given path in file explorer.
      • google-chrome : open google chrome browser.
      • firefox : open firefox browser.
      • cheese : application for camera(to take photo and video).
      • shotwell : it is photo organizer application.
      • rhythmbox : it is a music or audio player.
      • totem : it is s the movie or video player.

    Open Files With It's Default Program : if we want to open image file from terminal(not as text) then we need command that can open image with it's default application. to open file with it's default application we use xdg-open command.

    Note : xdg-open will open *.desktop as text file.

    in following example we open audio song file with music player (default application to play audio)

    image
    open file with default application

    Open Application With Another Program : in this we open file with other application. following are way to do this.

    1. using file explorer : select file in file explorer > right click > select Open With Other Application > select application if it is not there then select View All Applications or select Find New Applications and select your application then > click on select

      image
      open file with another application using file explorer

    2. using terminal : to open file with another application we use mimeopen. to more information use manual page for the mimeopen command.

      syntax : mimeopen -a file-name

      in following example we open audio file with video player(application). when command get executed it ask to select the option. after selecting option 2(Videos), the audio file gets open in video player.

      image
      open file with another application using terminal

    Set Default Application For File(File Type) : : when we set default application for file, it also get applied to all other files with the same type. Example when we set default application to audio file it get applied to all audio files. following are ways to set default application.

    1. using file explorer : open file in file explorer > right click > select Properties > select Open With > select your default application > click on Set as default

      in following example we set video player(application) as default application for audio file.

      image
      set default application for file type using gui

    2. using terminal : to set default application we use mimeopen command. use following syntax.

      syntax : mimeopen -d file-name

      in following example we set default application for audio file. when command get executed it ask to select one option from 3 options. first option is default application option. when 3 option get selected. it ask for command (application) to set as default application. i want vlc as the default application for audio files. after pressing enter it will set vlc as default application for all audio files and opens file with vlc player.

      image
      set default application for file type using terminal