记录一些常用的系统或者软件命令
linux
# 查看端口占用
$ lsof -i :8080
# 结束进程
$ sudo kill -9 [pid]
windows
# 查看端口占用
$ netstat -aon | findstr 8080
# 查看 pid 进程
$ tasklist | findstr 19516
# 结束进程
$ taskkill /pid 19516 /F
# 或者使用进程名字
$ taskkill -F -IM node.exe
linux
shutdown
有如下选项:
- k =>不执行任何关机操作,只发出警告信息给所有用户
- r => 重新启动计算机
- h => 关机并彻底断电
- f =>快速关机且重启动时跳过fsck
- n =>快速关机不经过init程序
- c => 取消之前的定时关机
立即关机:shutdown -h now
立即重启:shutdown -r now
注意:now 不能省略
$ shutdown -h +10 # 10分钟后自动关机
$ shutdown -h 10:00 # 10点整关机
windows
shutdown
-a =>取消关机
-s 关机
-f =>强行关闭应用程序
-l =>注销当前用户
-r =>关机并重启
-s -t 时间 =>设置关机倒计时
-h 休眠
$ shutdown -s -t 3600 # 一个小时候自动关机
windows
$ ipconfig /flushdns
# 显示当前的 Git 配置
$ git config --list
# 编辑Git配置文件
$ git config -e [--global]
# 设置提交代码时的用户信息
$ git config [--global] user.name "[name]"
$ git config [--global] user.email "[email address]"
$ git add -A (stage all files: new, modified, deleted)
$ git add . (stage files: new, modified, deleted[version 2])
$ git add -u (stage files: modified, deleted)
$ git add --ignore-removal . (stage files: new, modified)
$ git commit -m [message]
$ git commit [file1][file2]... -m [message] # file 要包含路径
# amend 使用一次新的 commit,替代上一次提交
# 如果代码没有任何新变化,则用来改写上一次 commit 的提交信息
$ git commit --amend -m [message]
# 重做上一次commit,并包括指定文件的新变化
$ git commit --amend [file1][file2]... -m[message]
# 取回远程仓库的变化,并与本地分支合并
$ git pull [remote] [branch]
# 上传本地指定分支到远程仓库
$ git push [remote] [branch]
# 强行推送当前分支到远程仓库,即使有冲突
$ git push [remote] --force
# 推送所有分支到远程仓库
$ git push [remote] --all
# 列出所有本地分支
$ git branch
# 列出所有远程分支
$ git branch -r
# 列出所有本地分支和远程分支
$ git branch -a
# 新建一个分支,但依然停留在当前分支
$ git branch [branch-name]
# 新建一个分支,并切换到该分支
$ git checkout -b [branch]
# 切换到指定分支,并更新工作区
$ git checkout [branch-name]
# 新建一个分支,与指定的远程分支建立追踪关系
$ git branch --track [branch] [remote-branch]
# 删除分支
$ git branch -d [branch-name]
# 删除远程分支
$ git push origin --delete [branch-name]
$ git branch -dr [remote/branch]
# 选择一个commit,合并进当前分支
$ git cherry-pick [commit id]
# 显示所有远程仓库
$ git remote -v
# 增加一个新的远程仓库
$ git remote add [shortname] [url]