Terminal command for quitting applications?

Discussion in 'Mac Basics and Help' started by RedCroissant, Feb 10, 2013.

  1. macrumors 68020

    RedCroissant

    Joined:
    Aug 13, 2011
    Location:
    California
    #1
    Sorry if this has been posted elsewhere(I did a search and could not find this specific question). I like learning terminal and using the command line interface. I can open applications and quit them as well by running "top," finding the specific PID, and then typing "kill [PID]." But I don't like running top to find the particular Process ID of the app I would like to quit.

    Is there another command that can be performed in fewer steps? Thanks in advance.
     
  2. simsaladimbamba

    Joined:
    Nov 28, 2010
    Location:
    located
    #2
    Try
    Code:
    killall Safari
    or
    Code:
    killall iTunes
     
  3. macrumors 603

    Joined:
    Aug 9, 2009
    #3
    Code:
    man killall
    
    And you've also learned the 'man' command.

    EDIT
    And I haven't learned to stop editing and hit Submit to get in before simsaladimbamba.
     
  4. thread starter macrumors 68020

    RedCroissant

    Joined:
    Aug 13, 2011
    Location:
    California
    #4
    Hey Chown, I've already learned that lesson today. He even only beat me by a few seconds.

    Thank you both! I'm enjoying diving into Mac OS X as of late and having a lot of fun doing it.

    It's just seems weird that "quit" isn't an accepted command.
     
  5. simsaladimbamba

    Joined:
    Nov 28, 2010
    Location:
    located
    #5
    But your reply is more helpful due to the manual command, if the OP does not know it yet.

    And to be honest, I just tried the killall command the first time, which I have only learned from the Show / Hide Hidden Files in Finder tutorial. It was just a lucky guess, which I tested first of course before giving it away. It is a nice command if Force Quit using both methods does not work and Terminal is still launchable.
     
  6. macrumors 603

    Joined:
    Oct 14, 2008
    #6
    But typing 'killall' is just so much more fun! :)
     
  7. macrumors 603

    Joined:
    Aug 9, 2009
    #7
    See:
    Code:
    man alias
    
    That will probably lead you to read 'man bash' and search for the builtin 'alias' cmd. At that point you will likely run into a problem with 'man': no easy searchability. To address that, I suggest the online man pages:
    https://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/index.html

    Then, to have the alias automatically defined each time you start Terminal.app, add it to your user-account's bash profile file (search the online bash man page for profile).
     
  8. dyn
    macrumors 68000

    Joined:
    Aug 8, 2009
    Location:
    .nl
    #8
    The killall command should only be used if there is no other way in quitting the application. There are quite a few where hitting q will quit them. Some require something like ctrl-q, ctrl-c (some apps treat this as control-break, some simply as quit), F10 or something else. It is always good to check this beforehand and the "man" command is very useful for this.
     
  9. macrumors 6502a

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #9
    I agree, indiscriminate use of the 'killall' command could result in corrupted data in some applications. It's not the same as using the "Quit" menu option. What problem are you really trying to solve here? Or are you just trying to be cute with the Terminal?

    A better way might be to write some Applescript which asks an app to terminate. That would better than killall.
     
  10. macrumors 603

    Joined:
    Aug 9, 2009
    #10
    There's also a Terminal command that can run AppleScript. It's called 'osascript', and it has a man page.

    Because AppleScript uses " to identify apps by name, one may also need a working knowledge of bash quoting: e.g. single-quote (') vs. double-quote ("), backslash to escape a " between "s.
     
  11. thread starter macrumors 68020

    RedCroissant

    Joined:
    Aug 13, 2011
    Location:
    California
    #11
    Well, I'm not just trying to be cute with Terminal. I want to learn as much as I can and try relying more on the Terminal to use my computer. I'm enjoying using the CLI to empty trash, open apps, send email, open/duplicate/move files around. That kind of thing. It's slow-going because I have a lot of other things on my plate, but it's fun getting to know it.
     

Share This Page