点击数:669
- Linux本地和服务端拷贝文件
拷贝文件(从本地拷贝到远程):
scp local_file remote_username@remote_ip:remote_folder 或者 scp local_file remote_username@remote_ip:remote_file 或者 scp local_file remote_ip:remote_folder 或者 scp local_file remote_ip:remote_file
拷贝目录:
scp -r local_folder remote_username@remote_ip:remote_folder 或者 scp -r local_folder remote_ip:remote_folder
拷贝文件(从远程拷贝到本地):
与上述命令类似,调换参数的位置即可,如:
scp root@1.1.1.1:/home/root/others/music /home/space/music/1.mp3
注:使用scp命令要确保使用的用户具有可读取远程服务器相应文件的权限,否则scp命令是无法起作用的。
- chattr / lsattr
之所以说到这个命令,是由于前几天,公司电脑被人用来挖矿了。。顺便说下原因貌似是因为redis没有设置密码。具体的原因没有详细了解,现象是出现了三个跑满CPU的进程:systemupdate 和 networkservice。
在删除文件的过程中发现用root用户竟然无法删除启动上述进程的脚本,后来搜索一番才发现除了用户组的权限控制之外,在Linux系统上还有个 chattr
命令可以对一些重要文件设置属性,这样即使是 root 用户也无法删除或修改。
chattr
命令的用法:chattr [-pRVf] [-+=aAcCdDeijPsStTu] [-v version] files…
(Ubuntu 18.0)operator
: +
: 添加属性; -
:删除属性 =
:保持属性
几个重要的参数 :a
:让文件或目录仅供追加(append)模式。A
:不更新文件或目录的最后存取时间。i
:文件不能被修改、移动、创建链接,只有超级用户可以取消该属性。S
:即时更新文件或目录。u
:预防意外删除,可以恢复文件内容。
用例:

查看文件的属性: lsattr
:

e
attribute indicates that the file is using extents for mapping the blocks on disk. (不是很懂这个属性,但是默认都有这个属性) 设置属性:
chattr +i important.conf
chattr +i demo/
再次查看:

尝试删除:

去除属性:
chattr -i important.conf
chattr -i demo/
即可正常删除
- journalctl
查看系统日志
journalctl –since 2020-06-17 –until 2020-06-18
从时间点到时间点
- tput rmcup
有时候在切换代理之后,滑动鼠标,或者使用上下左右键盘的时候会在*UNIX 终端,通常发生在vi等文本编辑或者显示(tail -f 命令等)的时候会产生一些奇怪的字符,入鼠标上下滑动,会产生:^[OA^[OB^ 这类字符。 好像是叫做 ‘cursor addressing’ mode。
可以通过命令:tput rmcup
手动关掉。
参考:https://www.igorkromin.net/index.php/2016/05/05/mouse-wheel-displaying-control-characters-in-a-terminal-or-scrolling-through-history-instead/
- gsettings set org.gnome.shell.extensions.dash-to-dock click-action ‘minimize-or-previews’
设置Ubuntu gnome 桌面的dock应用图标的点击响应方式。可选的包括:

minimize-or-preview
会在应用只有一个窗口时单击打开或最小化,在多个的时候则会出现预览窗格,进行选择。
留言