Linux: Shell Commands for GUI Apps

By Xah Lee. Date: . Last updated: .

Command to Open File

xdg-open file_path

# open current dir
xdg-open .

In gnome, you can use gvfs-open file_path. (Note: there's gnome-open, but is deprecated.)

Command to Move File to Trash

Find Command Name of App

Method 1, Use xprop

  1. In terminal, type xprop
  2. then click the window
  3. then read the line “WM_CLASS” and “_NET_WM_PID”.

Method 2: Use ps

launch the app by mouse. Then, in terminal type ps -ef | grep string, where string is what you think the name contains, for example, {gnome, kde, xfce, unity, setting, viewer}.

Method 3: Use top

type top first, then launch the app, and watch it appear in top.

Command to Put Machine to Sleep

Command to Set Default App

launch GUI app from terminal?

xyz & → launch GUI app named “xyz”.

or

setsid xyz

[see Linux: GUI Apps Command Names]

[see Linux: Job Control]

Linux: Sync X11 Primary Selection and Clipboard

Linux: Sync X11 Primary Selection and Clipboard

thanks to [ amirhoshangi ] https://twitter.com/amirhoshangi, [Manuel Lara https://plus.google.com/100356143682994881415/posts], Leonardo Torres, Yanko Simeonoff.