安装 chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
安装网络工具
sudo apt install -y net-tools
sudo apt install -y iputils-ping
sudo apt install -y telnet
安装 vim
sudo apt install -y vim
启动 springboot 程序
nohup java -Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=8100 -jar coffee-1.0.jar --spring.config.location=application.yml,application-dev.yml --logging.config=logback.xml 2>&1 &
查询进程并 kill
kill -9 `ps -ef|grep coffee-1.0.jar | grep -v grep|awk '{print $2}'`
ps -ef | grep hello | grep -v grep | awk '{print $2}' | xargs kill -9
dos2unix
sudo apt install -y dos2unix
dos2unix t.sh
dos2unix *
修改mydir 目录所属用户和组
chown -R mm:mm mydir
kvm
# 查看镜像信息
qemu-img info bionic-server-cloudimg-amd64.img
# 把 vmware 虚拟机转化成 qcow2
qemu-img convert -f vmdk -O qcow2 Windows_Server_2019_1909-disk1.vmdk w2019.img
ssh
终端与服务器保持心跳,编辑文件
vim /etc/ssh/ssh_config
添加配置
ServerAliveInterval 30
ServerAliveCountMax 10
hash计算
md5sum master.ova
不能与主机共享剪贴板(vmware)
apt update
apt install open-vm-tools open-vm-tools-desktop
reboot
搜索日志
cat xxx.log | grep key
grep -a key xxx.log #解决Binary file (standard input) matches
grep -rn "xxx" * #递归搜索所有文件,并且显示行号
查看安装软件的版本
dpkg -l | grep nfs
开启远程桌面
开启后,客户端包安全错误,可取消加密
gsettings set org.gnome.Vino require-encryption false
连接windows server 2012 r2 远程桌面
使用 Remmina, 可远程连接 windows系统桌面,如下图:
连接出错解决
如果连接出现如下错误:
You requested an H264 GFX mode for server app.localhost.com, but your libfreerdp does not support H264. Please check Color Depth Settings
解决:
# 添加 remmina 仓库
sudo apt-add-repository ppa:remmina-ppa-team/remmina-next
sudo apt update
#重新安装 remmina
sudo apt install remmina remmina-plugin-rdp remmina-plugin-secret
#关掉所有 remmina 进程
sudo killall remmina
参考:https://blog.youkuaiyun.com/Joker00007/article/details/112950609
切换到root
#使用当前用户环境
sudo -s
#同时切换到root用户环境
sudo su
git linux和windows换行符差异解决
大部分时候在windows上开发,有时候需要在linux上调试。因为换行符的差异,linux上看到所有文件都被改变了。在linux系统上项目目录下,执行命令
git config core.autocrlf input
测试磁盘读写速度
time dd if=/dev/zero of=t.img bs=32k count=102400 #写速度
time dd if=t.img of=/dev/null bs=32k
openssl
openssl pkey -in apiserver.key -noout -text #查看秘钥
openssl x509 -in apiserver.crt -noout -text #查看证书
ubuntu云镜像设置root用户密码
sudo apt install libguestfs-tools
#把root密码设置为123456
virt-customize -a focal-server-cloudimg-amd64.img --root-password password:123456
锁定内核版本
sudo apt-mark hold linux-image-5.4.0-148-generic
sudo apt-mark hold linux-headers-5.4.0-148-generic
sudo apt-mark hold linux-modules-5.4.0-148-generic
sudo apt-mark hold linux-modules-extra-5.4.0-148-generic
ubuntu历史版本
https://old-releases.ubuntu.com/releases/20.04.4/
#dhcp refresh ip
sudo dhclient -r enp0s8
sudo dhclient enp0s8
查看系统状态
cpu
top 1
or
mpstat -P all 1
内存
vmstat 1
磁盘
iostat -d -k 1
iotop -oP
进程
pidstat -t -p xx 1 #thread
pidstat -w -p xx 1 #上下文切换
查看 docker 绑定
docker inspect xxx|grep Pid
taskset -c -p yyy
openssh 加解密文件
#加密
openssl enc -e -aes256 -in xfuzzserver.zip -out xfuzzserver.aes
#解密
openssl enc -d -aes256 -in xfuzzserver.aes -out xfuzzserver.zip