Mac使用相关

2021/11/21 碎片

Mac使用相关

# Mac 常用命令

  • 【编辑host】sudo vim /etc/hosts
  • 【查看端口号port对应的进程】lsof -i tcp:[port]
  • 【结束进程】sudo kill [pid]
  • 【清屏】clear
  • 【拷贝文件】ctp 文件源路径 文件目标路径
  • 【新建文件】touch [filename.abc]
  • 【解压 需要安装unar】unar [filename.abc]

# HomeBrew 相关

  • 【安装homebrew】 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    • 因为是官方的安装脚本,可能速度很慢,此时请使用中科大的脚本 /usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
  • 【切换源】需要依次执行下面的命令
    • git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
    • git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
    • git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
    • brew update

# 解压命令

官方的支持格式不多,unar是一个万能解压缩工具,需要手动安装下。

  • 【安装解压工具unar】homebrew install unar
  • 【解压命令】unar test.zip -o /home/dir/ -p 123456

-o 是目标路径 -p 是密码,其他的参数输入unar查看下吧

# FortiClient

m1芯片打开后 软件显示空白。估计是有啥奇怪的问题。

可以使用 开源包openfortivpn 启动。

# <!--安装openfortivpn-->
brew install openfortivpn
# <!--创建文件并配置-->
host = 117.22.228.210
port = 10443
username = tigestream@orderplus.com
password = tigestream
trusted-cert = c526ff0f763f519ad61b7c015c38fbd22a1a55b82d0ed680f39f3092c679a339
# <!--终端启动服务-->
sudo openfortivpn -c [config文件目录]
# <!-- 也可以写个sh文件直接执行,省的记命令了 -->
1
2
3
4
5
6
7
8
9
10
11

需要注意:trusted-cert后面的参数大概率不知道,可以先省掉这一行,先启动服务,终端中会报错如下。然后把ERROR中的值粘贴进来再次启动就好了。

ERROR:  Gateway certificate validation failed, and the certificate digest is not in the local whitelist. If you trust it, rerun with:
ERROR:      --trusted-cert c526ff0f763f519ad61b7c015c38fbd22a1a55b82d0ed680f39f3092c679a339
ERROR:  or add this line to your configuration file:
ERROR:      trusted-cert = c526ff0f763f519ad61b7c015c38fbd22a1a55b82d0ed680f39f3092c679a339
1
2
3
4

# 更新到12后,git没了

更新到 MacOS Monterty(12.2.1) 后,遇到的第一个问题就是,我的git没了。

在我想用brew 重新安装git时,系统提示

# sudo brew install git
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
# brew install git
Error: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install

Error: 'git' must be installed and in your PATH!
Error: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install
1
2
3
4
5
6
7
8
9
10
11
12
13

按照命令执行

# xcode-select --install
1

等待重新安装xcode之后就可以使用git了

百度后发现,mac升级系统时会删除xcode,想不通是为啥;另外升级系统之后,我硬盘多出来20多G,不知道把啥玩意给我删了···