各种记不住的命令
- git 快速上手:git_tutorial.sh
- Python 部分:python-notes.md
Fedora 上自带的是 ibus-intelligentpinyin, 其中 ibus 是一种输入框架,和 fctix5 对应,而 intelligentpinyin 是具体的输入法。 ibus 是 Fedora 上自带的输入框架,这个框架下面的 intelligentpinyin、pinyin、libpinyin、rime 我都试过,ibus 的状态就是——崩溃,各种各样的崩溃,莫名其妙的崩溃,打了一半就只有英文的崩溃,必须切换到英文输入法再切回去才能恢复的崩溃。 为了解决这个问题,可以尝试切换到 fctix5 框架,具体而言,执行下面的命令
sudo dnf install fcitx5-chinese-addons fcitx5-autostart
# 之后手动安装gnome插件:https://extensions.gnome.org/extension/261/kimpanel/
# 重启电脑生效
之后系统应用会多一个“Fctix5 Configuration”,logo 是linux小企鹅,在其中的“Avaliable Input Method”->“简体中文(**)”中有数个输入法
- Pinyin
- Shuangpin、Bingchan、Dianbaoma、Erbi、Wanfeng、Ziranma:我不会用的编码
{
"auto_match_enabled": false,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": "all",
"tab_size": 4
}
Effect: username@hostname:/etc/ssh$ --> username@hostname:ssh$
open ~/.bashrc (or /etc/bachrc or /etc/profile), find PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' or PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ', replace the \w with \W.
How to: Use iptables for port forwarding
将临时文件夹挂载到内存上有助于延长ssd硬盘寿命,但对我来说是更快的进程间传递数据(是的懒惰的我就是用文件读写做 IPC,但是我的文件在内存里呀)
sudo ln -s /usr/share/systemd/tmp.mount /etc/systemd/system/
sudo systemctl enable tmp.mount
之后再确认下df -h应该有一条
tmpfs 7.8G 0 7.8G 0% /tmp
表示/tmp已经成功挂载到 tmpfs(RAM) 了
- 编辑
cat /etc/iproute2/rt_tables仿照已有的格式加入表名,编号不应大于 255 ip route add x.x.x.x via x.x.x.x table xxxip route show table xxx、ip route flush table xxx- 使编辑好的路由表生效
ip rule add table xxx,检查ip rule show
数字运算用双圆括号、double parentheses、Arithmetic Expansion:(()),其他用双方括号[[]],单方括号是垃圾。
不是说自动补全不好,而是经常错,尤其是删除时会多删一个,连括号配对都分不清还是别自动补全了。
解决方法:在 notebook 中运行
from notebook.services.config import ConfigManager
c = ConfigManager()
c.update('notebook', {"CodeCell": {"cm_config": {"autoCloseBrackets": False}}})
# -c copy 表示音频视频和字幕编码都直接复制
# -metadata:s:s:0 language="English" 给字幕一个名字
# -metadata:s:s:0 表示第一个字幕
ffmpeg -i input.mp4 -i subtitles.srt -c copy -metadata:s:s:0 language="English" output.mkv
# -ss 和 -t 开始时间和时长
ffmpeg -i input.mkv -ss 00:00:07 -t 00:00:18 -c:v h264 output.mp4
-
重复执行某一条指令(每 2s 执行一次、每 5s 执行一次)
watch cmd watch -n 5 cmd -
cpu 温度和 gpu 温度,
sed -n '9,11p'是截取 9 至 11 行watch "sensors coretemp-*; nvidia-smi -q -d TEMPERATURE | sed -n '9,11p'" -
树苺派是否低电压, more options at raspberrypi documentation for vcgencmd.
watch vcgencmd get_throttled -
实时网速
iftop
一边开启服务器
iperf -s
另一边连接
iperf -c ip
可选参数:-p指定端口,-u使用 UDP
先测试语法 logrotate -dv /etc/logrotate.d/configfile, 再手动执行 logrotate -fv /etc/logrotate.d/configfile
logrotate --help
-d, --debug Don't do anything, just test and print debug messages
-f, --force Force file rotation
-v, --verbose Display messages during rotation
一些样例配置文件
$ cat /etc/logrotate.d/apt
/var/log/apt/term.log {
rotate 12
monthly
compress
missingok
notifempty
}
$ cat /etc/logrotate.d/dpkg
/var/log/dpkg.log {
monthly
rotate 12
compress
delaycompress
missingok
notifempty
create 644 root root
}
- compress: Old versions of log files are compressed with gzip(1) by default.
- nocompress: Old versions of log files are not compressed.
- delaycompress: Postpone compression of the previous log file to the next rotation cycle. This only has effect when used in combination with compress.
- missingok: If the log file is missing, go on to the next one without issuing an error message. See also nomissingok.
- nomissingok: If a log file does not exist, issue an error. This is the default.
- notifempty: Do not rotate the log if it is empty (this overrides the ifempty option).
- See https://linux.die.net/man/8/logrotate for more info.
注意下面这个命令中的"要建立的快捷方式"是不需要提前建立的,ln会帮你创建
ln -s 已经存在的文件 要建立的快捷方式
rm听起来就好危险,要是不小心把真正存在的数据也删了呢?
unlink 快捷方式
samba 允许链接 Accessing symbolic links through Samba
[global]
follow symlinks = yes
unix extensions = no
wide links = yes
sudo vi /etc/ssh/sshd_config 更改
ClientAliveInterval 60
ClientAliveCountMax 20
其含义是每 60s 服务器测试一下客户端有没有响应,连续 20 次没响应则关闭 session。这样网再差都不会断啦
sudo systemctl stop systemd-resolved.service
sudo systemctl disable systemd-resolved.service
sudo systemctl mask systemd-resolved.service
sudo rm /etc/resolv.conf
sudo vi /etc/NetworkManager/NetworkManager.conf
(add in "[main]") dns=none #NetworkManager will not modify resolv.conf
sudo systemctl restart network-manager.service
See NetworkManager.conf.(5) for other configurations.
sudo systemctl set-default graphical.target
sudo systemctl set-default multi-user.target
vi /etc/systemd/logind.conf
modify: HandleLidSwitch=ignore
systemctl restart systemd-logind
- add to
hosts:127.0.0.1 license.sublimehq.com - add to sublime settings:
"update_check": false
Dump all parameters for all objects
upower -d
Show information about object path
upower -i /org/freedesktop/UPower/devices/battery_BAT0
Edit vim /etc/vim/vimrc (or vim ~/.vimrc) to config vim.
set ts=4
set softtabstop=2 "按退格键的时候退回缩进的长度
set expandtab
set autoindent
尼玛我明明换了,结果别的文件行,碰上 .py 结尾的就给我抽风,草**老子用 nano,nano 就没这些破事,浪费我半小时。
续: nano 真好用,不但不会自动缩进,而且还能高亮显示结尾的空格。一个好的程序应该尽可能好的完成自己的本职工作,别的都不要管。你觉得为用户着想,其实往往是帮倒忙。就好像 vim 搞一堆蛋疼的设置但我根本不想要,想改又改不彻底,这不成 windows 了吗?