Skip to content

全文约 743 字 · 读完约 2 分钟

vim 意外退出后的恢复流程

使用vim -r恢复

bash
vim -r caixukun.sh

提示

执行上一步时需要回车一下,进入vim中wq保存退出,此时.caixukun.sh.swp文件内容会同步到caixukun.sh

删除swp文件

bash
rm -rf .caixukun.sh.swp

find -exec 报错:missing argument to '-exec'

bash
root@VM-0-4-ubuntu:/opt/mysql/mysql-backup# find /opt/mysql/mysql-backup/* -mtime +3 -name "*.gz" -exec rm -rf {};
find: missing argument to `-exec'

我这里的解决方案是加一个\

bash
find /opt/mysql/mysql-backup/* -mtime +3 -name "*.gz" -exec rm -rf {} \;

笔记

{}前后需要加空格

curl 报错:symbol lookup error

bash
curl: symbol lookup error: curl: undefined symbol: curl_easy_nextheader

解决方案:

bash
ldconfig

umount 报错:target is busy

bash
[root@ecs-79cf-0708514 downloads]# umount /downloads/
umount: /downloads: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))

解决方案: 安装fuser工具

bash
yum install psmisc.x86_64 -y

使用fuser定位进程信息

bash
[root@ecs-79cf-0708514 downloads]# fuser -m -u /downloads
/downloads:                5701c(root)  5779c(root)

信息

在例子中,使用了-m和-u选项,用来查找所有正在使用/downloads 的所有进程的PID,以及该进程的OWNER,如5701c(root),其中5701是进程PID,root是该进程的OWNER。

查看进程使用的文件

bash
[root@ecs-79cf-0708514 downloads]#  ls -al /proc/5701/fd/
total 0
dr-x------ 2 root root  0 Oct  8 10:17 .
dr-xr-xr-x 9 root root  0 Oct  8 10:17 ..
lrwx------ 1 root root 64 Oct  8 10:17 0 -> /dev/pts/0
lrwx------ 1 root root 64 Oct  8 10:17 1 -> /dev/pts/0
lrwx------ 1 root root 64 Oct  8 10:17 2 -> /dev/pts/0
lrwx------ 1 root root 64 Oct  8 10:53 255 -> /dev/pts/0

[root@ecs-79cf-0708514 downloads]# ls -al /proc/5779/fd/
total 0
dr-x------ 2 root root  0 Oct  8 10:40 .
dr-xr-xr-x 9 root root  0 Oct  8 10:40 ..
lrwx------ 1 root root 64 Oct  8 10:40 0 -> /dev/pts/1
lrwx------ 1 root root 64 Oct  8 10:40 1 -> /dev/pts/1
lrwx------ 1 root root 64 Oct  8 10:40 2 -> /dev/pts/1
lrwx------ 1 root root 64 Oct  8 10:53 255 -> /dev/pts/1

通过ppid查看进程

bash
[root@ecs-79cf-0708514 downloads]# ps --ppid 5779
  PID TTY          TIME CMD
 5856 pts/1    00:00:00 ps
[root@ecs-79cf-0708514 downloads]# ps --ppid 5701
  PID TTY          TIME CMD

kill进程

注意

可能会kill掉当前终端

bash
[root@ecs-79cf-0708514 downloads]# kill -9 5701
[root@ecs-79cf-0708514 downloads]# kill -9 5779

再次尝试umount

bash
[root@ecs-79cf-0708514 ~]# umount /downloads/
[root@ecs-79cf-0708514 ~]#

成功

ssh 免密登录报错:Host key verification failed

配置ssh免密时报错

[root@jenkins .ssh]# ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
ERROR: It is also possible that a host key has just been changed.
ERROR: The fingerprint for the ECDSA key sent by the remote host is
ERROR: SHA256:Ly2qQIR34xDh1mAqLxW6PA28I7DX4TGOsMRZTIAKlpE.
ERROR: Please contact your system administrator.
ERROR: Add correct host key in /root/.ssh/known_hosts to get rid of this message.
ERROR: Offending ECDSA key in /root/.ssh/known_hosts:10
ERROR: ECDSA host key for 150.158.x.x has changed and you have requested strict checking.
ERROR: Host key verification failed.

解决方案:删除known_hosts文件或者删掉文件内的x.x.x.x访问记录

bash
rm -rf /root/.ssh/known_hosts

「同一座教堂,三十种光线。」