DEV Community

Sh Raj
Sh Raj

Posted on

Execute .dmg (Mac) and .exe (Windows) Files Using Terminal

How to Execute .dmg (Mac) and .exe (Windows) Files Using Terminal

In this guide, we'll explore how to execute .dmg files on macOS and .exe files on Windows using the terminal. While GUI (Graphical User Interface) installations are common, sometimes you might need to use the terminal for various reasons like automation or remote access.

Executing .dmg Files on macOS

.dmg files are disk image files commonly used for software distribution on macOS. Here's how you can mount and execute a .dmg file using the terminal:

  1. Open Terminal: You can find Terminal in the Applications > Utilities folder, or use Spotlight Search (Cmd + Space then type "Terminal").

  2. Navigate to the .dmg File: Use the cd command to navigate to the directory containing your .dmg file. For example, if your file is on the desktop:

   cd ~/Desktop
Enter fullscreen mode Exit fullscreen mode
  1. Mount the .dmg File: Use the hdiutil command to mount the disk image. Replace YourApp.dmg with the name of your .dmg file:
   hdiutil mount YourApp.dmg
Enter fullscreen mode Exit fullscreen mode

This command mounts the .dmg file as a disk volume.

  1. Install the Application: Once mounted, you can typically find the application icon in the new Finder window that appears. Drag the application to your Applications folder to install it.

  2. Eject the Disk Image: After installation, you can eject the disk image:

   hdiutil eject /Volumes/YourApp
Enter fullscreen mode Exit fullscreen mode

Replace YourApp with the name of the mounted volume.

Executing .exe Files on Windows

.exe files are executable files commonly used on Windows. Here's how you can execute an .exe file using the Command Prompt:

  1. Open Command Prompt: Press Win + R, type cmd, and press Enter to open the Command Prompt.

  2. Navigate to the Folder: Use the cd command to navigate to the directory containing your .exe file. For example, if your file is on the desktop:

   cd Desktop
Enter fullscreen mode Exit fullscreen mode
  1. Run the .exe File: Type the name of the .exe file to run it. For example:
   YourApp.exe
Enter fullscreen mode Exit fullscreen mode

Replace YourApp.exe with the name of your .exe file.

  1. Follow Installation Prompts: Depending on the application, you might see installation prompts. Follow the on-screen instructions to complete the installation.

That's it! You've successfully executed .dmg and .exe files using the terminal.

Top comments (0)