plantuml常用汇总
linux 上中文文字层叠现象
ubuntu
sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy
centos
sudo yum install -y wqy-microhei-fonts
sudo yum install -y adobe-source-han-sans-cn-fonts
sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy
sudo yum install -y wqy-microhei-fonts
sudo yum install -y adobe-source-han-sans-cn-fonts
linux 字体安装
1.将字体下载并拷贝到对应文件夹中,并进入字体文件夹
cp *.ttf /usr/share/fonts
cd /usr/share/fonts
2.字体安装器
sudo apt install ttf-mscorefonts-installer
# (创建字体的fonts.scale文件,它用来控制字体旋转缩放)
sudo mkfontscale
# (创建字体的fonts.dir文件,它用来控制字体粗斜体产生)
sudo mkfontdir
3.建立字体缓存
sudo apt install fontconfig
# 建立字体缓存信息
sudo fc-cache -fv
# 查看已经安装的
fc-list
https://github.com/ohmyzsh/ohmyzsh
https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
1.zsh-autosuggestions 自动补全插件
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
2.高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
3.autojump
sudo apt-get install autojump
plugins=(
git
z
autojump
zsh-autosuggestions
zsh-syntax-highlighting
sudo
)
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
https://github.com/romkatv/powerlevel10k
如果使用 EPEL 存储库中的 dnf 安装 Git 仍然无法得到最新版本的 Git,您可以考虑从源代码编译安装 Git。以下是在 CentOS 7 上编译安装最新版本 Git 的步骤:
打开终端并使用 root 用户登录系统。
安装必需的编译工具和依赖项:
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y
前往 Git 官网的下载页面(https://git-scm.com/downloads) 并找到最新版本的 Git。复制该版本的下载链接。
在终端中使用以下命令下载 Git 的源代码压缩包(请将命令中的 URL 替换为第 3 步中复制的下载链接):
curl -LO https://github.com/git/git/archive/refs/tags/v2.40.1.tar.gz
tar xzf *.gz
cd git-*
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo 'export PATH=$PATH:/usr/local/git/bin' >> ~/.bashrc
source ~/.bashrc
git --version
如果 Git 版本号显示为最新版本,则表示 Git 已经成功安装在 CentOS 7 上。请注意,由于 CentOS 7 默认使用较旧的软件版本,因此您可能需要升级其他依赖项来满足 Git 的要求。如果在编译过程中遇到任何问题,请检查错误消息并尝试解决它们。
windows git 上有分支名称,一下加入可让 linux 也支持分支名称
vim ~/.bashrc
function git-branch-name {
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s] " $branch; fi
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(git-branch-prompt)\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(git-branch-prompt)\$ '
fi
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1="\[\033[36m\]\u@\h\[\033[m\]:\[\033[32m\]\w\[\033[m\]\$(parse_git_branch)\$ "
vim /home/[username]/.gitconfig
[color]
status = auto
diff = auto
ui = true
interactive = auto
branch = auto
修改后立马生效
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.ui true
git config --global color.interactive auto
git remote -v
本地建立仓库,远程后建立,拉取时会失败,使用以下命令强制拉取
git pull <远程仓库地址> -allow-unrelated-histories
git branch --set-upstream-to=origin/<远程分支名称>
git push origin --delete origin/<远程分支名称>
git reset --hard <commit>
// 方式1
git push origin HEAD --force
// 方式2
git push --force
git revert <commit> // 回退作为一个动作保留
git push // 这样作为一个同步提交不会造成服务器的冲突了
git remote set-url origin 【url】
或者
git remote remove origin
git remote add origin【url】
git clone -b <branch> <remote_repo>
fetch <仓库路径>
git cherry-pick <版本号> # 也可以是分支名称
$ git tag
$ git tag -a v1.0 -m "xxx"
```\ $ git tag -l "v1.0*"
#### 3.4 显示对应标签所有信息
#### 3.5 删除标签
## git submodule
### 添加子模块
```sh
git submodule add <submodule> <path>
git submodule update --init --recursive
git submodule deinit <path>
git rm <path>
如果已经update 了,还要删除 .git里面module的对应内容
先删除再添加
git 1.8.5 之后新增, 建议先删除再新增子模块
git mv {oldPath} {newPath}
# 如果要更换submodule 名称与 path 一致
mv .git/modules/{oldPath} .git/modules/{newPath}
nvs 详细安装可以去 github:
https://github.com/jasongin/nvs
如果使用 git base 环境, 在 ~/.bash_profile 加入以下命令
export NVS_HOME=$LOCALAPPDATA/nvs
. $NVS_HOME/nvs.sh
如果为wsl环境, 如果windows中无nvs环境可跳过此步骤
vim ~/.bashrc
在文件末尾加入,排出windows nvs 环境变量, 具体路径参考自己 windows 的 nvs 环境
export PATH=$(echo $PATH | sed -e 's;:/mnt/c/Users/<user>/AppData/Local/nvs/default;;' -e 's;:/mnt/c/Users/<user>/AppData/Local/nvs/;;')
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
推荐直接使用 pnpm 替代
pnpm config set prefix ~/.npm-global
配置到环境变量到 ~/.bashrc, windows类似在系统配置中添加
export PATH=~/.npm-global/bin:$PATH
查看 remote
nvs remote
配置镜像地址
nvs remote node https://npmmirror.com/mirrors/node/
pnpm i
都会直接卡死解决方式: 1. 配置虚拟内存 2. 调整内核参数
在 Linux 系统中,可以通过调整内核参数来加快内存回收,从而提高系统的性能和响应速度。以下是一些常用的内核参数及其调整方法:
默认值:60 调整建议: 降低值:如果希望系统尽量减少使用 Swap,可以将 vm.swappiness 设置为较低的值,例如 10 或 20。 提高值:如果希望系统更积极地使用 Swap,可以将 vm.swappiness 设置为较高的值,例如 80 或 100。
# 临时调整
sudo sysctl vm.swappiness=10
# 永久调整(编辑 /etc/sysctl.conf)
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
默认值:100 调整建议: 降低值:如果希望系统保留更多的文件系统缓存,可以将 vm.vfs_cache_pressure 设置为较低的值,例如 50。 提高值:如果希望系统更积极地回收文件系统缓存,可以将 vm.vfs_cache_pressure 设置为较高的值,例如 150。
# 临时调整
sudo sysctl vm.vfs_cache_pressure=50
# 永久调整(编辑 /etc/sysctl.conf)
echo "vm.vfs_cache_pressure=50" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
vm.dirty_ratio:脏页占总内存的最大百分比。超过此值时,系统会开始同步脏页到磁盘。
vm.dirty_background_ratio:脏页占总内存的背景阈值。超过此值时,系统会开始异步同步脏页到磁盘。
默认值:
vm.dirty_ratio:20 vm.dirty_background_ratio:10 调整建议:
降低值:如果希望系统更频繁地同步脏页,可以将这两个值设置为较低的值,例如 10 和 5。 提高值:如果希望系统减少同步频率,可以将这两个值设置为较高的值,但需谨慎,以免影响系统稳定性。
# 临时调整
sudo sysctl vm.dirty_ratio=10
sudo sysctl vm.dirty_background_ratio=5
# 永久调整(编辑 /etc/sysctl.conf)
echo "vm.dirty_ratio=10" | sudo tee -a /etc/sysctl.conf
echo "vm.dirty_background_ratio=5" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
值: 1:清除页面缓存 2:清除目录项和inode缓存 3:清除所有缓存
# 清除所有缓存
sudo sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
vm.overcommit_memory:
0:内核根据可用内存和当前使用情况决定是否允许内存过量分配(默认值)。 1:内核总是允许内存过量分配。 2:内核根据 vm.overcommit_ratio 计算允许的最大内存分配量。 vm.overcommit_ratio:当 vm.overcommit_memory 设置为 2 时,此参数表示允许的最大内存分配量占物理内存的百分比。
默认值:
vm.overcommit_memory:0 vm.overcommit_ratio:50 调整建议:
设置为 2:如果希望严格控制内存分配,可以将 vm.overcommit_memory 设置为 2,并调整 vm.overcommit_ratio。
# 临时调整
sudo sysctl vm.overcommit_memory=2
sudo sysctl vm.overcommit_ratio=70
# 永久调整(编辑 /etc/sysctl.conf)
echo "vm.overcommit_memory=2" | sudo tee -a /etc/sysctl.conf
echo "vm.overcommit_ratio=70" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
1.查看硬盘
root@ubuntu:~# fdisk -lu
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x3c78b7a1
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 16777215 16775168 8G 83 Linux
/dev/sda2 16779262 20969471 4190210 2G 5 Extended
/dev/sda5 16779264 20969471 4190208 2G 82 Linux swap / Solaris
Partition 2 does not start on physical sector boundary.
Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
2.创建分区
root@ubuntu:~# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xdf96fde2.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-104857599, default 104857599):
Created a new partition 1 of type 'Linux' and of size 50 GiB.
Command (m for help): p
Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xdf96fde2
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 104857599 104855552 50G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
3.格式化分区
root@ubuntu:~# mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Discarding device blocks: 完成
Creating filesystem with 13106944 4k blocks and 3276800 inodes
Filesystem UUID: c0887faa-eed2-4f38-9f18-6e3059261202
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
4.挂载和查看分区表
root@ubuntu:~# mount /dev/sdb1 /data
root@ubuntu:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 5.5M 389M 2% /run
/dev/sda1 7.8G 1.2G 6.2G 16% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs 395M 0 395M 0% /run/user/0
/dev/sdb1 50G 52M 47G 1% /data
5.永久挂载
# 执行前一定要进行备份,以免误操作
echo '/dev/sdb1 /data ext4 defaults 0 0' >> /etc/fstab
eg: 将 docker lib 目录映射到 /data/lib/docker
echo '/data/lib/docker /var/lib/docker none defaults,bind 0 0'>>/etc/fstab
mount -a
# 打印系统信息
$ uname -a
Linux LAPTOP-2181LTT2 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
# 获取发行版信息
$ cat /etc/issue
Ubuntu 18.04.6 LTS \n \l
$ cat /etc/issue.net
Ubuntu 18.04.6 LTS
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
# 根据上面 ID_LIKE 来获取version
$ cat /etc/debian_version
9.3
# 也可直接通过system 获取(如果有)
$ cat /etc/system-release
9.3
# 获取内核版本
$ cat /proc/version
Linux version 5.4.72-microsoft-standard-WSL2 (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Oct 28 23:40:43 UTC 2020
# dmesg 命令
$ dmesg | grep "Linux"
[ 0.000000] Linux version 5.4.72-microsoft-standard-WSL2 (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Oct 28 23:40:43 UTC 2020
[ 3.522133] ACPI: Added _OSI(Linux-Dell-Video)
[ 3.527064] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[ 3.531431] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
# 其他 Yum/Dnf
$ yum info nano
$ yum repolist
$ dnf info nano
$ apt-cache policy nano
nano:
Installed: 2.9.3-2
Candidate: 2.9.3-2
Version table:
*** 2.9.3-2 500
500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status
1.conf.d/default.conf 默认域名,若没命中,进入此处
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html/default;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
1.conf.d/www.my.com.conf www.my.com 和 my.com 进入会命中
server {
listen 80;
listen [::]:80;
server_name www.my.com my.com;
location / {
root /usr/share/nginx/html/my;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen 80; # 监听 HTTP 请求的端口,可以根据需要更改
server_name files.localhost; # 你的服务器名称或 IP 地址
location / {
alias /files/; # 指定文件存储目录
autoindex on; # 启用自动列出目录内容
autoindex_exact_size off; # 显示文件大小的近似值
charset utf-8;
}
}
htpasswd
文件生成printf "test:$(openssl passwd -crypt 123456)\n" >> /usr/local/nginx-1.5.1/conf/basicauth
server{
listen 80;
server_name auth.localhost;
location / {
root html;
auth_basic "Please enter your username and password";
auth_basic_user_file ../conf/basicauth;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}