How to Open Applications Using Terminal on Mac

Download ArticleDownload Article

Your Mac's Terminal app gives you a Linux command line inside the OS X environment. You can use the Terminal to run applications or open files in the program of your choice. In this How.com.vn tutorial, you'll learn easy ways to launch applications from the Mac Terminal app, and how to troubleshoot and fix common Terminal troubles.

Part 1
Part 1 of 2:

Opening an Application

Download Article
  1. How.com.vn English: Step 1 Launch Terminal....
    Launch Terminal. Look for Terminal in ApplicationsUtilitiesTerminal. You can also open Terminal by using spotlight in the right hand top corner.[1]
  2. How.com.vn English: Step 2 Open an application from anywhere.
    The open command normally requires you to input the full file path from your current directory. However, adding -a followed by the name of an application instructs Terminal to open that Application, no matter where it is located. For example:[2]
    • To open iTunes:
      open -a iTunes
    • Use quotation marks if the application has a space in its name:
      open -a "App Store"
    Advertisement
  3. How.com.vn English: Step 3 Open a file with a specific application.
    You can also use this command to override the default application for a file type. Just type in the file path followed by -a and the application name. If you're not sure how to enter file paths, see the Troubleshooting section below.
    • For example, you can open a .doc file with TextEdit:
      open Downloads/Instructions.doc -a TextEdit
  4. How.com.vn English: Step 4 Include additional options.
    Enter info open to see a full list of options for modifying the open command. (When you are finished, press Control+C to return to the command line.) Here are a couple basic examples:[3]
    • Use -e to specify TextEdit, or -t to specify your default text editor:
      open Downloads/Instructions.doc -e
    • Add -g to keep the application in the background, so you remain centered in Terminal:
      open -g -a iTunes
  5. Step 5 Add -F to open a "fresh" copy of the application.
    This will destroy your unsaved changes, but may help if a document is causing the application to crash when opened:[4]
    • open -F -a TextEdit
  6. How.com.vn English: Step 6 Open multiple instances of the same application with -n.
    This may be useful if you are comparing different access levels, or if the application only allows one window. For example, enter this command repeatedly to open multiple instances of an alarm clock program:
    • open -n -a "Wake Up Time" (Note: this is not a default OS X program.)
    • This may cause unexpected behavior in other applications that interact with the duplicate application.
  7. How.com.vn English: Step 7 Run an application inside Terminal.
    Instead of just opening an application normally, Terminal can host it. This is useful for debugging, as error messages and other console outputs will appear in that Terminal window. Here's how to do this:
    • Locate the application in Finder.
    • Right-click the application and select "Show Package Contents."
    • Locate the executable file. Typically, this is in ContentsMacOS, and has the same name as the application.
    • Drag that file onto your blank Terminal command line. Hit Enter to launch that program.
    • Leave your Terminal window open while you use the application. Quit the application to return to regular Terminal operations.
  8. Advertisement
Part 2
Part 2 of 2:

Troubleshooting

Download Article
  1. How.com.vn English: Step 1 Find the application name.
    If Terminal displays the error message "Unable to find application named...," find the exact name of the application by browsing an alphabetical list:[5]
    • Click the apple symbol in the top left corner of your screen.
    • Hold down Option and click System Information in the drop-down menu.
    • In the System Information window's left sidebar, click SoftwareApplications. It may take a couple minutes to load the list.
  2. How.com.vn English: Step 2 Understand absolute file paths.
    If Terminal displays "the file ... does not exist," you did not type the correct file path. An easy way to avoid mistakes is to drag and drop the file from Finder directly into your Terminal command line (after typing "open," but before hitting Enter.) This will enter the absolute file path, which will always point to that file.[6]
    • An absolute file path always begins with the symbol /. It describes the file path in relation to the root directory (usually "Macintosh HD").
  3. How.com.vn English: Step 3 Understands relative file paths.
    The start of your Terminal command line always displays the current directory you are located in. By default, this is your Home directory, named after your username. A relative file path begins with ./ or with no special characters, and describes the file's location in relation to your current directory.[7] If you're having trouble figuring this out, follow these steps:
    • Enter pwd to check your current directory. The file you are trying to open must be within this directory, not at a higher level.
    • Find your current directory in Finder. Open a series of folder until you reach the file you'd like to open.
    • Type in the names of the folders you opened in order, separated by / symbols, then end with the file name. For example, open Documents/Writing/Novel/ch3.pdf. (You may start with ./ in front of Documents for the same result.)
  4. How.com.vn English: Step 4 Switch directories.
    You can return to your Home directory with cd ~/, or switch to a lower-level directory with cd followed by the folder name — for example, cd Documents/Finances. Remember, the file you are trying to open must be inside your current directory, but you may use any application to open it regardless of location.
  5. How.com.vn English: Step 5 Find the correct file name.
    Your file name must include the extension at the end of its name. If the extension is hidden, use any of these methods to find it:
    • Select the file in Finder. Press Command+I. In the Info window, look for "file name & extension" to see the whole name.
    • Or switch directories to the folder that contains the file. Enter ls into your Terminal command line to list all files in your directory.
    • Or drag and drop the file into your Terminal window.
  6. Advertisement

Community Q&A

Search
Add New Question
  • Question
    Why does Safari open automatically when I log into my laptop?
    How.com.vn English: Mariam Atbouli
    Mariam Atbouli
    Community Answer
    Try right-clicking Safari in your dock. Choose options > Open at Login. If there is a tick, uncheck it.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Video

      Tips

      • You can use * as a wildcard to represent any sequence of characters, or ? to represent any single character.[8] This works in file names, but not application names. For example, open budget* will open the first file in your directory that begins with "budget." open budget?.pdf would open "budget1.pdf" but would not open "budget2015.pdf," since the ? character only represents a single character.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      Warnings

      Advertisement

      About This Article

      How.com.vn English: How.com.vn Staff
      Co-authored by:
      How.com.vn Staff Writer
      This article was co-authored by How.com.vn Staff. Our trained team of editors and researchers validate articles for accuracy and comprehensiveness. How.com.vn's Content Management Team carefully monitors the work from our editorial staff to ensure that each article is backed by trusted research and meets our high quality standards. This article has been viewed 1,015,456 times.
      How helpful is this?
      Co-authors: 13
      Updated: March 16, 2024
      Views: 1,015,456
      Categories: Mac
      Article SummaryX

      1.Use "open -a appname" to launch an app.
      2.Use "open path/to/file -a appname" to open a file with an app.
      3.Add "-g" to keep the file in the background.
      4.Add "-F" to open a fresh copy of the app.
      5.Use "-n" to open multiple instances.

      Did this summary help you?

      Thanks to all authors for creating a page that has been read 1,015,456 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement