公司电脑是macOS,手动安装某些软件(*.dmg)时需要系统管理员输入用户名和密码,要看管理员脸色行事。作为电脑的使用者有sudo权限,那我们是不是可以有绕过的方法呢?答案是肯定的。

那我们就可以使用系统自带的hdituil命令来静默安装软件。

hdiutil 命令详解

NAME

hdiutil -- manipulate disk images (attach, verify, create, etc)

SYNOPSIS

hdiutil verb [options]

DESCRIPTION

hdiutil uses the DiskImages framework to manipulate disk images.  Common verbs include attach, detach, verify, create, convert, and compact.

The rest of the verbs are currently: help, info, burn, checksum, chpass, erasekeys, unflatten, flatten, imageinfo, isencrypted, mountvol, unmount, plugins, udifrez, udifderez, resize, segment, makehybrid, and

pmap.

BACKGROUND

Disk images are data containers that emulate disks.  Like disks, they can be partitioned and formatted.  Many common uses of disk images blur the distinction between the disk image container and its content,

but this distinction is critical to understanding how disk images work.  The terms "attach" and "detach" are used to distinguish the way disk images are connected to and disconnected from a system.  "Mount" and

"unmount" are the parallel filesystems options.

For example, when you double-click a disk image in the macOS Finder, two separate things happen.  First, the image is "attached" to the system just like an external drive.  Then, the kernel and Disk Arbitration

probe the new device for recognized file structures.  If any are discovered that should be mounted, the associated volumes will mount and appear on the desktop.

主要用到它的两个命令 hdituil attach, hdiutil detach.

attach image [options]

attach a disk image as a device.  attach will return information about an already-attached image as if it had attached it.  If any associated volumes are unmounted (and mounting is not suppressed),

they will be remounted.  mount is a poorly-named synonym for attach.  See BACKGROUND.

By default, the system applies additional mount options to filesystems backed by untrusted devices like disk images: options like nosuid and quarantine.  PERMISSIONS VS. OWNERS explains the behavior

of such filesystems and EXAMPLES shows how to override some of the default behavior.

The output of attach has been stable since Mac OS X 10.0 (though it was called hdid(8) then) and is intended to be program-readable.  It consists of the /dev node, a tab, a content hint (if applica-

ble), another tab, and a mount point (if any filesystems were mounted).  Because content hints are derived from the partition data, GUID Partition Table types may leak through.  Common GUIDs such as

"48465300-0000-11AA-AA11-0030654" are mapped to their human-readable counterparts (here "Apple_HFS").

detach dev_name [-force]

detach a disk image and terminate any associated process.  dev_name is a partial /dev node path (e.g. "disk1").  As of Mac OS X 10.4, dev_name can also be a mountpoint.  If Disk Arbitration is run-

