CentOS 7 使用 Cockpit

Cockpit 是一个 Red Hat 赞助的开源项目,它是一个网页式用户界面,让用户可以通过浏览器来管理和监控Linux 服务器。除了一些常规的系统操作外,Cockpit 还支持 Docker、Kubernetes和KVM。 通过Cockpit Web UI可以轻松启动容器、管理存储、配置网络和检查日志。

安装过程如下:

yum install -y epel-release
yum clean all
yum makecache fast
yum install -y cockpit cockpit-dashboard cockpit-storaged cockpit-packagekit
systemctl enable cockpit.socket
systemctl start cockpit.socket

开启防火墙

firewall-cmd --permanent --add-service=cockpit
firewall-cmd --reload

管理 docker / k8s

yum install -y cockpit-docker cockpit-kubernetes

管理虚拟机

yum install -y cockpit-machines libvirt virt-install

安装完后访问服务器 9090 端口即可。

linux 设置时间

方法1

手动设置

date -s "20201204 13:50:00"
hwclock --systohc

网络校时

需要允许 udp/123 端口访问外网

ntpdate ntp.aliyun.com
hwclock --systohc

国内授时服务器

#NTP服务器
cn.ntp.org.cn
ntp.aliyun.com
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com

#Time服务器
time1.aliyun.com
time2.aliyun.com
time3.aliyun.com
time4.aliyun.com
time5.aliyun.com
time6.aliyun.com
time7.aliyun.com

方法2

timedatectl set-time 15:58:30
timedatectl set-time 20151120
timedatectl set-time '16:10:40 2015-11-20'

windows 自动启动全屏浏览器打开指定网页

创建 bat 文件,如 run.bat,将 bat 放到开始菜单启动组中即可。

chrome 浏览器

start chrome.exe --kiosk "http://www.baidu.com/"

360 浏览器

start 360chrome.exe --kiosk "http://www.baidu.com/"

edge 浏览器

start msedge.exe --kiosk "http://www.baidu.com/" --edge-kiosk-type=fullscreen

附 win10 & win11 启动菜单位置:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

debian 设置静态 IP

编辑配置文件:

vim /etc/network/interfaces

参考以下配置:

auto ens18                  # 添加该行
allow-hotplug ens18
iface ens18 inet static     # 改这里
address 192.168.188.40      # 添加该行和以下行
netmask 24
gateway 192.168.188.1
nameservers 114.114.114.114

sed 替换的用法

第一个aa替换为bb

sed -i 's/aa/bb/' file

所有aa替换为bb

sed -i 's/aa/bb/g' file

文件第3行的aa替换为bb

sed -i '3s/aa/bb/' file

找出包含xxx的行,并将其中的aa替换为bb

sed -i '/xxx/s/aa/bb/g' file

文件第1行,将其中的#号或是*号替换为fff

sed -i '1s/[#*]/fff/gp' file

firewall-cmd 常用操作

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --permanent --zone=public --remove-port=80/tcp

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.188.222" port protocol="tcp" port="3306" accept"
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address=" 192.168.1.100" port protocol="tcp" port="3306" accept"

firewall-cmd --reload

nginx 代理 gitlab 时的 413 问题

git push 时出现:

Counting objects: 80, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (75/75), done.
fatal: The remote end hung up unexpectedly
Writing objects: 100% (80/80), 42.70 MiB | 12.01 MiB/s, done.
Total 80 (delta 47), reused 0 (delta 0)
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
Everything up-to-date

可以先尝试

git config --global http.postBuffer 524288000

同时检查 nginx 配置,在 nginx.confhttp 中添加:

client_max_body_size 100m;

100m 值取决于报错的大小。