Shell相关

Node包管理器

yarn

# 升级依赖包
yarn upgrade [package]
yarn upgrade [package]@[version]
# 删除依赖包
yarn remove [package]
# 运行脚本
yarn run [script] [<args>]
# 显示某个包信息
yarn info [package]
yarn info [package] --json
# 列出当前工作文件夹所有依赖
yarn list [--depth] [--pattern]
yarn list --depth=0
# 列出已缓存的包
yarn cache list
# 当前yarn全局缓存位置
yarn cache dir
# 清除缓存
yarn cache clean
yarn cache clean [<module_name...>]
# 设置淘宝镜像
yarn config set registry https://registry.npmmirror.com/

Centos

系统相关

# 查看CentOS体统的内核版本
uname -r
# 查看内存使用情况
free -h
# 查看硬盘使用情况
df -h 

服务相关

# 查看服务列表
systemctl list-unit-files

# 查看某个服务状态
systemctl list-unit-files | grep firewalld

# 开机自启和不自启
systemctl enable service_name
systemctl disable service_name

# 防火墙
systemctl restart firewalld
firewalld-cmd --zone=public --add-port=80/tcp --permanent

# 常用方法
systemctl start 服务名(XXX.service)
systemctl restart 服务名(XXX.service)
systemctl stop 服务名(XXX.service)
systemctl reload 服务名(XXX.service)
systemctl status 服务名(XXX.service)

端口相关

# 查看端口占用情况
lsof -i:8080

netstat -anp|grep 8080

常用软件安装

安装NodeJS

cd /usr/local/src

wget https://nodejs.org/dist/v14.15.0/node-v14.15.0-linux-x64.tar.gz

tar -zxvf node-v14.15.0-linux-x64.tar.gz

mv node-v14.15.0-linux-x64 nodejs14.15

ln -s /usr/local/src/nodejs14.15/bin/node /usr/local/bin

ln -s /usr/local/src/nodejs14.15/bin/npm /usr/local/bin

npm i -g pm2

ln -s /usr/local/src/nodejs14.15/lib/node_modules/pm2/bin/pm2 /usr/local/bin

安装puppetter

npm install puppeteer --ignore-scripts --save
# 下载对应编号的Chromium,需要将%d替换成你查找到的编号
linux: 'https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/%d/chrome-linux.zip'
mac: 'https://storage.googleapis.com/chromium-browser-snapshots/Mac/%d/chrome-mac.zip'
win32: 'https://storage.googleapis.com/chromium-browser-snapshots/Win/%d/chrome-win32.zip'
win64: 'https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/%d/chrome-win32.zip'

# 下载后将压缩包上传到服务器,存储位置为node_modules/puppeteer/.local-chromium/linux-%d

# 安装相关依赖
#依赖库
yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 nss.x86_64 -y
#字体

yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y

# 初始化浏览器参数
const pathToExtension = "/home/cyz/project/puppetter/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome"
const browser = await puppeteer.launch({
    executablePath: pathToExtension,
    headless: true,
    args:['--disable-infobars','--no-sandbox','--disable-setuid-sandbox']
})

# 处理权限
chmod -R 777 /home/cyz/project/puppetter/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome

安装Redis

  1. 官网下载redis.x.x.tar.gz文件,并上传之服务器
  2. 运行gcc --version查看是否有 gcc 的环境
  3. 如果没有 gcc,则执行yum install gcc
  4. 解压进入redis目录
  5. make
  6. make install
  7. 成功后会在/usr/local/bin目录下看到redis-serverredis-cli

redis.conf 基本配置项

# 前台启动
daemonize yes
# 数据库个数
databases 16
# 配置远程连接,注释掉即可
bind 127.0.0.1
# 保护模式,远程连接需要设置为no
protected-mode yes

MongoDB安装

安装步骤待完善

常用配置:

# 远程访问
bind_ip: 0.0.0.0
# 配置密码访问
security:
  authorization: enabled

MySql完全卸载

sudo rm /usr/local/mysql

sudo rm -rf /usr/local/mysql*

sudo rm -rf /Library/StartupItems/MySQLCOM

sudo rm -rf /Library/PreferencePanes/My*

rm -rf ~/Library/PreferencePanes/My*

sudo rm -rf /Library/Receipts/mysql*

sudo rm -rf /Library/Receipts/MySQL*

sudo rm -rf /private/var/db/receipts/*mysql*

brew

# 安装服务类、命令行软件,如git,redis,nginx
brew install [包名]
# 安装带有图形界面的软件
brew install --cask [包名]
# 卸载软件
brew uninstall [包名]
# 搜索
brew search [包名]
# 查看
brew info [包名]
# 打开软件官网
brew home [包名]
# 更新Homebrew自身
brew update
# 查看可升级的软件
brew outdated
# 升级所有软件
brew upgrade
# 升级指定软件
brew upgrade [包名]
# 查看所有已安装的软件
brew list
# 清理所有旧版软件
brew cleanup
# 清理指定软件的旧版
brew cleanup [包名]
# 查看安装源列表
brew tap
# 添加一个新的tap
brew tap [tap名]
# 管理后台服务,如nginx、redis等
## 查看所有已注册的服务
brew services list
## 运行某个服务,并设置开机自动运行
brew services start [服务名]
## 停止某个服务
brew services stop [服务名]
## 重启某个服务
brew services restart [服务名]
## 单次运行某个服务
brew services run [服务名]

Git相关

# 生成ssh公钥
ssh-keygen -t rsa -C "xxxxxx@qq.com"
# 测试是否关联成功
ssh -T git@github.com

清除Mac电脑的DNS缓存

sudo killall -HUP mDNSResponder
Loading...