comparing ubuntu with centos in package management

yum

1
2
3
4
5
6
7
8
9
10
11
12
# find which package the cmd 'a.out' belongs to
yum provides */bin/a.out
# check if 'wget' package is installed
yum list installed | grep wget
# download 'wget' package to /tmp/rpm/
yum install yum-plugin-downloadonly
yum download --downloaddir=/tmp/rpm/ --downloadonly wget
# list all files in 'wget' package
rpm -qlp /tmp/rpm/wget*.rpm
# another method listing files without downloading
yum install yum-utils
repoquery -l wget

apt

1
2
3
4
5
6
# find which package 'Python.h' belongs to
apt install apt-file
apt-file update
apt-file search Python.h
# list all files in 'wget' package
dpkg -L wget

package names

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  ubuntu			  centos
install build-essential		groupinstall "Development tools"
xfce4				@xfce-desktop
ssh				openssh-clients
udev				systemd-udev
libc6-dev			glibc-devel
libglib2.0-dev			glib2-devel
libffi-dev			libffi-devel
libncurses5			ncurses
libncurses5-dev			ncurses-devel
libsqlite3-dev			sqlite-devel
libnet1-dev			libnet-devel
libreadline6			readline
bridge-utils			bridge-utils
libpcre3-dev			pcre-devel
libyaml-dev			libyaml-devel
libmagic-dev			file-devel
liblua5.1-0-dev			lua-devel
libssl-dev			openssl-devel
zlib1g-dev			zlib-devel
lm-sensors			lm_sensors
ifenslave			iputils
ntpdate				ntp
redis-server			redis
libperl-dev			perl-devel
libjpeg-turbo8-dev		libjpeg-turbo-devel
libfreetype6-dev		freetype-devel
iproute2			iproute
iputils-ping			iputils
ifupdown			NetworkManager
net-tools			net-tools
libpython3.8-dev		python3-devel
mysql-server			mysql5-server
libmysqlclient-dev		mysql5-devel
tofrodos			dos2unix
				kernel-headers
				kernel-devel
qemu-user-static
initramfs-tools
gcc-5-plugin-dev
build-essential
libprelude-dev
libzmq3-dev
libhtp-dev
fbset				maybe in xorg-x11-server

deprecated in ubuntu

1
2
sysv-rc-conf
libjpeg-dev # why?

refer to:
https://blog.csdn.net/mimosa2008/article/details/102833837
https://forums.centos.org/viewtopic.php?t=14711
https://blog.csdn.net/xldwhj/article/details/72831674
https://www.cnblogs.com/orcl-2018/p/13276558.html
https://blog.csdn.net/HAOMCU/article/details/7268687
https://mirrors.tuna.tsinghua.edu.cn/help/fedora/

switch between shell and anaconda in serial console

as are indicated at the bottom of the console, there are 5 windows in anaconda, we can toggle any of them by press:

<Ctrl> + <b> + <window number>

in a tmux style.

refer to:
https://docs.centos.org/en-US/centos/install-guide/Trouble-x86/
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-consoles-logs-during-installation-x86

automatic disk performance test

mkdir like test_case1, copy three files below in it:

test_case1/test.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/python3
import os
 
def shell_run(name, cmd):
	os.system('mkdir result')
	os.system(cmd + '> ./result/' + name)
 
def run_cmds(cmds):
	for name, cmd in cmds.items():
		shell_run(name, cmd)
 
cmds = {
	'1_small_read'		: 'fio -name iops -rw=read -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_small_randread'	: 'fio -name iops -rw=randread -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_small_write'		: 'fio -name iops -rw=write -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_small_randwrite'	: 'fio -name iops -rw=randwrite -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_big_read'		: 'fio -name iops -rw=read -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_big_randread'	: 'fio -name iops -rw=randread -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_big_write'		: 'fio -name iops -rw=write -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'1_big_randwrite'	: 'fio -name iops -rw=randwrite -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1',
	'4_small_read'		: 'fio -name iops -rw=read -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_small_randread'	: 'fio -name iops -rw=randread -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_small_write'		: 'fio -name iops -rw=write -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_small_randwrite'	: 'fio -name iops -rw=randwrite -bs=4k -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_big_read'		: 'fio -name iops -rw=read -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_big_randread'	: 'fio -name iops -rw=randread -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_big_write'		: 'fio -name iops -rw=write -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4',
	'4_big_randwrite'	: 'fio -name iops -rw=randwrite -bs=10M -runtime=60 -iodepth 32 -filename /dev/sda6 -ioengine libaio -direct=1 -numjobs=4'
}
run_cmds(cmds)

