Tips in Linux

Menu:

Clear apt cache

1
sudo rm -v /var/cache/apt/archives/*.deb

镜像源公钥安装

1
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys # + 公钥名

获取CPU总核心数

1
2
3
echo $(grep -c ^processor /proc/cpuinfo 2>/dev/null)
# use
make -j $(grep -c ^processor /proc/cpuinfo 2>/dev/null)

Linux Console 默认信息

1
2
3
/etc/issue
/etc/update-motd.d/*
/run/motd.dynamic

shell script check permission

1
2
3
4
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root\n"
exit 1
fi

Makefile help menu

1
2
3
4
5
all: help

.PHONY: help
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'