常用正则
- 常用正则表达式
常用正则
git相关
- 项目添加git管理
git init
git remote add origin 你的仓库地址
git add *
git commit —m"初次提交"
- 切换git仓库源
git remote set-url origin newRepoUrl
- Committing is not possible because you have unmerged files.
# 查看冲突
git status
# 添加到git
git add [filename]
# 或者从git删除
git rm [filename]
docker相关
- 设置容器开机自启动
docker run --restart=always 镜像
- 设置运行中容器开机自启动
docker update --restart=always fa0c54878a07(容器id或者容器名)
- 设置容器自启动失败次数
docker update --restart=on-failure:10 fa0c54878a07(容器id或者容器名)
Go
go get时候 timeout
go env -w GOPROXY=https://goproxy.cn,direct
当执行 git run 时候
package YOU_PATH is not in GOROOT
执行
git mod init
其他
- ts视频合并为mp4
copy /b D:\tsDir\* D:\tsDir\new.mp4
- Linux 端口占用
# 查看端口占用情况
lsof -i:8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nodejs 26993 root 10u IPv4 37999514 0t0 TCP *:8000 (LISTEN)
# 查看端口占用情况
netstat -tunlp | grep 端口号
# 杀掉进程
kill -9 PID
- 解决无法杀掉进程
# 解决使用 kill -9 pid 无法杀掉进程
# 进入进程目录
# [root]# cd /proc/#pid#
[root]# cd /proc/27437
[root]#cat status
Name: java
State: Z (zombie)
Tgid: 27437
Ngid: 0
Pid: 27437
PPid: 27415
TracerPid: 0
Uid: 1000 1000 1000 1000
Gid: 1000 1000 1000 1000
...
# 杀掉父进程和子进程
# [root]# kill -9 #PPid# #Pid#
[root]# kill -9 27415 27437
- Windows 端口占用
# 查看占用情况
netstat -aon|findstr "10080"
TCP 0.0.0.0:10080 0.0.0.0:0 LISTENING 29800
TCP [::]:10080 [::]:0 LISTENING 29800
# 查看进程
tasklist|findstr "29800"
java.exe 29800 Console 1 489,272 K
# 杀掉进程
taskkill /T /F /PID 29800
成功: 已终止 PID 41428 (属于 PID 29800 子进程)的进程。
成功: 已终止 PID 29800 (属于 PID 37260 子进程)的进程。
批量杀进程
# python 替换关键词
ps aux | grep python | grep -v grep | awk '{ print $2 }' | xargs -r kill
日志检索
# 检索application.log关键词keyword上下10行并展示行号
cat application.log | grep -n -B10 -10 "keyword"
# 检索application.log关键词keyword1或者keyword2
cat application.log | grep -E "keyword1|keyword2"
# 慢慢查看application.log第67595行以后的内容
less +67595 -N application.log
maven命令
下载源码
mvn dependency:resolve -Dclassifier=sources
idea 初始化
keymap > 搜索basic 替换快捷键为 alt+逗号
editor > code style > java > imports > 修改 Class count 和 Names count
editor > general > editor tabs > closing policy > 修改tab limit
editor > file types > Ignored Files and dir
editor > inspections > 搜索 Serializable class without 'serialVersionUID'
linux防火墙
1、查看firewall服务状态
systemctl status firewalld
出现Active: active (running)切高亮显示则表示是启动状态。
出现 Active: inactive (dead)灰色表示停止,看单词也行。
2、查看firewall的状态
firewall-cmd --state
3、开启、重启、关闭、firewalld.service服务
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
4、查看防火墙规则
firewall-cmd --list-all
5、查询、开放、关闭端口
# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload