How can I safely shutdown/reboot/logout KDE from the command line?












21















I am not talking about shutdown and reboot commands. I want to initiate the same routine from command line that would be performed if I would press the logout/reboot/shutdown button inside the KDE desktop.










share|improve this question

























  • I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :)

    – myusuf3
    Aug 10 '10 at 18:51











  • I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout

    – txwikinger
    Aug 10 '10 at 20:39
















21















I am not talking about shutdown and reboot commands. I want to initiate the same routine from command line that would be performed if I would press the logout/reboot/shutdown button inside the KDE desktop.










share|improve this question

























  • I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :)

    – myusuf3
    Aug 10 '10 at 18:51











  • I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout

    – txwikinger
    Aug 10 '10 at 20:39














21












21








21


7






I am not talking about shutdown and reboot commands. I want to initiate the same routine from command line that would be performed if I would press the logout/reboot/shutdown button inside the KDE desktop.










share|improve this question
















I am not talking about shutdown and reboot commands. I want to initiate the same routine from command line that would be performed if I would press the logout/reboot/shutdown button inside the KDE desktop.







kde command-line shutdown reboot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 18 '10 at 0:57









Marco Ceppi

37.1k24154192




37.1k24154192










asked Aug 10 '10 at 18:48









txwikingertxwikinger

19.4k106593




19.4k106593













  • I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :)

    – myusuf3
    Aug 10 '10 at 18:51











  • I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout

    – txwikinger
    Aug 10 '10 at 20:39



















  • I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :)

    – myusuf3
    Aug 10 '10 at 18:51











  • I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout

    – txwikinger
    Aug 10 '10 at 20:39

















I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :)

– myusuf3
Aug 10 '10 at 18:51





I dont know if you could do that. one of the commands would eventually close the terminal your using to interact with it. Maybe more ideas on why you need to do this? :)

– myusuf3
Aug 10 '10 at 18:51













I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout

– txwikinger
Aug 10 '10 at 20:39





I need to do this because plasma-desktop is acting up sometimes and I still want to keep the session information that is saved during logout

– txwikinger
Aug 10 '10 at 20:39










4 Answers
4






active

oldest

votes


















23














For kde4:



qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1


The three integer parameters are the confirm, sdtype and sdmode arguments to KWorkSpace::requestShutDown. Their values are explained at the top of the page.






share|improve this answer


























  • Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

    – user3099609
    Feb 10 '14 at 8:29



















3














For any version of KDE (maybe also GNOME and others):



In KDE Control Center (KDE3.5/trinity) you can set a keyboard shortcut for "halt without confirmation" (should be a complicated one to avoid tragedy, like Ctrl+Shift+Alt+Delete) and then run xvkbd (virtual keyboard):



xvkbd -text 'CSAd'


You can create an alias for this (e.g. kdehalt);



My favourite one: sleep 1h 20m && kdehalt or wget "http://something" ; kdehalt.






