软件
浏览器
https://www.microsoft.com/zh-cn/edge
升级
git 升级
# 查看版本
git --version
# 升级 Git
brew install git
# 重新链接 git
brew link git --overwrite
# 查看版本
git --version
配置修改
修改网络设置
# 列出本机所有网络服务
networksetup -listallnetworkservices
# 设置Wi-Fi静态IP和指定DNS
networksetup -setmanual "Wi-Fi" 10.0.1.37 255.255.255.0 10.0.1.1
networksetup -setdnsservers "Wi-Fi" 223.5.5.5 114.114.114.114
# 设置Wi-Fi自动获取IP和DNS
networksetup -setdhcp "Wi-Fi"
networksetup -setdnsservers Wi-Fi empty
修改 ulimit
launchctl limit
-----------------
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
memlock unlimited unlimited
maxproc 5568 8352
maxfiles 256 unlimited
------------------
echo "limit maxfiles 65535 unlimited" | sudo tee -a /etc/launchd.conf
# 记得重启哈
Linux发行版redhat/centos配置与osx不同,如下:
vim /etc/security/limits.conf
# noproc进程数,nofile文件打开数
# soft软限制, 在程序的进程中可自行改变.
# hard硬限制, 程序不可随意改变,除非有root权限.
* soft noproc 11000
* hard noproc 11000
* soft nofile 4100
* hard nofile 4100
创建新的配置文件,配置系统打开最多文件限制(如果没有的话)
sudo vim /Library/LaunchDaemons/limit.maxfiles.plist
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>655360</string>
<string>655360</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
.创建每个最大进程数限制的配置文件
sudo vi /Library/LaunchDaemons/limit.maxproc.plist
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
# 打开端口后限制 vim /etc/sysctl.conf
net.inet.ip.portrange.first=1024
net.inet.ip.portrange.last=65535
mac实现不对电池充电
把MagSafe接口5芯中间的那个断开,就可以实现使用电源供电,但是不对电池进行充电。只适合MagSafe接口的老机型,不适合最新的USB-C机型。
打开hosts权限
sudo /bin/chmod +a ‘user:’${LOGNAME}’:allow write’ /etc/hosts
配置系统打开最多文件限制
sudo vi /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>655360</string>
<string>655360</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
launchctl limit
再重启保证生效
每个最大进程数限制的配置文件
sudo vi /Library/LaunchDaemons/limit.maxproc.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>3096</string>
<string>3096</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
launchctl limit
再重启保证生效
端口限制
sudo vi /etc/sysctl.conf
net.inet.ip.portrange.first=1024
net.inet.ip.portrange.last=65535
CPU信息查看
#查看所有信息
sysctl machdep.cpu
#显示CPU型号
sysctl -n machdep.cpu.brand_string
#显示CPU核心数(物理核)
sysctl -n machdep.cpu.core_count
#显示线程数(逻辑核)
sysctl -n machdep.cpu.thread_count
并发测试问题
mac: max user processes最大值只能是2128,处于安全考虑,8G内存最大值为2500,16g最大值可以设置5000.
xcrun: error,missing xcrun
xcode-select --install
socket: Too many open files
$ sudo sysctl -w kern.maxfiles=1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
出现read: connection reset by peer
sysctl -a |grep somaxconn
sudo sysctl -w kern.ipc.somaxconn=2048
sysctl -w net.inet.ip.portrange.first=32768 # 增大客户端可以建立的连接数
launchctl limit maxfiles 99999 99999
ulimit -n 99999
Mac 解决brew一直卡在Updating Homebrew
# 直接关闭brew每次执行命令时的自动更新(推荐)
vim ~/.bash_profile
# 新增一行
export HOMEBREW_NO_AUTO_UPDATE=true
替换brew源
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
#替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update
# 备用地址-1
cd "$(brew --repo)"
git remote set-url origin https://git.coding.net/homebrew/homebrew.git
brew update
# 备用地址-2
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
brew update
#--------------------------------
#重置brew.git
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
#重置homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git