I want to use some applications shown on the Unity Launcher in a terminal, but I need to know the appropriate command to run them. How can I achieve that?
-
Thru System Settings, I configured the launcher to auto-hide and to come back when mouse is in the left upper corner. But then I coudn't activate the launcher, and I needed to start the System Settings again to revert it, and I was with terminal open. But how is the command for System Settings (and other items in the launcher)?– Sony SantosApr 27, 2012 at 18:40
8 Answers
Most default applications will have a .desktop
file located in /usr/share/applications
.
To find out about the corresponding terminal command that will be run when launching one of these applications open the file browser Nautilus and right click on the application's icon to select Properties in the context menu. This will give you all details you need (shown here for System Settings that will run gnome-control-center -overview
)
-
2Is there any alternative for this by now which can be used from within the
Unity Launcher
? I pretty often find myself in a situation where I find a program in the launcher and like to get this kind of information without having to fire up Nautilus or the command line first...– suamikimSep 30, 2016 at 8:54
If you installed the application through the repositories or through dpkg
, you can use this command:
dpkg -l | grep "application name"
This will search through all your installed applications, as well as search their descriptions; searching the description is the important part here, because the description usually contains the name of the application, even if the "command" to run it does not contain the application name.
Example:
In GNOME, there's an application called the Disk Usage Analyzer. However, the command to run it from the terminal is not disk-usage-analyzer
. To find out its command, you can run:
dpkg -l | grep "disk usage"
The output should contain this entry:
alaa@aa-lu:~$ dpkg -l | grep "disk usage"
ii baobab 3.6.4-0ubuntu1 i386 GNOME disk usage analyzer
Look at the second column. The command to actually run the Disk Usage Analyzer is baobab
.
What you can do is use xprop
: it will let you click on a application and display information. To get the name, enter in a terminal:
xprop | grep WM_CLASS
if WM_CLASS
doesn't work, then try with WM_COMMAND
.
-
-
1@Liker777 Don't grep for "terminal". The pattern should be "WM_CLASS" as stated. Try
xprop
alone to see. Then your cursor is changed into a small cross. Click on the window of choice. Info should be displayed. Feb 19, 2021 at 14:24
First, open Synaptic by running synaptic
in the terminal. Type the name of the app in the quick filter box. For an example, I'll use LibreOffice Writer
. Type the name of the app in the Synaptic filter:
It appears as the first installed result (little green box), with the full package name libreoffice-writer
in the first column.
Now, try running libreoffice-writer
in the terminal. Sometimes the package will run, but in this case it doesn't work:
Now, if you look back at Synaptic, you will see that the very first result is the libreoffice
package. You could just run libreoffice
in the terminal, in which case you get this window:
Or, you could type man libreoffice
in the terminal. If you look at the these two screenshots:
You can see that to directly launch LibreOffice Writer, you can use one of two commands: lowriter
or libreoffice --writer
. Both work equally well.
-
That's very interesting. Ubuntu 12.04 hasn't
synaptic
, but it hassoftware-center
(whose name I found using it itself). But I coudn't find the System Settings, which I discovered to begnome-control-center
thru the PS way. +1 anyway. Apr 27, 2012 at 18:59 -
Synaptic
can be installed by runningsudo apt-get install synaptic
in terminal. It was removed at the 11.10 release. It is such a fantastic program, such a shame that they removed it from the official install. Apr 27, 2012 at 19:19
Some programs or applications simply run by a binary. By name of application one can find out where binary is located.
whereis name-of-application
ergo little example:
$ whereis gparted
gparted: /usr/sbin/gparted /usr/share/man/man8/gparted.8.gz
You simply can take over /usr/sbin/gparted
- for to run this application gparted in entry of icon or application-name (like in cairo-dock
). (in this case to run gparted root-password is necessary).
xprop
allows finding the PID of a running window, while ps
allows finding command corresponding to a PID. By combining the two together, we can find a command corresponding to a window , like so :
ps --no-headers -p $(xprop | awk -F '=' '/_NET_WM_PID/{print $2}') -o cmd
xprop
will turn your cursor into X
, which you can use to click on a window, it will return the PID, and then ps
will use that PID to print the command
That is too simple for Linux geeks.
Close the application if it is open.
Open the application by clicking its icon.
For example, I click the icon Document Viewer.
Open Terminal (ctl alt T), and run
ps -u `whoami`|tail -3
The answer is on the first line of ouput:
mac2011-linux% ps -u `whoami`|tail -3
51252 ? 00:00:01 evince
53209 pts/3 00:00:00 ps
53211 pts/3 00:00:00 tail
Yes, Document Viewer is evince, not easy to guess.
From https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html:
Basically when you install an app, a .desktop file is generated somewhere. This .desktop file is what tells the desktop environment which command to run. There are many .desktop files scattered around the file system. Their locations are specified by the $XDG_DATA_DIRS
environment variable, although most of them are in a subdirectory called "applications" in the paths specified in $XDG_DATA_DIRS
. So you basically have to go through all of those files, check one by one the name of the app specified in them, and once you finally find the one with the name of your app you check the "Exec" key in them.
This super long command does that automatically for you. Just make sure to specify the name of the program to search for at the beginning and then run it in a terminal (PS: You can open a terminal with Ctrl+Shift+T).
NameOfProgramToSearchFor='CopyQ' && \
find $(tr ':' ' ' <<<"$XDG_DATA_DIRS") \
-name '*.desktop' \
-exec grep -e '^Name=' -e '^Exec=' {} \; 2>/dev/null |
grep -i -A 1 "^Name=.*$NameOfProgramToSearchFor.*$"
Or you can just do what @Takkat said. In my case his solution didn't work because I couldn't find the "Properties" button in the right click menu, since I am using Zorin OS and it doesn't show that option. Zorin OS is based on Ubuntu, so I can't really tell if this is just a Zorin OS thing or it's that @Takkat used an older version of Ubuntu.