Can I install or update Mac App Store apps through a command line using terminal? [duplicate]

Solution 1:

Note: This will only work on machines with an OS prior to macOS 10.7

There is a commandline app called softwareupdate that you have to run as root.

sudo softwareupdate --list for example will give you the list of apps that are set to update. You can then run sudo softwareupdate --install {app-name}

This won't let you install a new application that you haven't already downloaded though.

Solution 2:

Until recently, the answer was no but there are open source efforts to replicate the Mac App Store in a command-line based tool:

  • https://github.com/mas-cli/mas

To install:

brew install mas 

Once it's in, you could update all the apps that are available with:

mas upgrade

If you don't like this tool, you could also use MDM tools to package an already downloaded application and distribute it internally. Examples are Casper Suite, sftp, rsync, etc... and side load these apps. You do need to use the GUI or the mas tool to get the first copy of the application, however. So, if you already have the app, you can file share it over, but you can't get the App updated or installed solely from the terminal.

In a nutshell - you would set up an MDM server (there are now open source options) like:

  • https://github.com/project-imas/mdm-server

Then you would make your own App Store app that's amenable to command line updates. For that munki is a nice open-source choice:

  • https://www.munki.org

From there you could package the app updates and server them side loaded or use the InstallApplication MDM command to trigger an app install or update. Do note, that if you are pulling the app or the update from Apple's servers - you still need the user to enter their Apple ID and password in the prompt that OS X provides for the update. This does bypass opening the App Store app so it's a partial win, I suppose.

  • http://enterprisemac.bruienne.com/2015/11/17/installing-os-x-pkgs-using-an-mdm-service/

At present, the command line can only list software updates that come through the App Store the same as the previous Software Update server was used to download system updates and updates to apps that came on physical media. Terminal is not able to update apps that were bought electronically through the Mac App Store. Only some Apple apps are included in the updates using the softwareupdate command.