test_case1/parse.cpp

Read more

罗马历史年表

罗马时期

罗马十二主神
	Diana/Dĭāna: 狄安娜/月亮与橡树女神/Artemis、赫卡忒、腓尼基神话的刻勒斯塔女神
Janus: 雅努斯/门神
Somnus: 索莫纳斯/睡神
Bellona: 贝罗纳/战争女神/Mars之妻/Enyo

Flora: 芙罗拉/克罗丽丝/花神
Zephyr: 西风之神

Gaul: 高卢

努米托/兄弟阿穆利乌斯
	雷亚西尔维亚/女祭司/维斯太贞女/被阿穆利乌斯丢弃

Mars: 马尔斯/战神
	Remus: 莱姆斯/雷亚西尔维亚之子
	Romulus: 罗慕路斯/雷亚西尔维亚之子/杀兄成战神奎里纳斯

Lupin: 狼人

Alexander the Great: 亚历山大/前356-前323

Carthage: 迦太基/前8世纪-前146年
	Hannibal Barca: 汉尼拔_巴卡/前247-前183

Gaius Julius Caesar: 恺撒/前100-前44
Spartacus: 斯巴达克斯/前69

Nero: 尼禄/37-68/
Decius: 德修/249-251/全国性地迫害基督教
Constantine the Great: 君士坦丁一世/272-337/第一位信仰基督教的皇帝
Theodosius I: 狄奥多西一世/347-395/330年将帝国一分为二/393年宣布基督教为国教
	西罗马/476年在蛮族的侵袭下灭亡
		800年罗马教宗里奥三世为查理曼大帝加冕
		814-858,Pope Joan/约翰娜/女教皇
	Byzantine Empire: 拜占廷帝国/395-1453/东罗马/东正教
		Julia: 尤利安/361-363/apostate
		希拉克略/620年定希腊语为官方语言
		726年利奥三世下令捣毁帝国境内所有圣象
		查士丁尼/将北非以西、意大利和西班牙的东南并入版图,554年击败法兰克王国
		1054年天主教和东正教大分裂
		1095年穆斯林再度兵临城下,东正教向天主教求救,罗马教宗乌尔班二世发起了第一次十字军东征
		1204年首都君士坦丁堡被第四次十字军东征洗劫

Ammonius Saccas: 阿摩尼阿斯 萨卡斯/175-242
	Plotinus: 普罗提诺/204-269/新柏拉图主义

Philo Judeaus: 斐洛尤迪厄斯/前15-40
Pantaenus: 潘代诺
	Titus Flavius Clemens: 革利免/150-215/
		Origenes Adamartius: 俄利根/185-254/

Athanasius: 296-373
Theophilus: 提阿非罗/391/
	Cyril: 西里尔/375-444/

Theon: 赛翁
	Hypatia/: 希帕蒂娅/370-415/
		Orestes: 奥瑞斯特斯/Alexandria总督
		Synesius of Cyrene: 辛乃西斯

希波的奥古斯丁/Augustine of Hippo/354-430

Damascius: /逃亡波斯

1265-1321	Dante Alighieri/但丁·阿利吉耶里

1479-1555	Juana/胡安娜/西班牙女王

?-1557		塔塔尼亚/口吃
			卡尔丹诺/三次方程一般解/令y = x + (a over 3)/给自己算死期不准,自杀
			费拉里/四次方程一般解

1776-1856	Ameldeo Avogadro/阿伏伽德罗

			开普勒/死在讨薪

1824		阿贝尔/Norway/无钱出论文/肺结核

Carthagia: 迦太基

Punic Wars: 布匿战争
巴卡家族
	汉尼拨

圣经

莎乐美和圣约翰
约阿施
	Gideon: 吉迪恩
印第安人

大航海

1452-1506	Columbus/哥伦布
1480-1521	Ferdinand Magellan/麦哲伦

refer to:
闲时乱翻书

德国历史年表

Prussia 普鲁士

1
2
3
4
5
1224		Deutscher Orden 条顿骑士团建国
1512		Albrecht von Brandenburg-Ansbach 阿尔布雷希特
1483-1546	Martin Luther 马丁_路德
 
1712-1786	Friedrich II 腓特烈二世/七年战争

Austria 奥地利
Hungary 匈牙利
Bohemia 波希米亚 = Czech 捷克
Bavaria 巴伐利亚 = Bayern 拜仁

