Tell a process PID by it's window?











up vote
46
down vote

favorite
22












How I can tell a process image name (to run from terminal using sudo) showing on the Ubuntu UI?










share|improve this question




















  • 1




    Have a look here: stackoverflow.com/questions/2041532/…
    – sulaweyo
    May 16 '12 at 14:09















up vote
46
down vote

favorite
22












How I can tell a process image name (to run from terminal using sudo) showing on the Ubuntu UI?










share|improve this question




















  • 1




    Have a look here: stackoverflow.com/questions/2041532/…
    – sulaweyo
    May 16 '12 at 14:09













up vote
46
down vote

favorite
22









up vote
46
down vote

favorite
22






22





How I can tell a process image name (to run from terminal using sudo) showing on the Ubuntu UI?










share|improve this question















How I can tell a process image name (to run from terminal using sudo) showing on the Ubuntu UI?







process






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 8 '15 at 8:44









muru

134k19283483




134k19283483










asked May 16 '12 at 13:06









Ted

3601311




3601311








  • 1




    Have a look here: stackoverflow.com/questions/2041532/…
    – sulaweyo
    May 16 '12 at 14:09














  • 1




    Have a look here: stackoverflow.com/questions/2041532/…
    – sulaweyo
    May 16 '12 at 14:09








1




1




Have a look here: stackoverflow.com/questions/2041532/…
– sulaweyo
May 16 '12 at 14:09




Have a look here: stackoverflow.com/questions/2041532/…
– sulaweyo
May 16 '12 at 14:09










5 Answers
5






active

oldest

votes

















up vote
51
down vote



accepted










Per your request on the other question, here is my answer again:




I'm sure there is a cleaner way of doing it, but for your second question you can try this:



   xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //' | ps `cat`


This will make your cursor a cross with which you can click on an open window. It will report the PID and command in the terminal you ran it in.



In general, xprop and xwininfo will provide you with a lot of information about an open window.




The "apostrophes" I used for surrounding cat are the ~ key on my keyboard without pressing shift. This should give you some more info on the subject:



Grave Accents and the backquote






share|improve this answer





















  • xprop says: _NET_WM_PID: not found. This method not foolproof enough...
    – Calmarius
    Oct 3 '12 at 17:04






  • 3




    This is easier to remember: xprop | grep PID (although it only prints the process ID)
    – KajMagnus
    Jan 10 '13 at 11:26


















up vote
13
down vote













You can try xprop | grep WM_CLASS and then click on the window you are interested in.



Examples:



#> xprop | grep WM_CLASS
WM_CLASS(STRING) = "gedit", "Gedit"

#> xprop | grep WM_CLASS
WM_CLASS(STRING) = "gcalctool", "Gcalctool"