share|improve this answer

































    1














    So I tried the answer presented by Gilles, but that only works for KDE4.



    After a system-update with my graphics, I could no longer log out, reboot, or shutdown. Eventually found this command worked:



    qdbus org.kde.ksmserver /KSMServer logout 0 0 0


    My source is from here, where they discuss it a bit more. I'm not sure about he other optoins. Forum topic discussion KDE5 shutdown options. The above command seems to have shutdown my system gracefully. All my programs came back that were expected, in the right layout order, and I did not seem to be missing anything. If this doesn't work, please comment and I will adjust my answer but so far this is all that has worked for a graceful KDE5 shutdown when my is locked. (I obviously could have used the shutdown command or called init, but those aren't graceful.)






    share|improve this answer








    New contributor




    C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




























      0














      I usually use init command for restart and ... .
      I like this command



      # Default run level. The run levels are:
      # 0 - halt (Do NOT set initdefault to this)
      # 1 - Single user mode
      # 2 - Multiuser, without NFS
      # (The same as 3, if you do not have networking)
      # 3 - Full multiuser mode
      # 4 - unused
      # 5 - X11
      # 6 - reboot (Do NOT set initdefault to this)


      sjb@sjb-laptop~$ init 6





      share|improve this answer



















      • 4





        This does not shutdown the desktop gracefully

        – txwikinger
        Aug 10 '10 at 20:40











      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',
      autoActivateHeartbeat: false,
      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%2f1871%2fhow-can-i-safely-shutdown-reboot-logout-kde-from-the-command-line%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      23














      For kde4:



      qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1


      The three integer parameters are the confirm, sdtype and sdmode arguments to KWorkSpace::requestShutDown. Their values are explained at the top of the page.






      share|improve this answer


























      • Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

        – user3099609
        Feb 10 '14 at 8:29
















      23














      For kde4:



      qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1


      The three integer parameters are the confirm, sdtype and sdmode arguments to KWorkSpace::requestShutDown. Their values are explained at the top of the page.






      share|improve this answer


























      • Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

        – user3099609
        Feb 10 '14 at 8:29














      23












      23








      23







      For kde4:



      qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1


      The three integer parameters are the confirm, sdtype and sdmode arguments to KWorkSpace::requestShutDown. Their values are explained at the top of the page.






      share|improve this answer















      For kde4:



      qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1


      The three integer parameters are the confirm, sdtype and sdmode arguments to KWorkSpace::requestShutDown. Their values are explained at the top of the page.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 16 '17 at 19:33









      Oleh Prypin

      1,98821829




      1,98821829










      answered Aug 10 '10 at 19:51









      GillesGilles

      45.2k13102141




      45.2k13102141













      • Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

        – user3099609
        Feb 10 '14 at 8:29



















      • Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

        – user3099609
        Feb 10 '14 at 8:29

















      Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

      – user3099609
      Feb 10 '14 at 8:29





      Gilles' answer helped me as well. Just a small note there: it doesn't work from su. In my case this was part of a command issued using sudo. In that case it doesn't work. Complains Cannot find 'org.kde.KSMServerInterface.logout' in object /KSMServer at org.kde.ksmserver. However works very well when run with the regular user ^_^

      – user3099609
      Feb 10 '14 at 8:29













      3














      For any version of KDE (maybe also GNOME and others):



      In KDE Control Center (KDE3.5/trinity) you can set a keyboard shortcut for "halt without confirmation" (should be a complicated one to avoid tragedy, like Ctrl+Shift+Alt+Delete) and then run xvkbd (virtual keyboard):



      xvkbd -text 'CSAd'


      You can create an alias for this (e.g. kdehalt);



      My favourite one: sleep 1h 20m && kdehalt or wget "http://something" ; kdehalt.






      share|improve this answer






























        3














        For any version of KDE (maybe also GNOME and others):



        In KDE Control Center (KDE3.5/trinity) you can set a keyboard shortcut for "halt without confirmation" (should be a complicated one to avoid tragedy, like Ctrl+Shift+Alt+Delete) and then run xvkbd (virtual keyboard):



        xvkbd -text 'CSAd'


        You can create an alias for this (e.g. kdehalt);



        My favourite one: sleep 1h 20m && kdehalt or wget "http://something" ; kdehalt.






        share|improve this answer




























          3












          3








          3







          For any version of KDE (maybe also GNOME and others):



          In KDE Control Center (KDE3.5/trinity) you can set a keyboard shortcut for "halt without confirmation" (should be a complicated one to avoid tragedy, like Ctrl+Shift+Alt+Delete) and then run xvkbd (virtual keyboard):



          xvkbd -text 'CSAd'


          You can create an alias for this (e.g. kdehalt);



          My favourite one: sleep 1h 20m && kdehalt or wget "http://something" ; kdehalt.






          share|improve this answer















          For any version of KDE (maybe also GNOME and others):



          In KDE Control Center (KDE3.5/trinity) you can set a keyboard shortcut for "halt without confirmation" (should be a complicated one to avoid tragedy, like Ctrl+Shift+Alt+Delete) and then run xvkbd (virtual keyboard):



          xvkbd -text 'CSAd'


          You can create an alias for this (e.g. kdehalt);



          My favourite one: sleep 1h 20m && kdehalt or wget "http://something" ; kdehalt.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 2 '15 at 6:16









          kos

          25.8k871121




          25.8k871121










          answered Oct 24 '11 at 22:56









          Zdeněk VálekZdeněk Válek

          311




          311























              1














              So I tried the answer presented by Gilles, but that only works for KDE4.



              After a system-update with my graphics, I could no longer log out, reboot, or shutdown. Eventually found this command worked:



              qdbus org.kde.ksmserver /KSMServer logout 0 0 0


              My source is from here, where they discuss it a bit more. I'm not sure about he other optoins. Forum topic discussion KDE5 shutdown options. The above command seems to have shutdown my system gracefully. All my programs came back that were expected, in the right layout order, and I did not seem to be missing anything. If this doesn't work, please comment and I will adjust my answer but so far this is all that has worked for a graceful KDE5 shutdown when my is locked. (I obviously could have used the shutdown command or called init, but those aren't graceful.)






              share|improve this answer








              New contributor




              C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

























                1














                So I tried the answer presented by Gilles, but that only works for KDE4.



                After a system-update with my graphics, I could no longer log out, reboot, or shutdown. Eventually found this command worked:



                qdbus org.kde.ksmserver /KSMServer logout 0 0 0


                My source is from here, where they discuss it a bit more. I'm not sure about he other optoins. Forum topic discussion KDE5 shutdown options. The above command seems to have shutdown my system gracefully. All my programs came back that were expected, in the right layout order, and I did not seem to be missing anything. If this doesn't work, please comment and I will adjust my answer but so far this is all that has worked for a graceful KDE5 shutdown when my is locked. (I obviously could have used the shutdown command or called init, but those aren't graceful.)






                share|improve this answer








                New contributor




                C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.























                  1












                  1








                  1







                  So I tried the answer presented by Gilles, but that only works for KDE4.



                  After a system-update with my graphics, I could no longer log out, reboot, or shutdown. Eventually found this command worked:



                  qdbus org.kde.ksmserver /KSMServer logout 0 0 0


                  My source is from here, where they discuss it a bit more. I'm not sure about he other optoins. Forum topic discussion KDE5 shutdown options. The above command seems to have shutdown my system gracefully. All my programs came back that were expected, in the right layout order, and I did not seem to be missing anything. If this doesn't work, please comment and I will adjust my answer but so far this is all that has worked for a graceful KDE5 shutdown when my is locked. (I obviously could have used the shutdown command or called init, but those aren't graceful.)






                  share|improve this answer








                  New contributor




                  C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  So I tried the answer presented by Gilles, but that only works for KDE4.



                  After a system-update with my graphics, I could no longer log out, reboot, or shutdown. Eventually found this command worked:



                  qdbus org.kde.ksmserver /KSMServer logout 0 0 0


                  My source is from here, where they discuss it a bit more. I'm not sure about he other optoins. Forum topic discussion KDE5 shutdown options. The above command seems to have shutdown my system gracefully. All my programs came back that were expected, in the right layout order, and I did not seem to be missing anything. If this doesn't work, please comment and I will adjust my answer but so far this is all that has worked for a graceful KDE5 shutdown when my is locked. (I obviously could have used the shutdown command or called init, but those aren't graceful.)







                  share|improve this answer








                  New contributor




                  C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 3 hours ago









                  C.D.C.D.

                  111




                  111




                  New contributor




                  C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  C.D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.























                      0














                      I usually use init command for restart and ... .
                      I like this command



                      # Default run level. The run levels are:
                      # 0 - halt (Do NOT set initdefault to this)
                      # 1 - Single user mode
                      # 2 - Multiuser, without NFS
                      # (The same as 3, if you do not have networking)
                      # 3 - Full multiuser mode
                      # 4 - unused
                      # 5 - X11
                      # 6 - reboot (Do NOT set initdefault to this)


                      sjb@sjb-laptop~$ init 6





                      share|improve this answer



















                      • 4





                        This does not shutdown the desktop gracefully

                        – txwikinger
                        Aug 10 '10 at 20:40
















                      0














                      I usually use init command for restart and ... .
                      I like this command



                      # Default run level. The run levels are:
                      # 0 - halt (Do NOT set initdefault to this)
                      # 1 - Single user mode
                      # 2 - Multiuser, without NFS
                      # (The same as 3, if you do not have networking)
                      # 3 - Full multiuser mode
                      # 4 - unused
                      # 5 - X11
                      # 6 - reboot (Do NOT set initdefault to this)


                      sjb@sjb-laptop~$ init 6





                      share|improve this answer



















                      • 4





                        This does not shutdown the desktop gracefully

                        – txwikinger
                        Aug 10 '10 at 20:40














                      0












                      0








                      0







                      I usually use init command for restart and ... .
                      I like this command



                      # Default run level. The run levels are:
                      # 0 - halt (Do NOT set initdefault to this)
                      # 1 - Single user mode
                      # 2 - Multiuser, without NFS
                      # (The same as 3, if you do not have networking)
                      # 3 - Full multiuser mode
                      # 4 - unused
                      # 5 - X11
                      # 6 - reboot (Do NOT set initdefault to this)


                      sjb@sjb-laptop~$ init 6





                      share|improve this answer













                      I usually use init command for restart and ... .
                      I like this command



                      # Default run level. The run levels are:
                      # 0 - halt (Do NOT set initdefault to this)
                      # 1 - Single user mode
                      # 2 - Multiuser, without NFS
                      # (The same as 3, if you do not have networking)
                      # 3 - Full multiuser mode
                      # 4 - unused
                      # 5 - X11
                      # 6 - reboot (Do NOT set initdefault to this)


                      sjb@sjb-laptop~$ init 6






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 10 '10 at 20:01









                      Sajad BahmaniSajad Bahmani

                      822922




                      822922








                      • 4





                        This does not shutdown the desktop gracefully

                        – txwikinger
                        Aug 10 '10 at 20:40














                      • 4





                        This does not shutdown the desktop gracefully

                        – txwikinger
                        Aug 10 '10 at 20:40








                      4




                      4





                      This does not shutdown the desktop gracefully

                      – txwikinger
                      Aug 10 '10 at 20:40





                      This does not shutdown the desktop gracefully

                      – txwikinger
                      Aug 10 '10 at 20:40


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1871%2fhow-can-i-safely-shutdown-reboot-logout-kde-from-the-command-line%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

                      GameSpot

                      connect to host localhost port 22: Connection refused

                      Getting a Wifi WPA2 wifi connection