In Ubuntu, applications can be opened from a terminal. But sometimes it isn't clear what the appropriate command is to do this.
So, having an application open, how can I get the command used to launch it, without having to search anywhere (just by looking at it)?
I just made the following script which use the application window title to find out the right command which opens the respective application from terminal (I named it
appcmd
):Save this script in your
~/bin
directory and don't forget to make it executable:Usage:
When the script is runed without any argument, the script will return all commands for all windows opened corresponding.
If any argument is given, the script will try to find an open application window containing in its title that argument and will return the command corresponding. For example if Chromium browser is open, you can find out the command which opens it from terminal using only:
From here:
If you only need the starting command line then just:
After you've run the command just click on the window for which you want the starting command to be shown.
An alternative script:
Usage:
This requires xsel to be installed.
As an alternative without needing a script, you can just open the System Monitor and hover your mouse over the process which you'd like to know the command line of.
If you enable "Dependencies view", you'll be able to see which process called another so, for example, you can see the various processes which Chrome creates for each tab and trace it back to the parent process which will have the command line which Chrome was invoked with (by the user).
The most similar think I've found is xwininfo, which gives you information about a running window. But it doesn't tell you what program is running inside it.
Another way to list the command name and arguments of the running processes is:
(Redirect into a file so the command names/arguments are not truncated.)
Source:
man ps
: examples section (with a little modification).System monitor is a GUI for
ps
.