1
2
3
4
5
1576-1612	Rudolf II/欧洲三十年战争
1717-1780	Maria Theresa 玛丽亚_特蕾莎/Franz Stephan 弗朗茨_斯蒂芬之妻
			Marie Antoinette 玛丽_安托瓦内特/路易十六王后
1837-1898	Elisabeth Amalie Eugenie 茜茜公主/被刺杀
1863-1914	Archduke Franz Ferdinand of Austria 弗朗茨·斐迪南大公/茜茜公主之侄/被Gavrilo Princip刺杀的萨拉热窝事件

二战

1
2
3
4
193910月		纳粹完全占领波兰/盖世太保搜杀波兰精英人士/卡廷惨案
1943年初		德军在斯大林格勒战役中惨败
1943419日		华沙犹太人起义
194481日		华沙起义/避免波兰被苏联赤化

沙俄

1
2
3
4
5
彼得一世
Catherine I 叶卡捷琳娜一世
安娜女皇
伊丽莎白女皇
叶卡捷琳娜二世

refer to:
杨藩讲艺术
黄娜老师
https://baike.baidu.com/item/%E5%8D%8E%E6%B2%99%E8%B5%B7%E4%B9%89/13013998

how to turn off fans in linux

after running 'sensors-detect' command, kernel modules controlling fan speed should be loaded.

here is an occasion with 'Nuvoton NCT6102D/NCT6104D/NCT6106D Super IO Sensors' detected.

as nct6775 document said:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#/sys/class/hwmon/hwmon4
pwm[1-7]
    - this file stores PWM duty cycle or DC value (fan speed) in range:
	   0 (lowest speed) to 255 (full)
 
pwm[1-7]_enable
    - this file controls mode of fan/temperature control:
	* 0 Fan control disabled (fans set to maximum speed)
	* 1 Manual mode, write to pwm[0-5] any value 0-255
	* 2 "Thermal Cruise" mode
	* 3 "Fan Speed Cruise" mode
	* 4 "Smart Fan III" mode (NCT6775F only)
	* 5 "Smart Fan IV" mode
...

ps1. if set pwm[1-7]_enable to 0, we will not be able to change it to other value, unless reboot linux.
ps2. I still can't find a common way to turn off fans using ipmitool.

IPMI: Intelligent Platform Management Interface
BMC: Baseboard Management Controller
FRU: Field Replaceable Unit

refer to:
[linux-kernel-src-root]/Documentation/hwmon/nct6775.rst
https://bbs.archlinux.org/viewtopic.php?id=225349

c++ move forward

lvalue: loactor value
rvalue: read value

here is an example of class definition with only one constructor using template and 'forward' technique to tackle varying parameter:

rvalue.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <functional>
 
using namespace std;
 
template <typename T>
constexpr bool is_lvalue(T&) {
	return true;
}
 
template <typename T>
constexpr bool is_lvalue(T&&) {
	return false;
}
 
class MyStr
{
public:
	template<class T>
	MyStr(T&& t)
	{
		set(forward<T>(t));
	}
	template<class T>
	void set(T&& t)
	{
		if constexpr (conjunction_v<is_convertible<T&, MyStr&>>)
		{
			if (!is_lvalue(forward<T>(t)))
			{
				str_ = forward<string>(t.str_);
				cout << "is rvalue, type MyStr." << endl;
			}
			else
			{
				str_ = t.str_;
				cout << "is lvalue, type MyStr." << endl;
			}
		}
		else
		{
			str_ = forward<T>(t);
			cout << "is string." << endl;
		}
	}
	template<class T=char>
	void test()
	{
		cout << "test T size is " << sizeof(T) << endl;
	}
	string str_;
};
 
int main()
{
	cout << "call constructor:" << endl;
 
	MyStr str1("str1");
	MyStr str2(str1);
	MyStr str3(move(str1));
 
	cout << "call member function:" << endl;
 
	str1.set("set1");
	str2.set(str1);
	str3.set(move(str1));
 
	str3.test();
 
	return 1;
}

make

1
g++ -o rvalue -g -O0 -std=c++17 rvalue.cpp

output

1
2
3
4
5
6
7
8
call constructor:
is string.
is lvalue, type MyStr.
call member function:
is string.
is lvalue, type MyStr.
is rvalue, type MyStr.
test T size is 1

refer to:
http://www.javashuo.com/article/p-olwxiggw-q.html
http://c.biancheng.net/view/7829.html
https://zhuanlan.zhihu.com/p/99524127