ning, detach will use it to unmount any filesystems and detach the image.  If not, detach will attempt to unmount any filesystems and detach the image directly (using the `eject' ioctl).  If Disk

Arbitration is not running, it may be necessary to unmount the filesystems with umount(8) before detaching the image.  eject is a synonym for detach.  In common operation, detach is very similar to

diskutil(8)'s eject.

安装dmg文件的脚本

#/bin/bash

VOLUME=`hdiutil attach $1 | grep -o "/Volumes.*$"`

echo "app directory: $VOLUME"

APP_NAME=`ls "$VOLUME" | grep .app`

echo "app name: $APP_NAME"

cp -rf "$VOLUME/$APP_NAME" /Applications/"$APP_NAME"

xattr -c /Applications/"$APP_NAME"

hdiutil detach "$VOLUME"

echo "$APP_NAME install completed!"

~

xattr -c *.app 是删除所有扩展属性,解决问题“App can’t be opened because it is from an unidentified developer”。

详情参考:“App can’t be opened because it is from an unidentified developer” 的解决之道?_走向自由的博客-CSDN博客

安装示例

./install_app.sh Docker.dmg

参考:

https://www.jianshu.com/p/1734fecdf51e

macOs 静默安装dmg文件相关推荐

  1. NSIS检测已安装并卸载旧版本和静默安装.msu文件

    NSIS检测已安装并卸载旧版本: Function .onInit    !insertmacro TIP_WHEN_AMD64_INSTALLER_RUNAT_X86    ;安装到所有用户下,cu ...

  2. Mac 命令行安装 dmg文件

    1.安装dmg文件 hdiutil attach jdk-9.0.1_osx-x64_bin.dmg 会挂载在 /Volumes 目录下 2.安装pkg文件(可以 man installer 查看命令 ...

  3. Oracle11.2.0.4静默安装响应文件db_install.rsp

    Oracle11.2.0.4静默安装响应文件 如果用11.2.0.1的响应文件去安装就会需要oracle MOS账号,因为11.2.0.4原则上来说是要收费的.但是我发现了跳过检测的方法,现在就把安装 ...

  4. linuxoracle静默安装应答文件修改_Oracle 19c的examples静默安装

    Oracle 11g的examples示例schema安装,在这篇文章<Oracle 11g的examples静默安装>介绍过了,Oracle 19c的examples示例schema安装 ...

  5. linuxoracle静默安装应答文件修改_Windows7重要更新补丁安装包 2020.01.17

    2020年1月14日微软官方宣布正式停止支持Windows 7(以下简称Win7),除付费政企用户外,不再提供安全补丁或者更新服务.那么以后win7的更新要怎么办?难道只能"裸奔" ...

  6. linuxoracle静默安装应答文件修改_巧用组策略分发软件—让IT不再手忙脚乱地奔走在各个工位安装软件...

    8月29日发的微头条,访问量达到了40万+,同日发表的图文,推荐量6700,访问量才320:8月30日发的微头条,访问量目前也已经超出了25万,同日发表的图文,推荐量5000,访问量才148:搞不清楚 ...

  7. linuxoracle静默安装应答文件修改_Linux7静默安装Oracle11g教程,亲测实用有效!

    1.查看swap大小,若小于150M,需添加增加虚拟空间 dd if=/dev/zero of=/swapadd bs=1024 count=2006424 mkswap /swapadd swapo ...

  8. 使用Terminal 安装dmg文件

    step1:cd ~/desktop (xxx.dmg已下载并拖至desktop) step2: 安装光盘镜像文件(dmg),一般会自动装载到/Volumes下 step3:切到Volumes文件下 ...

  9. Centos6/7下静默安装oracle10g

    Centos6/7下静默安装Oracle10g 远程安装oracle10g,通过网上资料,不断摸索成功安装.先在本地虚拟机Centos7上做实验,快照恢复快照恢复,安装了几十次成功之后,再在服务器Ce ...

  10. Centos 7 64位 minimal 最小化安装的系统中静默安装oracle 11g r2(无图形化安装)

    一 安装运行环境(操作系统环境) 1,最小化安装 linux CentOS7 我使用的镜像包:CentOS-7-x86_64-Minimal-1708.iso 操作系统安装步骤:https://blo ...

最新文章

  1. ExtJS 的工具条及菜单
  2. 查看安卓模拟器 CPU版本
  3. 傅里叶变换的初级理解二
  4. 2020-10-29
  5. 什么是死锁(deadlock)?
  6. php numeric乘法,PHP is_numeric()用法及代码示例
  7. Java的ATM界面任务台选择同时有文本和数据库登陆注册
  8. java中的银行界面开发_ATM机银行项目java图形界面
  9. pdf pmp书籍第六版_PMP项目管理 第六版 (带目录完整高清版).pdf
  10. python3中字符编码转换
  11. PBFT(一):过程
  12. virtualBox实现windows和Ubuntu之间的复制粘贴
  13. Redis高级项目实战,西安java程序员工资
  14. anaconda使用arcpy库
  15. 奥塔在线:CentOS7下配置Nginx实现本地缓存
  16. OpenCV-判断OpenCV摄像头是否断开
  17. HTML网页制作代码——简约的旅游图文相册博客HTML模板(12页)HTML+CSS+JavaScript 静态HTML旅行主题网页作业
  18. 《大话存储》——1. 磁盘控制器、驱动器控制电路和磁盘控制器驱动程序
  19. 电脑回收站清空了如何找回原来的文件
  20. 美《外交政策》:世界5大黑帮现状

热门文章

  1. docker入门小结
  2. 北京专科计算机学校排名及分数线,北京专科大学排名及分数线
  3. 林大计算机科学考研分数线,2018年北京林业大学考研复试分数线已公布
  4. 漂白水增稠剂看似木讷,其实在专注于分析罢了
  5. 2021年高光谱图像文献追踪_ISPRS_V.180_10
  6. 启用共享文件夹服务器,Windows Server 2008 启用公共文件夹共享
  7. Redux Reducer
  8. VSCode 中常用的 PHP 编程插件
  9. IDEA 中定义自己的TODO 并设置快捷键
  10. 科技云报道:率先迈入“10微秒”时代,腾讯云存储跑出加速度