共有 274 篇文章
Fail2ban
2023-05-11 - 2024-09-18

安装 Fail2ban

1apt-get install fail2ban

Fail2ban 默认启用 ssh 的过滤器,可以在 /etc/fail2ban/jail.conf 查看,但是 Fail2ban 更新会覆盖此文件,建议复制一个 jail.local 进行编辑。

1cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

此后建议编辑 jail.local

对于 jail.local,你能找到许多 unit

vmdk for ESXi
2023-05-05 - 2024-09-18

开启SSH

管理 -> 服务 -> TSM-SSH

使用SSH登录到ESXI

修改的固件vmdk大小

1cd /vmfs/volumes/datastore1
2ls *.vmdk
3vmkfstools -i openwrt.vmdk 123.vmdk
4vmkfstools -X 1024M 123.vmdk # 需大于源文件大小

添加硬盘

根据实际情况选择EFI或BIOS引导

Resize Partition
2023-05-04 - 2024-09-18

1.卸载磁盘

1umount  -l  /data

若提示磁盘忙,使用fuser找出将正在使用磁盘的程序并结束掉。

1fuser -m -v /data
2fuser -m -v -i -k /data

2.磁盘分区

使用fdisk命令重新调整磁盘分区大小

1fdisk -l
2fdisk /dev/sdb
1p #查看磁柱号 ,记住,后面要用到
2d #删除之前的分区
3n #建立新分区
4p #主分区
51 #第一个主分区

删除之前的分区,然后建立新分区,注意开始的磁柱号要和原来的一致(保证数据不丢失的关键步骤),结束的磁柱号默认回车使用全部磁盘。

增加SWAP分区
2023-05-04 - 2024-09-18

一般来说可以按照如下规则设置swap大小:

  • 4G以内的物理内存,SWAP 设置为内存的2倍。
  • 4-8G的物理内存,SWAP 等于内存大小。
  • 8-64G 的物理内存,SWAP 设置为8G。
  • 64-256G物理内存,SWAP 设置为16G。

实际上,系统中交换分区的大小并不取决于物理内存的量,而是取决于系统中内存的负荷,所以在安装系统时要根据具体的业务来设置SWAP的值。

无法删除网络驱动器:此网络连接不存在
2023-03-28 - 2024-09-18
  1. 单击 “开始”,指向 “运行”,键入 regedit,然后单击 “确定”。
  2. 在注册表编辑器中,找到以下注册表子项: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
  3. 右键单击要删除的映射驱动器。 例如,右键单击 ##Server_Name#Share_Name,然后单击 “删除”。
Music Player Control
2023-03-22 - 2024-09-18

通过命令行控制软件的声音

安装

1sudo apt install playerctl

使用

控制当前

1playerctl play
2playerctl pause
3playerctl play-pause  # toggle
4playerctl stop
5playerctl next
6playerctl previous
7playerctl volume

控制指定软件

获取软件列表

1playerctl status -l

控制指定软件,如网易云音乐

Fstab
2023-03-08 - 2024-09-18

系统挂载的一些限制

  • 根目录/是必须挂载的,而且一定要先于其他mount point被挂载进来。
  • 其他挂载点必须为已新建的目录,可任意指定,但一定要遵守必需的系统目录架构原则
  • 所有挂载点在同一时间之内,只能挂载一次
  • 所有分区在同一时间内,只能挂载一次
  • 如若进行卸载,必须先将工作目录移到挂载点(及其子目录)以外。

/etc/fstab(file system table)

 1# <file system> <mount point>   <type>  <options>       <dump>  <pass>
 2# / was on /dev/sda2 during installation
 3UUID=0b15699d-6b0c-4c41-91e8-b2a5fe113366 /               ext4    errors=remount-ro 0       1
 4# /boot/efi was on /dev/sda1 during installation
 5UUID=DBF9-FECA  /boot/efi       vfat    umask=0077      0       1
 6# swap was on /dev/sda3 during installation
 7UUID=2126dcda-b478-4b0f-bfc6-a29189440e46 none            swap    sw              0       0
 8
 9LABEL=HHD1 /HHD1 ext4 noexec 0 2
10LABEL=HHD2 /HHD2 ext4 noexec 0 2
11LABEL=PHHD1 /PHHD1 ext4 noexec 0 2

语法

[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]

Unreal mode
2023-02-27 - 2024-09-15
AOS
Unreal mode consists of breaking the 64KiB limit of real mode segments (while retaining 16-bit instructions and the segment * 16 + offset addressing mode) by tweaking the descriptor caches.
AOS32 显示中文字符GB2312
2023-02-27 - 2025-03-26

aos32-gb2312.tgz

一个GB2312汉字是由两个字节编码的,范围为A1A1~FEFE。A1-A9为符号区,B0到F7为汉字区。每一个区有94个字符。

点阵结构

从图片可以看出:

  • 日文编码的第一个字节为点阵的左半部分,第二个字节为点阵的右半部分。

日文EUC

Mathtex
2023-02-27 - 2024-09-18

https://www.mediawiki.org/wiki/MediaWiki_and_LaTeX_on_a_host_with_shell_access

安装TexLive,使用 which latex 和 which dvipng 检查是否安装

按照注释中操作

 1<?php
 2# Place this file in extension directory as Mtag.php
 3# Add the following line to LocalSettings.php:
 4# include './extensions/Mtag.php';
 5# Mediawiki will render as LaTeX the code within <m> </m> tags.
 6
 7$wgExtensionFunctions[] = "wfMtag";
 8
 9function wfMtag() {
10    global $wgParser;
11    $wgParser->setHook( "m", "returnMtagged" );
12}
13
14function returnMtagged( $code, $argv) {
15# if you have mathtex.cgi installed:
16    $txt='<img src="/cgi-bin/mathtex.cgi?'.$code.'">';
17# OR if you want to temporarily test a public mathtex.cgi:
18#    $txt='<img src="http://www.forkosh.com/mathtex.cgi?'.$code.'">';
19
20    return $txt;
21}
22?>

下载并解压 Mathtex.zip

https://via.akvicor.com/file?f=1241

Data Structure Alignment
2023-02-27 - 2024-09-15
C

The CPU in modern computer hardware performs reads and writes to memory most efficiently when the data is naturally aligned, which generally means that the data’s memory address is a multiple of the data size. For instance, in a 32-bit architecture, the data may be aligned if the data is stored in four consecutive bytes and the first byte lies on a 4-byte boundary.

If the highest and lowest bytes in a datum are not within the same memory word the computer must split the datum access into multiple memory accesses. This requires a lot of complex circuitry to generate the memory accesses and coordinate them. To handle the case where the memory words are in different memory pages the processor must either verify that both pages are present before executing the instruction or be able to handle a TLB miss or a page fault on any memory access during the instruction execution.