11 Replies Latest reply: Mar 5, 2013 7:56 AM by Kidsnd274
Kidsnd274 Level 1 (30 points)

Is there a way to restart the Mac using Terminal to restart the computer without reopening windows when logging back in


I am currently stuck at here


shutdown -r -n now


not sure what even -n does. Do I need it?

MacBook Air, OS X Mountain Lion (10.8.2)
  • dominic23 Level 8 (37,632 points)

    Mountain Lion


    Disable Resume feature without using terminal


    System Preferences > General


    Uncheck  the checkbox next to  "Close windows when quitting an application".


    Is there any particular reason that you have to use terminal to restart the computer?



  • Barney-15E Level 8 (46,274 points)

    Where did you get that command?

    According to the man page, -n alone doesn't do anything.


    There is nothing in the shutdown command that will disable resume. You need to follow the instructions that dominic posted.

  • BobHarris Level 6 (17,634 points)

    -n is a VERY BAD IDEA!


         -n      If the -o is specified, prevent the file system cache from being

                 flushed by passing -n option to halt(8) or reboot(8).  This

                 option should probably not be used.


    Not flushing your file system cache can result in lost data.  The only thing that saved you is you did not have the -o option also specified.


    sudo shutdonw -r now


    sudo shutdown -h now


    are about the extent anyone should be doing, unless they are really Unix system admin aware.


    And since the Unix command line side of the house does not know anything about the GUI, shutdown will not change the GUI's re-launch and option previous apps and windows.

  • Kidsnd274 Level 1 (30 points)

    I am actually creating a writing a program to restart my computer into bootcamp

  • Kidsnd274 Level 1 (30 points)

    I found the -n command option by googling it. Luckily, there wasn't a -o thanks alot


    If not my computer will be in deep trouble

  • Barney-15E Level 8 (46,274 points)

    See this hint on using an Applescript to set the boot volume and then

    tell "System Events"


    end tell


    You'll need to read through the comments to find the option to boot Windows, and also a nice option to only switch the boot volume for this restart.


    It uses the do shell script to run the shell commands, so you could just wrap it all in a shell instead.

  • Kidsnd274 Level 1 (30 points)

    I know the command to boot into Windows, but what I don't like is only the fact that after it restarts my computer, and I go back to Mac, it reopens all my windows that I have left open when restarting the computer to Windows. But your command might just work. I will see how it goes

  • Barney-15E Level 8 (46,274 points)

    That is a setting in General System Preferences. Close windows when quitting an application.

  • Kidsnd274 Level 1 (30 points)

    Tried that, but however it still reopened the windows when I started the Mac OS again. Is there any command line or something like for example.


    tell "System Events"

         restart -nowindow

    end tell



    But does anyone happen to know if there is anything similar, or it is just not possible.

  • Barney-15E Level 8 (46,274 points)

    No, there is not.

  • Kidsnd274 Level 1 (30 points)

    That is sad for me