share|improve this answer




























    up vote
    7
    down vote













    Run this command in a terminal:



    xprop | awk '/PID/ {print $3}'


    Your mouse pointer will be replaced with crosshairs; select the window you're interested in.



    This method shows just the PID of the process who owns that window (which appears to be what you want).






    share|improve this answer






























      up vote
      1
      down vote













      You can get process info using:



      $ ps -f --pid $(xprop _NET_WM_PID | grep -o '[0-9]*')





      share|improve this answer




























        up vote
        0
        down vote













        Running xprop | awk '/_NET_WM_PID(CARDINAL)/{print $NF}' and clicking the window you want the PID of will print the PID to the terminal.






        share|improve this answer





















          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f137875%2ftell-a-process-pid-by-its-window%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          51
          down vote



          accepted










          Per your request on the other question, here is my answer again:




          I'm sure there is a cleaner way of doing it, but for your second question you can try this:



             xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //' | ps `cat`


          This will make your cursor a cross with which you can click on an open window. It will report the PID and command in the terminal you ran it in.



          In general, xprop and xwininfo will provide you with a lot of information about an open window.




          The "apostrophes" I used for surrounding cat are the ~ key on my keyboard without pressing shift. This should give you some more info on the subject:



          Grave Accents and the backquote






          share|improve this answer





















          • xprop says: _NET_WM_PID: not found. This method not foolproof enough...
            – Calmarius
            Oct 3 '12 at 17:04






          • 3




            This is easier to remember: xprop | grep PID (although it only prints the process ID)
            – KajMagnus
            Jan 10 '13 at 11:26















          up vote
          51
          down vote



          accepted










          Per your request on the other question, here is my answer again:




          I'm sure there is a cleaner way of doing it, but for your second question you can try this:



             xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //' | ps `cat`


          This will make your cursor a cross with which you can click on an open window. It will report the PID and command in the terminal you ran it in.



          In general, xprop and xwininfo will provide you with a lot of information about an open window.




          The "apostrophes" I used for surrounding cat are the ~ key on my keyboard without pressing shift. This should give you some more info on the subject:



          Grave Accents and the backquote






          share|improve this answer





















          • xprop says: _NET_WM_PID: not found. This method not foolproof enough...
            – Calmarius
            Oct 3 '12 at 17:04






          • 3




            This is easier to remember: xprop | grep PID (although it only prints the process ID)
            – KajMagnus
            Jan 10 '13 at 11:26













          up vote
          51
          down vote



          accepted







          up vote
          51
          down vote



          accepted






          Per your request on the other question, here is my answer again:




          I'm sure there is a cleaner way of doing it, but for your second question you can try this:



             xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //' | ps `cat`


          This will make your cursor a cross with which you can click on an open window. It will report the PID and command in the terminal you ran it in.



          In general, xprop and xwininfo will provide you with a lot of information about an open window.




          The "apostrophes" I used for surrounding cat are the ~ key on my keyboard without pressing shift. This should give you some more info on the subject:



          Grave Accents and the backquote






          share|improve this answer












          Per your request on the other question, here is my answer again:




          I'm sure there is a cleaner way of doing it, but for your second question you can try this:



             xprop _NET_WM_PID | sed 's/_NET_WM_PID(CARDINAL) = //' | ps `cat`


          This will make your cursor a cross with which you can click on an open window. It will report the PID and command in the terminal you ran it in.



          In general, xprop and xwininfo will provide you with a lot of information about an open window.




          The "apostrophes" I used for surrounding cat are the ~ key on my keyboard without pressing shift. This should give you some more info on the subject:



          Grave Accents and the backquote







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 16 '12 at 19:19









          Nimble

          64165




          64165












          • xprop says: _NET_WM_PID: not found. This method not foolproof enough...
            – Calmarius
            Oct 3 '12 at 17:04






          • 3




            This is easier to remember: xprop | grep PID (although it only prints the process ID)
            – KajMagnus
            Jan 10 '13 at 11:26


















          • xprop says: _NET_WM_PID: not found. This method not foolproof enough...
            – Calmarius
            Oct 3 '12 at 17:04






          • 3




            This is easier to remember: xprop | grep PID (although it only prints the process ID)
            – KajMagnus
            Jan 10 '13 at 11:26
















          xprop says: _NET_WM_PID: not found. This method not foolproof enough...
          – Calmarius
          Oct 3 '12 at 17:04




          xprop says: _NET_WM_PID: not found. This method not foolproof enough...
          – Calmarius
          Oct 3 '12 at 17:04




          3




          3




          This is easier to remember: xprop | grep PID (although it only prints the process ID)
          – KajMagnus
          Jan 10 '13 at 11:26




          This is easier to remember: xprop | grep PID (although it only prints the process ID)
          – KajMagnus
          Jan 10 '13 at 11:26












          up vote
          13
          down vote













          You can try xprop | grep WM_CLASS and then click on the window you are interested in.



          Examples:



          #> xprop | grep WM_CLASS
          WM_CLASS(STRING) = "gedit", "Gedit"

          #> xprop | grep WM_CLASS
          WM_CLASS(STRING) = "gcalctool", "Gcalctool"





          share|improve this answer

























            up vote
            13
            down vote













            You can try xprop | grep WM_CLASS and then click on the window you are interested in.



            Examples:



            #> xprop | grep WM_CLASS
            WM_CLASS(STRING) = "gedit", "Gedit"

            #> xprop | grep WM_CLASS
            WM_CLASS(STRING) = "gcalctool", "Gcalctool"





            share|improve this answer























              up vote
              13
              down vote










              up vote
              13
              down vote









              You can try xprop | grep WM_CLASS and then click on the window you are interested in.



              Examples:



              #> xprop | grep WM_CLASS
              WM_CLASS(STRING) = "gedit", "Gedit"

              #> xprop | grep WM_CLASS
              WM_CLASS(STRING) = "gcalctool", "Gcalctool"





              share|improve this answer












              You can try xprop | grep WM_CLASS and then click on the window you are interested in.



              Examples:



              #> xprop | grep WM_CLASS
              WM_CLASS(STRING) = "gedit", "Gedit"

              #> xprop | grep WM_CLASS
              WM_CLASS(STRING) = "gcalctool", "Gcalctool"






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 16 '12 at 14:15









              Avio

              2,24251636




              2,24251636






















                  up vote
                  7
                  down vote













                  Run this command in a terminal:



                  xprop | awk '/PID/ {print $3}'


                  Your mouse pointer will be replaced with crosshairs; select the window you're interested in.



                  This method shows just the PID of the process who owns that window (which appears to be what you want).






                  share|improve this answer



























                    up vote
                    7
                    down vote













                    Run this command in a terminal:



                    xprop | awk '/PID/ {print $3}'


                    Your mouse pointer will be replaced with crosshairs; select the window you're interested in.



                    This method shows just the PID of the process who owns that window (which appears to be what you want).






                    share|improve this answer

























                      up vote
                      7
                      down vote










                      up vote
                      7
                      down vote









                      Run this command in a terminal:



                      xprop | awk '/PID/ {print $3}'


                      Your mouse pointer will be replaced with crosshairs; select the window you're interested in.



                      This method shows just the PID of the process who owns that window (which appears to be what you want).






                      share|improve this answer














                      Run this command in a terminal:



                      xprop | awk '/PID/ {print $3}'


                      Your mouse pointer will be replaced with crosshairs; select the window you're interested in.



                      This method shows just the PID of the process who owns that window (which appears to be what you want).







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 25 '13 at 21:07









                      Eliah Kagan

                      80.8k20226364




                      80.8k20226364










                      answered Jan 25 '13 at 8:55









                      totti

                      4,88212942




                      4,88212942






















                          up vote
                          1
                          down vote













                          You can get process info using:



                          $ ps -f --pid $(xprop _NET_WM_PID | grep -o '[0-9]*')





                          share|improve this answer

























                            up vote
                            1
                            down vote













                            You can get process info using:



                            $ ps -f --pid $(xprop _NET_WM_PID | grep -o '[0-9]*')





                            share|improve this answer























                              up vote
                              1
                              down vote










                              up vote
                              1
                              down vote









                              You can get process info using:



                              $ ps -f --pid $(xprop _NET_WM_PID | grep -o '[0-9]*')





                              share|improve this answer












                              You can get process info using:



                              $ ps -f --pid $(xprop _NET_WM_PID | grep -o '[0-9]*')






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Apr 8 '15 at 8:33









                              Wernight

                              88588




                              88588






















                                  up vote
                                  0
                                  down vote













                                  Running xprop | awk '/_NET_WM_PID(CARDINAL)/{print $NF}' and clicking the window you want the PID of will print the PID to the terminal.






                                  share|improve this answer

























                                    up vote
                                    0
                                    down vote













                                    Running xprop | awk '/_NET_WM_PID(CARDINAL)/{print $NF}' and clicking the window you want the PID of will print the PID to the terminal.






                                    share|improve this answer























                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      Running xprop | awk '/_NET_WM_PID(CARDINAL)/{print $NF}' and clicking the window you want the PID of will print the PID to the terminal.






                                      share|improve this answer












                                      Running xprop | awk '/_NET_WM_PID(CARDINAL)/{print $NF}' and clicking the window you want the PID of will print the PID to the terminal.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered May 16 '12 at 15:04









                                      ScottKu

                                      22617




                                      22617






























                                           

                                          draft saved


                                          draft discarded



















































                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f137875%2ftell-a-process-pid-by-its-window%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Mouse cursor on multiple screens with different PPI

                                          Agildo Ribeiro

                                          Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”