kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

ubuntu 16.04 & 18.04

删除snap,snap会自动更新,严重占带宽

1
2
3
4
5
6
7
8
snap list
sudo snap remove gtk-common-themes
...
sudo apt-get remove snapd

df -h | grep snap
sudo systemctl stop snap-core-6350.mount
sudo systemctl disable snap-core-6350.mount

ssh 保持连接

服务端

1
2
ClientAliveInterval 60
ClientAliveCountMax 1

SSH Server 每 60 秒就会自动发送一个信号给 Client,客户端没有回应数超过 ClientAliveCountMax 时,才会断开连接。

客户端

1
2
TCPKeepAlive yes
ServerAliveInterval 300

前一个参数是说要保持连接,后一个参数表示每过5分钟发一个数据包到服务器

命令行进行设定即:

1
ssh -o TCPKeepAlive=yes -o ServerAliveInterval=300 root@1.2.3.4

dns 命令

1
2
3
4
5
6
7
8
9
sudo apt-get install pppconfig
/etc/init.d/dns-clean

systemctl stop systemd-resolved
systemctl start systemd-resolved

systemd-resolve --statistics
systemd-resolve --status
systemd-resolve --flush-caches

代理设置

1
2
3
4
5
6
7
8
9
10
11
12
13
# cat /etc/apt/apt.conf
Acquire::https::Proxy "http://proxy.proxy.com:8080";
# err? http_proxy=http://proxy.proxy.com:8080
# err? https_proxy=http://proxy.proxy.com:8080

# cat /etc/environment
http_proxy=http://proxy.proxy.com:8080
https_proxy=http://proxy.proxy.com:8080
no_proxy=localhost,127.0.0.0/8,::1,*.pp.com,*.oa.com

# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.proxy.com:8080"

amdgpu.dc

VGA,DIV-D接口 4.15.0 以后内核黑屏,需要设置amdgpu.dc=0 HDMI,DP接口支持音频,需要设置amdgpu.dc=1

注释掉下面这行将会显示引导菜单

1
#GRUB_HIDDEN_TIMEOUT=0

设定默认启动项 /etc/default/grub

1
2
3
4
5
6
7
8
9
# 用数字
GRUB_DEFAULT=0

# 最近启动
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

# 指定内核
GRUB_DEFAULT="gnulinux-advanced-999d2fc9-3d7b-4654-a25c-4f5d4472a23b>gnulinux-4.15.0-55-generic-advanced-999d2fc9-3d7b-4654-a25c-4f5d4472a23b"

Warning: Please don’t use old title Ubuntu, with Linux 4.15.0-55-generic' for GRUB_DEFAULT, useAdvanced options for Ubuntu>Ubuntu, with Linux 4.15.0-55-generic' (for versions before 2.00) or `gnulinux-advanced-999d2fc9-3d7b-4654-a25c-4f5d4472a23b>gnulinux-4.15.0-55-generic-advanced-999d2fc9-3d7b-4654-a25c-4f5d4472a23b' (for 2.00 or later)

卸载amazon

1
2
3
4
5
# 16.04
sudo apt-get remove unity-webapps-common

# 18.04
sudo apt-get remove ubuntu-web-launchers

新立得

1
sudo apt-get install synaptic

禁用apport

1
2
/etc/default/apport
enabled=0

禁用service

1
2
3
4
5
6
7
8
9
# 禁用
sudo systemctl disable apport.service

# 如果这不起作用,那么您需要屏蔽该服务
systemctl mask apport.service

# 重新启用
systemctl unmask apport.service # if you masked it
sudo systemctl enable apport.service

中文输入法

1
2
3
sudo apt-get install ibus-pinyin
# 选择全拼模式,同时勾选“简拼”, 然后运行
sudo ibus restart

温度

1
2
3
4
sudo apt-get install lm-sensors hddtemp
sudo sensors-detect
sensors
sudo apt-get install psensor

查看SSD状态

https://www.cnblogs.com/fiberhome/p/8275961.html

1
2
3
4
5
6
7
8
hdparm -t --direct /dev/sda

smartctl -i /dev/sda

sudo smartctl -data -A /dev/sda
sudo smartctl -A /dev/sda

# 233一行的值就是寿命,默认为100,当小于10的时候就要非常注意了。

个人桌面系统可以加 noatime

1
2
3
4
vim /etc/fstab
增加 noatime

stat /etc/fstab

nvme硬盘温度

1
2
3
4
5
6
7
sudo apt-get install nvme-cli
sudo nvme list

sudo nvme smart-log /dev/nvme0
sudo watch -n 1 nvme smart-log /dev/nvme0

sudo nvme smart-log /dev/nvme0 | grep "^temperature"

SSD

1
2
3
4
5
Aggressive LPM Support功能是SATA口的节能电源管理,开启会导致SSD掉盘,不认盘,掉速等问题。

解决方法:

到BIOS中找到Aggressive LPM Support并关闭。

18.04 unity

1
2
3
4
5
6
sudo apt install ubuntu-unity-desktop
select lightdm

# 恢复gnome
sudo apt purge ubuntu-unity-desktop
sudo dpkg-reconfigure gdm3

18.04 用synergy1.6.2

https://packages.ubuntu.com/xenial/libcrypto++9v5

https://packages.ubuntu.com/xenial/synergy

synergy_1.6.2-0ubuntu2_amd64.deb

libcrypto++9v5_5.6.1-9ubuntu0.1_amd64.deb