Skip to content

Instantly share code, notes, and snippets.

@ericzhong
Last active December 9, 2017 07:29
Show Gist options
  • Save ericzhong/af3fda0b203c172cde4238130fcd38c1 to your computer and use it in GitHub Desktop.
Save ericzhong/af3fda0b203c172cde4238130fcd38c1 to your computer and use it in GitHub Desktop.
Mac 常用命令
## HomeBrew
export HOMEBREW_VERBOSE=1
export HOMEBREW_NO_AUTO_UPDATE=1
# change repo
cd /usr/local/Homebrew
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-science"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-science.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-python"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-python.git
brew update


## top
# order by
top -o [+]mem|cpu|time|pid


# -n, number
# -r, route table
netstat -nr


## packet filter control
# port forword
sudo sysctl -w net.inet.ip.forwarding=1
echo "rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080" | sudo pfctl -ef -
# -s modifier, show
sudo pfctl -s nat
# -F modifier, flush
sudo pfctl -F all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment