Linux相关

scp 使用ipv6 的地址传输文件

1
scp ssr.sh root@\[2001:19f0:5:3135:5400:02ff:fe1d:3cd0\]:/root/

tmux相关快捷键

系统指令

窗口指令

面板指令

滚屏

tmux : PageUp,PageDown
linux普通模式翻屏:shift+PgUp或者shift+PgDn

vim编辑器相关

how-can-i-save-a-file-i-opened-in-vim-as-the-wrong-user

Try the below command

1
:w !sudo tee %

Explanation

:w – write
!sudo – call shell sudo command
tee – the output of write (:w) command is redirected using tee
% – current file name

Windows与linux之间传文件

1
apt-get install lrzsz

之后就rz,选择文件
sz是从linux下载文件到Windows

linux取色器

1
sudo apt-get install gpick

查看剩余磁盘容量

1
df -h
  • 查看某一个目录下的容量
    1
    du -sh 目录

查找指定时间的内容

1
find . -mtime -n   #最后一次修改发生在n天以内,距离当前时间为n*24小时以内

还有就是如果cp -r 一不小心直接把整个文件夹中的内容复制过来了(本应该是复制整个项目的),就可以使用下面的命令来删除

1
find [path]/* -maxdepth 0  -mtime +0 -exec rm -f {} \;

其中: - path: 被删除的文件所在目录

  • -maxdepth 0: 最大深度0,只删除当前目录下
  • -mtime +0: 一天前的文件
  • rm -f {} \; 只删除文件,不提示,如果删除目录使用 rm -rf {} \;1. - 这里是列表文本
  • +n #最后一次修改发生在n+1天以前,距离当前时间为(n+1)*24小时或者更早
  • n #最后一次修改发生在距离当前时间n24小时至(n+1)24 小时
  • eg:
    1
    2
    3
     #### 比如我新建了一个test目录之后将12306中里面的内容cp 12306/* -r test/ 
    #### 之后删除就可以使用
    find ./* -maxdepth 0 -mtime -1 -exec rm -rf {} \;

查看进程

ps -ef | grep tomcat

查找文件包含某些字符(超有用,最近看到的)

原理也是通过任意门(管道符)来操作的

1
2
3
4
find . -name *.xml|xargs grep '字符'
###当然关键部分就是xargs
### 也可以这样用
ls 之类的操作

转换编码(这个可以用unar代替)

iconv -f gb2312 -t utf-8 -c my_database.sql > new.sql #-c表示忽略不能转换的

linux下使用rm一不小心删除文件解决办法

  1. 首先unmount这个文件分区,或者将它设置为只读readonly,防止外界写入
  2. sudo apt-get install extundelete
  3. df 找到分区
  4. extundelete /dev/sdb1 –restore-file hosts [后面这部分可以使用的参数: –restore-files test/] [或者恢复所有: –-restore-all]
  5. 据说使用恢复所有成功率最高,其他的两个很低
0%