原因:mac默认只可读NTFS文件系统不支持写入
1.下载FUSE for macOS(FUSE for macOS是提供了底层读写扩展的接口)
https://github.com/osxfuse/osxfuse/releases
2.安装ntfs-3g
> brew install ntfs-3g
3.自定义挂载的目录
> mkdir -p /Users/xxx/mnt
4.插入USB 或 移动硬盘使用diskutil查看磁盘IDENTIFIER(一般是external扩展盘且type为Windows_NTFS)
> diskutil list
5.umount该只读ntfs盘后使用ntfs-3g重新挂载到自定义目录即可读写ntfs系统了
> sudo umount /dev/disk2s1
> sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Users/xxx/mnt -olocal -oallow_other -o auto_xattr
> open /Users/xxx/mnt
#给只读文件赋写权限
> sudo chmod +w /etc/pam.d/sudo
#第一行新增pam_tid.so
> sudo vim /etc/pam.d/sudo
# sudo: auth account password session
auth sufficient pam_tid.so
#重新恢复到只读
> sudo chmod -w /etc/pam.d/sudo
#新建终端窗口测试不用再输入密码会弹出指纹验证
> sudo ls -la
#新建命令切换到root
> vim ~/bin/root.sh
#!/bin/sh
currentpath="`pwd`"
echo $currentpath
#sudo -i
#sudo su
sudo -s -H
一般自启动文件为*.plist文件且在LaunchAgents目录
> open ~/Library/LaunchAgents/
(注意:在该目录下打开相应文件时必须用Xcode.app打开)
修改或新增Root下属性(不存在则新增):
Disabled Boolean YES
KeepAlive Boolean NO
# 若需要更新时提示是否连接入互联网注释即可
> sudo vim /etc/hosts
127.0.0.1 ocsp.apple.com
127.0.0.1 swscan.apple.com
127.0.0.1 swdist.apple.com
127.0.0.1 swcdn.apple.com
127.0.0.1 swquery.apple.com
127.0.0.1 swdownload.apple.com
# 消除已有红点提示(非root用户环境下)
> defaults write com.apple.systempreferences AttentionPrefBundleIDs 0 && Killall Dock
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost yourmac
255.255.255.255 broadcasthost
::1 localhost yourmac
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
127.0.0.1 xmind.net
127.0.0.1 www.xmind.net
127.0.0.1 license.sublimehq.com
127.0.0.1 www.sublimetext.com
127.0.0.1 localhost.charlesproxy.com
#tenant
127.0.0.1 bjdgg.tenant.com
127.0.0.1 bjdhj.tenant.com
# 禁止更新
127.0.0.1 updates.bravesoftware.com
127.0.0.1 go-updater.brave.com
127.0.0.1 update.googleapis.com
127.0.0.1 aus5.mozilla.org
127.0.0.1 boop.okat.best
# GitHub
151.101.193.194 github.global.ssl.fastly.net
140.82.113.3 github.com
140.82.113.3 gist.github.com
185.199.108.133 assets-cdn.github.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 gist.githubusercontent.com
185.199.108.133 cloud.githubusercontent.com
185.199.108.133 camo.githubusercontent.com
185.199.108.133 avatars0.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars3.githubusercontent.com
185.199.108.133 avatars4.githubusercontent.com
185.199.108.133 avatars5.githubusercontent.com
185.199.108.133 avatars6.githubusercontent.com
185.199.108.133 avatars7.githubusercontent.com
185.199.108.133 avatars8.githubusercontent.com
#parallels-desktop
127.0.0.1 download.parallels.com
127.0.0.1 update.parallels.com
127.0.0.1 desktop.parallels.com
127.0.0.1 download.parallels.com.cdn.cloudflare.net
127.0.0.1 update.parallels.com.cdn.cloudflare.net
127.0.0.1 desktop.parallels.com.cdn.cloudflare.net
127.0.0.1 www.parallels.cn
127.0.0.1 www.parallels.com
127.0.0.1 reportus.parallels.com
127.0.0.1 parallels.com
127.0.0.1 parallels.cn
127.0.0.1 pax-manager.myparallels.com
127.0.0.1 myparallels.com
127.0.0.1 my.parallels.com
#brave
127.0.0.1 brave.com
127.0.0.1 support.brave.com
127.0.0.1 go-updater.brave.com
# gg
127.0.0.1 www.google.com
172.217.31.142 translate.google.cn
172.217.31.142 translate.google.com
172.217.31.142 translate.googleapis.com
127.0.0.1 fundingchoicesmessages.google.com
# CodeRunner;
127.0.0.1 coderunnerapp.com
127.0.0.1 www.coderunnerapp.com
# apple
127.0.0.1 ocsp.apple.com
127.0.0.1 swscan.apple.com
127.0.0.1 swdist.apple.com
127.0.0.1 swcdn.apple.com
127.0.0.1 swquery.apple.com
127.0.0.1 swdownload.apple.com
127.0.0.1 smp-device-content.apple.com
127.0.0.1 pancake.apple.com
127.0.0.1 cds.apple.com
# Proxifier;
127.0.0.1 www.proxifier.com;
127.0.0.1 proxifier.com;
# App Cleaner 7
127.0.0.1 nektony.com
# nova
151.101.110.79 nova-extensions.freetls.fastly.net
# wnet
104.244.42.129 twitter.com
157.240.2.35 facebook.com
172.217.9.78 youtube.com
74.125.4.103 googlevideo.com
157.240.2.53 whatsapp.com
# collect-data
127.0.0.1 pc.stgowan.com
127.0.0.1 zz.bdstatic.com
127.0.0.1 s5.cnzz.com
127.0.0.1 s9.cnzz.com
127.0.0.1 ia.51.la
127.0.0.1 js.users.51.la
127.0.0.1 collect-v6.51.la
127.0.0.1 sdk.51.la
127.0.0.1 api.growingio.com
127.0.0.1 wind.hlgdata.com
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 hm.baidu.com
127.0.0.1 bdimg.share.baidu.com
打开应用程序 - 词典.app - 偏好设置,默认勾选牛津英汉汉英词典(简体中文-英语)
如何扩展:
把下载的langdao-ce-gb.dictionary和langdao-ec-gb.dictionary英汉互译词典文件
拷贝到 ~/Library/Dictionaries 目录后再默认勾选中即可
由于VirtualBox启动后很占资源,一般在mac下可以用Parallels打开已存在的vbox文件转换后,用Parallels启动
或者参考https://kb.parallels.com/en/124109如何直接在Parallels里安装linux,安全起见必须选择与mac隔离,
并且调整硬盘非自动扩展,固定分配20G即可
问题:虚拟机里mint(ubuntu)分辨率只能设置800x600的问题
解决:
> apt install xdiagnose
> sudo xdiagnose
弹出xdiagnose设置框,设置debug下三个选项全部勾选后关闭xdiagnose并重启系统
> xrandr 查询系统支持的所有分辨率
关闭文件索引
> sudo mdutil -a -i off
若要开启则
> sudo mdutil -a -i on
导致标签失效的可能原因:
1,mds_stores文件索引关闭了(这里如果快捷tag少的话可以直接拖到个人收藏,这样继可以关闭索引不发热也能不用tag达到快捷访问目的)
2,Spotlight聚焦设置里隐私项目添加的文件夹是失效tag的上级文件夹
1. 修改/Applications/xxx.app/MacOS/下的可执行文件名后,需用文本打开修改Info.plist:
<key>CFBundleExecutable</key>
<string>新的可执行文件名</string>
校验是否已修改:
> defaults read /Applications/xx.app/Contents/Info CFBundleExecutable
2. 尝试对app移除隔离并重新签名
sudo xattr -cr /Applications/xxx.app #移除安全隔离
sudo codesign --force --deep --sign - /Applications/xx.app #重新签名
3. 清理LaunchServices缓存
> /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/xx.app
4. 如果是更换了icon需清理图标缓存
Info.plist:
<key>CFBundleIconFile</key>
<string>新的icon名.icns</string>
> sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
> sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;
> sudo rm -rf /Library/Caches/com.apple.iconservices.store
> killall Dock #重启Dock栏
5. (可选操作)如果还有问题尝试手动结束LaunchServices
> killall -KILL launchservicesd
1, 安装 Anaconda
> brew cask install anaconda
> vim ~/.zshrc
export PATH="$PATH:/usr/local/anaconda3/bin"
> conda -V
conda 4.8.3
2, 配置cn源
> vim ~/.condarc
channel_priority: flexible
ssl_verify: true
channels:
- conda-forge
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
3, 安装 spleeter -> https://github.com/deezer/spleeter/wiki/1.-Installation#using-conda
> conda install -c conda-forge spleeter
4, 测试
> spleeter separate -i test.mp3 -p spleeter:2stems -o /tmp
5, 测试如果成功可使用简易脚本模式
> vim tqrs.sh
#!/bin/sh
_wkdir_root="/data/test/music"
_wkdir_out="$_wkdir_root/out"
if [ $# -eq 1 ];then
echo "要分离人声的音乐文件路径为:$_wkdir_root/$1"
if [ ! -f "$_wkdir_root/$1" ]; then
echo "不存在该文件!"
exit 0
fi
cd $_wkdir_root
echo "分离人声中..."
spleeter separate -i $1 -p spleeter:2stems -o $_wkdir_out
echo "结束"
exit 0
else
echo "未输入 $_wkdir_root 目录下音乐文件名(如mydemo.mp3)"
fi
===================== 可能存在的错误及解决方案 =====================
=> Solving environment: failed
原因:网络或其它
解决:失败会自动切换再尝试,耐心等待即可(conda config --set channel_priority flexible)
=> AttributeError: module ‘tensorflow’ has no attribute ‘compat’
原因:tensorflow-estimator 与 tensorflow 版本不匹配( 比如出现 tensorflow 1.15.0 而 tensorflow-estimator 2.0.0 的情况)
解决:
> pip list | grep tensorflow
> pip uninstall tensorflow-estimator
> pip install tensorflow-estimator==1.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
=> TensorFlow | ValueError: Can't load save_path when it is None
原因:下载模型文件失败或未完成
解决:删除当前目录下pretrained_models即可,慢的话可能需要开启代理重试一次
新建文件(必须用Xcode才能编辑和保存)
~/Library/Services/translate.workflow
控件
网站弹出式菜单 -> 自定/720x480/居中/iphone/所选文本)
运行AppleScript(每次右上角运行按钮就相当于已保存)
(注意:如果实际运行走#google的时候加载很慢,则需要在/ets/hosts加入127.0.0.1 www.google.com)
on run {input, parameters}
#google -> https://translate.google.cn?sl=auto&tl=zh-CN&op=translate&text=
#bing -> https://cn.bing.com/translator?mkt=zh-CN&text=
set output to "https://cn.bing.com/translator?mkt=zh-CN&text=" & urldecode(input as string)
return output
end run
on urldecode(x)
set cmd to "'require \"cgi\"; puts CGI.escape(STDIN.read.chomp)'"
do shell script "echo " & quoted form of x & " | ruby -e " & cmd
end urldecode
Mac自带了Apache和PHP环境,但默认未开启
#查看apache版本
> apachectl -version
# 查看php版本
> php -v
# 开启Apache,在浏览器中输入localhost:80查看结果
> sudo apachectl start
# 关闭Apache
> sudo apachectl stop
# 重启Apache
> sudo apachectl restart
# 开启PHP
> sudo vim /etc/apache2/httpd.conf
查找#LoadModule php7_module libexec/apache2/libphp7.so去掉#注释即可
查找DocumentRoot找到对应默认web目录/Library/WebServer/Documents
# 测试php是否正常
> vim /Library/WebServer/Documents/index.php
<?php phpinfo(); ?>
在DocumentRoot默认web目录下新建index.php并删除index.html,
访问localhost是否打印php信息
# 查看错误日志与访问日志
> tail -f /var/log/apache2/error_log
> tail -f /var/log/apache2/access_log
# 查看php.ini文件位置
> php -i |grep php.ini
# 查看PHP是否支持某个模块插件
> php -m | grep redis
> php -m | grep mysql
# 修改Apache DocumentRoot默认web目录
> sudo vim /etc/apache2/httpd.conf
替换DocumentRoot和Directory目录为自定义目录重启Apache即可
若403 Forbidden,You don't have permission to access/on this server
则修改
#<Directory />
# AllowOverride none
# Require all denied
#</Directory>
为
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
是否存在,已存在则无需安装
> php -m | grep redis
源码克隆编译
> git clone https://github.com/phpredis/phpredis.git
> cd ./phpredis
> phpize
grep: /usr/include/php/main/php.h: No such file or directory
解决方案
10.14:
重新安装header头文件SDK即可
cd /Library/Developer/CommandLineTools/Packages/
$ open macOS_SDK_headers_for_macOS_10.14.pkg
10.15:
xcode-select --install # 安装常用开发工具,如:git等。
sudo mount -uw / # 根目录挂载为可读写,否则无法在/usr/下建立文件,本修改重启前有效。
sudo ln -s "$(xcrun --show-sdk-path)/usr/include" /usr/include
export SDKROOT="$(xcrun --show-sdk-path)" # 设置环境变量
echo "export SDKROOT=\"\$(xcrun --show-sdk-path)\"" >> ~/.bash_profile # zsh的自行搞定
sudo DevToolsSecurity -enable # 将系统置于开发模式
> ./configure
> make
> make install
开启php redis扩展
> vim /etc/php.ini
添加extension=redis.so保存即可
> php -m | grep redis
1,Finder新建一个窗口
2,按住option键同时拖动窗口到合适大小
3,再次打开窗口即为刚才设置的大小
桌面启动台出现重复图标:
> killall Dock (重启Launchpad)
设置 - 键盘 - 触控栏 显示F1、F2等,但esc键消失的问题
> sudo pkill TouchBarServer
Parallels Desktop:
虚拟机默认可以访问宿主机任何端口(必须使用当前宿主机IP如192.168.xxx),网络设置的转发规则中源头为当前虚拟机内的端口
声音问题,声音突然没了,重启coreaudiod服务
> sudo killall coreaudiod
> sudo launchctl stop com.apple.audio.coreaudiod && sudo launchctl start com.apple.audio.coreaudiod
软件提示无法打开或已损坏,如果安全与隐私界面没有拦截,则需先删除app文件的MAC保护标志
> sudo xattr -rd com.apple.quarantine /Applications/xxx.app
Charles抓包软件代理设置时提示Proxyman CFErrorDomainLaunchd error
> launchctl print-disabled system #查看被禁用的system服务
> sudo launchctl enable system/com.xk72.charles.ProxyHelper #重新启用
> sudo launchctl disable system/com.xk72.charles.ProxyHelper #手动禁用(闲置不用)
重新设置即可 Charles - proxy - Settings - macOS - Enable macOS proxy - use HTTP proxy
Charles无法抓取问题:
1.火狐浏览器或其它浏览器等程序需要设置网络代理为System系统代理才能被抓取
2.监控本地程序时可使用localhost.charlesproxy.com取代localhost或127.0.0.1进行访问才能被抓取
3.访问https网站时需要确保录制按钮旁的锁不是打开的,如果还是乱码则Help - SSLProxying - InstallCharlesRootCert
抓取本地程序代码中发起的请求,需设置代理:
方式1(代码中直接写入):
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888(Charles设置的http代理端口)");
方式2(在Eclipse首选项中配置网络代理):
网络链接配置 - Manual手动 - 代理host/port同上
方式3(在Eclipse或Java启动VM参数中添加代理):
eclipse.exe -vmargs -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888同上
无法杀死的进程过程:
> ps -ef|grep SunloginClient //查找进程PID
> launchctl list | egrep 'Label|com.oray' //或直接搜索Label
> launchctl list | egrep 'PID|62825|62826' //根据PID查看LaunchAgents启动详情
PID Status Label
62825 -9 com.oray.sunlogin.desktopagent
> sudo launchctl list | egrep 'PID|62825|62826' //sudo的也查一次,有可能包含未找到的
PID Status Label
62826 -9 com.oray.sunlogin.helper
> launchctl stop xxxxLabelxxx.plist //停止进程Lablel+.plist
> launchctl unload xxxxLabelxxx.plist //卸载(注意unload需要在目录下执行,如/Library/LaunchAgents和/Library/LaunchDaemons或~/Library/LaunchAgents相关目录)
> launchctl load xxxxLabelxxx.plist //可用load加载回来Label+.plist
> launchctl start xxxxLabelxxx.plist //load后启动
#!/bin/sh
# 不使用向日葵时退出软件后再使用该脚本强制结束进程
echo "强制停止SunloginClient开始..."
cd /Library/LaunchAgents
sudo launchctl stop com.oray.sunlogin.agent.plist && sudo launchctl stop com.oray.sunlogin.startup.plist
sudo launchctl unload com.oray.sunlogin.agent.plist && sudo launchctl unload com.oray.sunlogin.startup.plist
#非sudo下也需要停止
launchctl stop com.oray.sunlogin.agent.plist && launchctl stop com.oray.sunlogin.startup.plist
launchctl unload com.oray.sunlogin.agent.plist && launchctl unload com.oray.sunlogin.startup.plist
cd /Library/LaunchDaemons
sudo launchctl stop com.oray.sunlogin.helper.plist && sudo launchctl stop com.oray.sunlogin.plist
sudo launchctl unload com.oray.sunlogin.helper.plist && sudo launchctl unload com.oray.sunlogin.plist
#非sudo下也需要停止
launchctl stop com.oray.sunlogin.helper.plist && launchctl stop com.oray.sunlogin.plist
launchctl unload com.oray.sunlogin.helper.plist && launchctl unload com.oray.sunlogin.plist
ps -ef |grep SunloginClient | grep -v grep |awk '{print $2}'|xargs kill -9 1>/dev/null 2>&1
echo "强制停止SunloginClient结束,现存进程:"
sudo launchctl list | egrep 'Label|com.oray'
#非sudo下进程列表
launchctl list | egrep 'Label|com.oray'
#!/bin/sh
# 使用SunloginClient前恢复权限
echo "恢复SunloginClient开始..."
cd /Library/LaunchAgents
sudo launchctl load com.oray.sunlogin.agent.plist && sudo launchctl load com.oray.sunlogin.startup.plist
cd /Library/LaunchDaemons
sudo launchctl load com.oray.sunlogin.helper.plist && sudo launchctl load com.oray.sunlogin.plist
sudo launchctl start com.oray.sunlogin.helper.plist && sudo launchctl start com.oray.sunlogin.plist
#无效时考虑非sudo恢复?
cd /Library/LaunchAgents
sudo launchctl start com.oray.sunlogin.agent.plist && launchctl start com.oray.sunlogin.startup.plist
echo "恢复SunloginClient结束,现有进程:"
sudo launchctl list | egrep 'Label|com.oray'
#!/bin/sh
# 不使用ToDesk时退出软件后再使用该脚本强制结束进程
echo "强制停止ToDesk开始..."
cd /Library/LaunchDaemons
sudo launchctl stop com.youqu.todesk.service.plist
sudo launchctl unload com.youqu.todesk.service.plist
launchctl stop com.youqu.todesk.service.plist
launchctl unload com.youqu.todesk.service.plist
ps -ef |grep ToDesk_Service | grep -v grep |awk '{print $2}'|xargs kill -9 1>/dev/null 2>&1
echo "强制停止ToDesk结束,现存进程:"
sudo launchctl list | egrep 'Label|com.youqu.todesk'
launchctl list | egrep 'Label|com.youqu.todesk'
#!/bin/sh
echo "恢复ToDesk开始..."
cd /Library/LaunchDaemons
sudo launchctl load com.youqu.todesk.service.plist
sudo launchctl start com.youqu.todesk.service.plist
echo "恢复ToDesk结束,现有进程:"
sudo launchctl list | egrep 'Label|com.youqu.todesk'
#!/bin/sh
# 彻底停止Charles
#sudo launchctl disable system/com.xk72.charles.ProxyHelper
cd /Library/LaunchDaemons
sudo launchctl stop com.xk72.charles.ProxyHelper.plist
sudo launchctl unload com.xk72.charles.ProxyHelper.plist
launchctl stop com.xk72.charles.ProxyHelper.plist
launchctl unload com.xk72.charles.ProxyHelper.plist
ps -ef |grep com.xk72.charles | grep -v grep |awk '{print $2}'|xargs kill -9 1>/dev/null 2>&1
echo "强制停止Charles,现存进程:"
sudo launchctl list | egrep 'Label|com.xk72.charles'
#非sudo下进程列表
launchctl list | egrep 'Label|com.xk72.charles'
#!/bin/sh
# 恢复Charles
#sudo launchctl enable system/com.xk72.charles.ProxyHelper
cd /Library/LaunchDaemons
sudo launchctl load com.xk72.charles.ProxyHelper.plist
sudo launchctl start com.xk72.charles.ProxyHelper.plist
echo "恢复Charles结束,现有进程:"
sudo launchctl list | egrep 'Label|com.xk72.charles'