Mac

Mac OS使用与问题解决

admin
2025-09-15 / 0 评论 / 23 阅读 / 正在检测是否收录...


一:打开软件提示“xxx-已损坏无法打开”的解决方案

1、信任任何来源
sudo spctl --master-disable
在设置---隐私---选择:任何来源


2、使用xattr
sudo xattr -cr /Applications/xxxx.app 软件所在位置
可以把应用程序拖进终端



二:关闭SIP保护系统

查看SIP:
查看:csrutil status 状态


已打开:
System Integrity Protection status: enabled


已关闭:
System Integrity Protection status: disabled


关闭SIP:
1 重启 开机一直按住Command+R迸入Recovery模式
2 进入Recovery模式后打开终端
3 输入命令 csrutil disable 然后回车
4 点击屏幕最左上角苹果图标,再点击重新启动完毕
5 苹果M系列 按住开机键不放松知道出现恢复选项



三:mac os 清除dns缓存

sudo killall -HUP mDNSResponder
sudo killall mDNSResponderHelper
sudo dscacheutil -flushcache


修复网络dns
测试:nslookup www.baidu.com ping www.baidu.com
硬盘找到 资源库/Preferences/SystemConfiguration 保留 com.apple.Boot.plist 文件 其他文件全部删除
重启电脑



四:本地利用http代理

本地需要有代理并打开代理1087端口

export https_proxy=http://127.0.0.1:1087 http_proxy=http://127.0.0.1:1087 all_proxy=socks5://127.0.0.1:1080




五:添加路由

添加基于接口的路由
sudo route add -host 1.1.1.1 -iface lo0
sudo route add -net 1.1.1.0/24 -iface lo0


添加基于网关IP的路由
sudo route add -net 1.1.1.0/24 192.168.1.1
sudo route add -host 1.1.1.1 192.168.1.1
注意: macOS 中添加基于网关 IP 的路由系统不会检查网关 IP 合法性 , 需要提前检查.


删除静态路由
sudo route delete 1.1.1.0/24
sudo route delete 1.1.1.1


查看路由表
netstat -nr



六:macOS重新安装系统

你的电脑必须能接入互联网,才能重新安装 macOS


在搭载 Apple 芯片的 Mac 上:选取苹果菜单 >“关机”,按住电源按钮直至“正在载入启动选项”出现,选择“选项”,点按“继续”,然后按照屏幕指示进行操作。


在搭载 Intel 芯片的 Mac 上:选取苹果菜单 >“重新启动”,然后立即按住以下其中一个组合键(视你想执行的操作而定):


安装与你电脑兼容的 macOS 最新版本:Option-Command-R
重新安装你电脑原始版本的 macOS(包括可用的更新):Shift-Option-Command-R
重新安装当前版本的 macOS:Command-R


在“恢复” App 窗口中,针对你的 macOS 版本选择“重新安装”,然后点按“继续”
请按照屏幕指示进行操作
在你选择宗卷的设置中,选择你当前的 macOS 宗卷(大多数情况下,它是唯一可用的宗卷)



七:macOS安装软件

Homebrew是一款Mac OS平台下的软件包管理工具类似 yum apt,拥有安装、卸载、更新、查看、搜索等很多功能

普通用户安装
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
被强的话 
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 

使用Homebrew安装软件
brew install telnet wget
brew install netcat (nc)



八:MacOS下禁止开机自动挂载分区 [/etc/fstab]

首先查UUID 命令 : diskutil list 显示当前所有磁盘


例如win10安装盘name为“系统”,在disk0s3磁盘
执行命令:diskutil info disk0s3 查询UUID
如:Volume UUID: 3B87FF76-C6DA-49BF-B911-61DE2331E9F5 这一行就是我们要的UUID (注意一定要是:Volume UUID)
也可以直接用mac磁盘工具直接找到要操作的卷,看简介


禁止开机自动挂载
UUID=3B87FF76-C6DA-49BF-B911-61DE2331E9F5 none ntfs noauto 0 0
挂载点 格式 不自动 不备份 不检查
Mac支持的文件系统如:apfs,ntfs,vfat等


写入到系统,下次开机将不自动挂载:
sudo echo "UUID=3B87FF76-C6DA-49BF-B911-61DE2331E9F5 none ntfs noauto 0 0" >> /etc/fstab
输入密码 查询确认 cat /etc/fstab


或者方法二(新系统):
输入:sudo vifs并键入密码后,按一下键盘上的 “a”,用键盘上下键调整输入位置到最后一排
UUID=磁盘UUID none ntfs noauto 0 0
举一反三 : 开机需要自动挂载也可以这样做



九:打造 Mac 下高颜值好用的终端环境

1,安装Iterm2 (mac os 的一种终端工具 与自带的(Terminal)一样)
官网下载:https://www.iterm2.com/
打开iterm2
查看系统下有哪些shell可用/安装
cat /etc/shells
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
常用的 sh/bash 是 Shell 的一种,也是 Linux 下的默认 Shell 程序
zsh 重新定义一个更强大,更人性化的 Shell ,zsh它于bash相似功能又有所加强


