Terminal
Powershell
计算Hash
Get-FileHash ($FILE_PATH) -Algorithm [SHA1,SHA256,SHA384,SHA512,MD5,RIPEMD160]| Format-List不使用profile启动
pwsh -NoProfile
screen
screen -S seesion_name
screen -ls
screen -r seesion_namesed
将正则表达式https\?://\S*\.debian\.org匹配到的内容替换为https://mirrors.scau.edu.cn
-i参数表示直接修改文件,若不带这个参数,会把替换结果输出到标准输出。
sed -i 's|https\?://\S*\.debian\.org|https://mirrors.scau.edu.cn|g' /etc/apt/sources.list.d/debian.sources
# 去除全部注释
sed 's|^#.*\S||g' /etc/apt/sources.list 在上述例子中,s表示substitute替换,命令格式为s/原内容/新内容/修饰符,其中上述描述符g表示是全局。
d命令-删除 删除文件第二行
sed '2d' test.txt分割符
sed命令可以使用多种字符当作分割符,分隔符是界定命令和操作内容的。
分隔符可以用 /、|、:、@ 等,只要全程一致即可
awk
du
查看文件夹大小
du -h --max-depth=1Compress
tar
解压tar.gz
tar -xzvf exp.tar.gz
--hlep:
-x , --extract, --get extract files from an archive
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
-v, --verbose verbosely list files processed
-f, --file=ARCHIVE use archive file or device ARCHIVE因此若是要解压.tar.xz
tar -xvf exp.tar.xz
压缩
将~/folder/压缩到archive.tar.gz
tar -czvf archive.tar.gz ~/folder/
--help:
-c, --create create a new archive将~/folder/压缩到archive.tar.xz
tar -cJvf archive.tar.xz ~/folder/
--help:
-J, --xz filter the archive through xz
--lzip filter the archive through lzip
--lzma filter the archive through xz
--lzop filter the archive through lzop
--no-auto-compress do not use archive suffix to determine the compression program
--zstd filter the archive through zstd7z
将~/folder/压缩到archive.7z
7z a archive.7z ~/folder/
7z a archive.7z ~/folder/ -mx0 # 仅存储解压,-o参数输出路径无空格
7z x archive.7z -o./extractedZIP
递归压缩目录
zip -r archive.zip directory/SSH
设置私钥登录 生成密钥对
ssh-keygen -t ed25519
ssh-keygen -t rsa -b 4096
将id_ed25519.pub 或 id_rsa.pub公钥写入下列文件
~/.ssh/authorized_keys
即可使用私钥登录
sshd配置文件
/etc/ssh/sshd_config
Network
指定dns服务器查询命令
dig z.cn @223.5.5.5Tcpdump
Hardware
CommandLineBeauty
Zsh
Oh My ZSH
安装oh my zsh
sh -c "$(curl -fsSL https://install.ohmyz.sh/)"
# 镜像
sh -c "$(curl -fsSL https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"主题
powerlevel10k
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"在配置文件里设置主题
nano ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"重新配置主题配色
p10k configure
插件
zsh-syntax-highlighting 语法提示插件 安装
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 中国用户可以使用下面任意一个加速下载
# 加速1
git clone https://github.moeyy.xyz/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 加速2
git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 加速3
git clone https://gh.api.99988866.xyz/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionszsh-autosuggestions 命令提示插件 安装
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 中国用户可以使用下面任意一个加速下载
# 加速1
git clone https://github.moeyy.xyz/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 加速2
git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 加速3
git clone https://gh.api.99988866.xyz/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightingPowerShell
Oh My Posh
更新到powershell7 https://aka.ms/PSWindows
微软商店搜索oh my posh下载后,修改外观。


修改字体 Oh my posh是基于Nerd fonts开发的,需要使用Nerd字体 https://www.nerdfonts.com/font-downloads
可以使用 JetBrainsMono Nerd Font
主题 首先创建配置文件
if (-not (Test-Path $PROFILE)) {
New-Item -Path $PROFILE -Type File -Force
}打开配置文件
notepad $PROFILE
code $PROFILE # Vscode打开在配置文件中写入
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/atomic.omp.json" | Invoke-Expression主题路径在$env:POSH_THEMES_PATH,通常为C:\Users\<用户名>\AppData\Local\Programs\oh-my-posh\themes
与Conda共存
需要找到主题json配置文件里有"type": "python"字段的。然后添加properties配置,下面是整个块的配置。
{
"background": "#306998",
"foreground": "#FFE873",
"leading_diamond": "\ue0b6",
"style": "diamond",
"template": "\ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}",
"trailing_diamond": "\ue0b4 ",
"type": "python",
"properties": {
"display_mode": "environment",
"fetch_virtual_env": true,
"home_enabled": true
}
},完整$PORFILE
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "C:\Users\gyl-sec\miniconda3\Scripts\conda.exe") {
(& "C:\Users\gyl-sec\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
#endregion
$env:VIRTUAL_ENV_DISABLE_PROMPT=1
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/atomic.omp.json" | Invoke-Expression