Command

Last Edited Time
Feb 9, 2022 06:15 AM
date
Jan 8, 2018
slug
command
status
Published
tags
Command
Bash
ZSH
Notebook
summary
常用的 CMD 命令
type
Post

Common

Mac shadowsocks kcptun not working

你用的是两个不同分支的 kcptun,下载的这个版本不支持从插件选项里面读参数 似乎目前只支持到 kcptun 的 2017 版本
ln -s ../kcptun_v20170718/kcptun_client ./kcptun

Mac Allow apps downloaded from anywhere

sudo spctl --master-disable

Mac ReInstall CommandLineTools

Solve No Xcode or CLT version detected!
rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Run comment as sudo

eugene        ALL=(ALL)       NOPASSWD:/usr/bin/systemctl reload nginx

GEO SQL

UPDATE `do_onepage_store` SET geom = GeomFromText('POINT(0 0)')
SELECT * FROM `do_storelist` WHERE ST_Distance_Sphere(Point(0, 0), geom)  =0

check the 40 largest file

sudo du -x -h / | sort -h | tail -40

Find all files in current directory recursively

find . -type f | wc -l

find all file match regex

find . -regex ".*/api/.*\.ts"

Package Manager

homebrew

brew leaves #list installed top-level packages
brew install PACKAGE
brew uninstall PACKAGE

Mac 上使用 brew update 会卡住的问题

# 替换源地址
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 重置为官方地址
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

Install plantUML

brew install caskroom/cask/brew-cask
brew install java
brew install graphviz

yarn

yarn install
yarn add
yarn remove
yarn global list --depth=0 #list installed top-level packages
nodeLinker: pnp
yarnPath: .yarn/releases/yarn-3.0.1.cjs
unsafeHttpWhitelist:
  - '*.tuzhanai.com'
npmRegistryServer: http://npm.tuzhanai.com/

pnpMode: loose

npm

npm install
npm remove
npm -g list --depth=0

Process

Kill all php-fpm pool www

kill -9 `ps -ef | grep 'php-fpm: pool www' | awk ' { print $2 }' | head -n -1`

check_status.sh

ps -fp $(pgrep  -f Qworker)

restart_worker.sh

pgrep -f Qworker.php |xargs kill -9/home/goopter/start_worker.sh

start_worker.sh

cd /var/www/qa/goopter_common/mq/receivernohup php Qworker.php > worker.log &

stop_worker.sh

pgrep -f Qworker.php |  xargs kill -9

stop flutter

ps -ef | grep flutter | grep -v grep | awk '{print $2}' | xargs kill -9

check port

ss -ntuap | egrep $PORT
ps -ef | egrep $PID

vim 粘贴格式不对

# 开启
:set paste

# 关闭
:set nopaste

Grep without node_modules

# grep without node_modules
grep -rF --exclude-dir=node_modules --exclude-dir=.cache-loader '@fe/common/lib/file-uploader' *

rsync

# copy without node_modules
rsync -avltrc --exclude="node_modules" --exclude=".cache-loader" --exclude="logs" --delete admin/ admin_xy/

# dry-run with --include-from
rsync -avltrc --dry-run \
  --include-from '/Users/jiyu/Code/rabbitpre/@fe-deploy/rsync_xy-include.txt' \
  /Users/jiyu/Code/rabbitpre/@fe-deploy/ \
  ~/Desktop/@fe-deploy.bak/
rsync_xy-include.txt
+ /*/
+ /*/prod_xy/
+ /*/prod_xy/**
- *

copy file from remote

scp -P 22 root@66.42.74.139:/root/kcptun.sh ./

curl with duration

 
curl -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} --location --request GET 'https://ema-home.xyzq.cn/slowtest.txt' \
--header 'Cookie: renderer.sid=s%3A8h0vJmXRqGnDBxuPNd5a_vBLo_4ILUdq.xDo7bjJWXOxZDsqwIFVPLxqtWjy8cKa3ydsjZfMa3j4; rp.sid=s%3AnGR4PA6TtkJAw_OewqAKydIv1UKxKk48.cuhLIH53b8aJ86GlRgR5Gwr2fxx137GEZ5rBIy76NlE'