2,安装必要软件
brew install wget
修改默认的bash为zsh(可选 因为安装oh-my-zsh的时候也会提示更改默认shell为zsh)
一般linux系统都会默认安装zsh 如果没有安装 可用 brew install zsh
(这里要注意的是,如果后期需要做一些命令别名,环境变量的时候,就不再是以前的bashrc等了,应是~/.zshrc或者/etc/zshrc)
chsh -s /bin/zsh 改变默认bash为zsh


重新打开终端
echo $SHELL 查看默认shell
/bin/zsh
如果你想要修改回来 chsh -s /bin/bash


3,安装oh-my-zsh
通常zsh配置起来非常麻烦且相当的复杂
oh-my-zsh是为了简化zsh的配置而开发的,因此oh-my-zsh算是zsh的配置工具
安装方式:
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
或者
sh -c "$(wget -O- http://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
重启iterm2


卸载oh-my-zsh
cd ~/.oh-my-zsh/tools
chmod +x uninstall.sh
./uninstall.sh


4,iterm2进行配置主题


方式一:自动配置 powerlevel10k主题
可能需要代理(可选)
export https_proxy=http://127.0.0.1:1087 http_proxy=http://127.0.0.1:1087 all_proxy=socks5://127.0.0.1:1080


git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
vi ~/.zshrc
设置如下内容 使用p10k主题 ZSH_THEME="powerlevel10k/powerlevel10k"
重启 q;
重启iterm2


正常会出现配置界面,如果没有自动出现配置界面
则执行 p10k configure
配置:安装字体 配色 主题 一体化 需要翻墙
配置过程略


安装语法高亮插件和自动补全插件:
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
复制
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/.zshrc 在插件配置处添加下载的这两个插件名
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
)


方式二:手动配置agnoster主题
通过vi ~/.zshrc,设置ZSH_THEME="agnoster"对主题进行修改
也可以打开 https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 更为直观的查看所有的配色方案


安装字体 PowerFonts
有些主题是会设置图标的,我们电脑上的字体一般都不支持这些图标,会出现乱码
git clone https://github.com/powerline/fonts.git --depth=1 前提是安装了git
cd fonts && ./install.sh
通过以下操作路径设置Iterm2 字体
菜单栏 -> Profiles -> Open Profiles -> Edit Profiles -> 选择 Text
Font和ASCII Font可以选择 Meslo LG L for 这个字体, 大小 14 乱码的图标就正常了


配色方案 (可选 主题通常都带默认的配色)
http://www.siguoya.name/pc/home/article/256
git clone git://github.com/altercation/solarized.git
Profiles——colors——Load Presets——Solarized Dark即可设置终端配色


声明高亮
brew install zsh-syntax-highlighting
安装成功之后,编辑vim ~/.zshrc文件,在最后一行增加下面配置:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh


自动填充
这个功能是非常实用的,可以方便我们快速的敲命令
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
然后编辑vim ~/.zshrc文件,找到plugins配置,增加zsh-autosuggestions插件
plugins=(git zsh-autosuggestions)


上面声明高亮,如果配置不生效的话
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
然后编辑vim ~/.zshrc文件,找到plugins配置,增加zsh-autosuggestions插件
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)


5,问题解决
Insecure completion-dependent directories detected:
启动新的终端窗口时遇到较大的错误消息屏幕
该错误通常指出“检测到不安全的完成依赖目录”,并显示一系列 /usr/local/share/zsh/ 目录,其权限 zsh 认为不安全
更改指定目录的权限:
chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions



十:mac使用rz,sz进行文件传输

安装lrzsz : brew install lrzsz
下载iterm2-zmodem
执行
git clone https://github.com/aikuyun/iterm2-zmodem.git
cd iterm2-zmodem


克隆到本地,并赋值到对应文件中,并赋值权限
sudo cp ./iterm2-recv-zmodem.sh /usr/local/bin/
sudo cp ./iterm2-send-zmodem.sh /usr/local/bin/
sudo cd /usr/local/bin/
sudo chmod +x iterm2-* (一定要有执行权限)


进入iterm2配置项 profiles->default->editProfiles->Advanced中的Tirgger
triggers中增加以下两项:

Regular expression: \*\*B0100 
Action: Run Silent Coprocess 
Parameters: /usr/local/bin/iterm2-send-zmodem.sh 
Regular expression: \*\*B00000000000000 
Action: Run Silent Coprocess 
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh 

两个勾都打上,测试rz上传,sz下载


另外如果是服务器中使用rz上传,sz下载
直接安装:yum -y install lrzsz



十一:macOS软件使用与激活



Google 密码导入:
浏览器中输入---chrome://flags----搜 Password import----开启----重启浏览器


关闭Adobe 相关版权提示:
sudo rm /Library/Application\ Support/Adobe/AdobeGCClient/AdobeGCClient.app/Contents/MacOS/AdobeGCClient
ps启动后会重新创建


虚拟机软件激活
ParallelsDesktop
https://appstorrent.ru/61-parallels-desktop.html 脚本激活

0

评论 (0)

取消