目录
Git push 已存在文件夹
cd existing_folder
git init
git remote add origin http://XXX.git
git add .
git commit -m “Initial commit”
git push -u origin master
Git 切换分支、更新代码
- git remote -v
- git remote rm origin
- git remote add origin http://10.100.37.6/wltsgz/ultra-tsgz-bp.git
- git pull
- git branch --set-upstream-to=origin/dev dev
- git pull
Git 撤销本地修改
- git checkout – .(未git add)
- git reset HEAD . (已git add)
- git reset --soft HEAD^(已git commit、不撤销git add)
- git reset --hard HEAD^(已git commit、同时撤销git add)
redis
- redis-cli
- auth 密码
- keys *
- flushdb
mysql导出
- cd /usr/bin
- ./mysqldump -uroot -p dbname > /root/dbname.sql
- ./mysqldump -uroot -p dbname --tables table_name1 table_name2 > /root/dbname.sql
- ./mysqldump -uroot -h 127.0.0.1 -p dbname > /root/dbname.sql
mysql导入
- mysql -uroot -p
- mysql -uroot -h 10.1.58.5 -P 3307 -p
- CREATE DATABASE /*!32312 IF NOT EXISTS*/ `dbname` /*!40100 DEFAULT CHARACTER SET utf8 */;
- use dbname;
- source /root/dbname.sql
docker-mysql数据导入
- docker cp mydb.sql mysql5.7:/root/
- docker exec -it mysql5.7 sh
- mysql -uroot -p
- create database mydb;
- use mydb;
- source /root/mydb.sql;
docker
- docker exec -it [name/id] /bin/sh
- docker save name/id -o ./images.tar
- docker load -i ./images.tar
- docker-compose up -d
- docker-compose --compatibility up -d
- docker-compose -f docker-compose.yml up -d
- docker-compose down、rm、stop、start
- docker rm $(docker ps -a -q)
- docker rm $(docker ps -a | grep)
- docker stats --no-stream
- docker rmi $(docker images -f “dangling=true” -q)
文件
- ll
- ls
- ls -a:
- ps -ef | grep [正则]
- pwd
- mv [文件夹] [目标路径]
- mv [文件夹]/** [目标路径]
- cp -r [文件夹] [目标路径]
- cp [文件] [目标路径]
- rm [文件]
- rm -rf [文件夹]
- cat [文件]
- tar -cvf [].tar [需压缩目录/文件]
- tar -czvf [].tar.gz [需压缩目录/文件]
- tar -xvf [].tar
- tar -xJvf [].tar.xz
- unzip [].zip
- vi /etc/profile
- source /etc/profile
进程
- kill -9 [进程号]
- nohup java -jar [.jar] --server.port=[port] > server.log 2>& 1 &
- echo $[]
- Ctrl+C:关闭进程
- Ctrl+Z:进程后台运行
网络
- 本机ip地址:ip addr show
- 本机网关地址:ip route show default
- netstat -ntlp
- lsof -i:[port]
- telnet [port] [ip]
- firewall-cmd --zone=public --list-ports
- systemctl stop firewalld.service
- firewall-cmd --zone=public --add-port=[port]/tcp --permanent
- firewall-cmd --zone=public --remove-port=[port]/tcp --permanent
- firewall-cmd --reload
资源
- df -h 磁盘
- free -h 内存
- lscpu 内核
vi
- vi [文件]
- i
- esc
- :wq
- :q
- :wq!
- q!
- /字符串 回车查询,n下一个
权限
- 查看用户 cat /etc/passwd
- 查看权限 ls -l /test
- useradd -m test
- passwd test
- visudo
- test ALL=(ALL:ALL) ALL
- groupadd mysql
- useradd -r -g mysql mysql
- chown -R mysql:mysql /data/test
- chmod -R 755 /data/test
- chmod a+x [.sh文件] 所有用户可执行权限
- chmod u+x [.sh文件] 文件所有者可执行权限
- 授权docker命令给用户 usermod -aG docker [用户名]
ssh端口
- vi etc/ssh/sshd_config
- systemctl restart sshd.service
查看nginx默认安装的模块
- cd /usr/local/src/nginx-1.13.7
- cat auto/options | grep YES
启动nginx
- which nginx
- nginx
- cd /usr/local/nginx/sbin
- ./nginx
- nginx -t #检查配置文件
- nginx -c /etc/nginx/nginx.conf #执行
- nginx -s reload #重载
- nginx -s reopen #重启
启动tomcat
- bin/startup.sh #启动tomcat
- bin/shutdown.sh #停止tomcat
- tail -f logs/catalina.out #看tomcat的控制台输出
启动mysql
- service mysqld start
- service mysqld stop
- service mysqld restart
启动docker
- systemctl start docker.socket
- systemctl stop docker.socket
启动redis
- cd /usr/local/redis
- ./bin/redis-server redis.conf
kubectl
- kubectl apply -f [.yaml]
- kubectl exec -it [pod/name] – sh (注意是两个-,然后空格,然后sh)
- kubectl get pods,svc -o wide
- kubectl delete deployment [name]
- kubectl set image deployment/[name] [容器名]=[镜像]
- kubectl rollout restart deployment/[name]