; ~/.tmux.conf
# 启动鼠标支持
set -g mouse on
# WindTerm需在 会话 --> 首选项 --> 设置 --> 终端 --> 鼠标追踪 --> 追踪事件
# 取消勾选:
# - 移动事件
# - 点击事件
# - 右键单击事件
# WindTerm使用鼠标修改面板大小,受WindTerm限制无法实现
# 禁用 WindTerm 的默认鼠标行为(防止冲突)
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# 1. 禁用左键释放自动复制(改为仅选择)
# bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
# 2. 右键复制到系统剪贴板(需先左键选择)
# bind -T copy-mode-vi MouseDown3Pane send-keys -X copy-pipe-and-cancel \
# "xclip -i -selection clipboard 2>/dev/null || pbpaste 2>/dev/null || win32yank.exe -i 2>/dev/null"
# 3. 右键直接粘贴系统剪贴板内容(跨系统支持)
bind -n MouseDown3Pane run-shell \
"tmux set-buffer -- \"$(xclip -o -selection clipboard 2>/dev/null || pbpaste 2>/dev/null || win32yank.exe -o 2>/dev/null)\"; tmux paste-buffer"
# 启动emacs键位支持
set -g mode-keys emacs
# Ctrl+c复制到系统剪贴板
bind -T copy-mode-emacs C-c send-keys -X copy-pipe-and-cancel \
"xclip -i -selection clipboard 2>/dev/null || \
pbpaste 2>/dev/null || \
win32yank.exe -i 2>/dev/null"
# 启动vi键位支持
# set -g mode-keys vi
# 解除默认的鼠标调整绑定(可选)
# unbind-key -T root MouseDrag1Border
# 重新绑定鼠标拖动调整大小
# bind -n MouseDrag1Border resize-pane -M
# status line
set -g status-justify centre
set -g status-left "#{session_name}"
set -g status-right "%F %R"
# 窗口编号自动重新排序
set -g renumber-windows on
# status line > window list
set -g window-status-format "#{window_index}:#{window_name}"
set -g window-status-separator " | "
set -g window-status-current-format "#{window_index}:#{window_name}"
set -g window-status-current-style bold,italics
# pane
set -g pane-border-format " #{pane_index}:#{pane_title} $ #{pane_current_command} "
set -g pane-border-status top
set -g history-limit 10000
# 更新配置,不需要关闭tmux,直接运行马上生效
tmux source-file ~/.tmux.conf
Prefix = Ctrl + b
cat info.log error.log > merge.log.bak
cp merge.log.bak merge.log
WindTerm客户端,取消 “会话设置 -> SSH -> 验证 -> 尝试键盘交互认证” 可已正常连接。
$ apk update
$ apk add openssh-server openssh
; /etc/ssh/sshd_config
# 开放Root登录
- #PermitRootLogin prohibit-password
+ PermitRootLogin yes
# 允许其它用户登录
- #PasswordAuthentication yes
+ PasswordAuthentication yes
# 解决ssh自动断开
- #ClientAliveInterval 0
- #ClientAliveCountMax 3
+ ClientAliveInterval 60
+ ClientAliveCountMax 3
$ rc-service sshd start
$ rc-service sshd restart
# 设置开机启动
$ rc-update add sshd
# 删除开机启动服务
$ rc-update del sshd
# 显示所有服务
# rc-status -a
在 /etc/profile.d 文件夹下,创建sh文件来实现。
已弃用,转到 Tmux 命令
# 离线方式创建屏幕,一般用在启动脚本
$ screen -S <screen_name> -d -m
$ screen -ls
# 在指定屏幕内输入cmd,注意\n代表回车
$ screen -S <screen_name> -X stuff "<cmd>\n"
# 在当前窗口内,通过另一个过滤进程控制窗口的输入或输出。
# 非常复杂,还没有搞明白有什么用
# 官方建议:小心使用!
$ screen -S <screen_name> -X |<cmd>
$ screen -S <screen_name> -X !..|<cmd>
$ screen -S <screen_name> -X exec<cmd>
参考文档
在 screen 终端下,按 Ctrl+a d 键
# 进入指定屏幕,再退出
$ screen -r <screen_name|pid>
$ exit
# 指定屏幕,直接退出
$ screen -S <screen_name> -X quit
systemctl list-units ##列出当前系统服务的状态
systemctl list-unit-files ##列出服务的开机状态
systemctl status sshd ##查看指定服务的状态
systemctl stop sshd ##关闭指定服务
systemctl start sshd ##开启指定服务
systemctl restart sshd ##从新启动服务
systemctl enable sshd ##设定指定服务开机开启
systemctl disable sshd ##设定指定服务开机关闭
systemctl reload sshd ##使指定服务从新加载配置
systemctl list-dependencies sshd ##查看指定服务的倚赖关系
systemctl mask sshd ##冻结指定服务
systemctl unmask sshd ##启用服务
systemctl set-default multi-user.target ##开机不开启图形
systemctl set-default graphical.target ##开机启动图形
$ _hostname_=XXXX
$ hostnamectl --static set-hostname ${_hostname_}
$ hostnamectl --transient set-hostname ${_hostname_}
$ hostnamectl --pretty set-hostname ${_hostname_}
$ timedatectl set-timezone Asia/Shanghai
# 字符串方式
command: /bin/bash -c "cp /app/dtest/config.default.yml /app/config.yml && python -u /app/dtest/tcc.py"
# 另一种方式
command: ["/bin/bash","-c","while","true;","do","sleep","1;","done"]
# 配置文件方式
......
启动后停在cli,等待登录
stdin_open: true # 对应 docker run 中的 -i
tty: true # 对应 docker run 中的 -t
# 查看代理
git config --global --get http.proxy
git config --global --get https.proxy
# 设置代理
git config --global http.proxy http://[username:passwrod@]ip or URL:port
git config --global https.proxy http://[username:passwrod@]ip or URL:port
# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
# 只代理github.com
git config --global --get http.https://github.com.proxy
git config --global --get https.https://github.com.proxy
git config --global http.https://github.com.proxy http://[username:passwrod@]ip or URL:port
git config --global https.https://github.com.proxy http://[username:passwrod@]ip or URL:port
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
# push设置
git config --global push.default simple
git clone https://[email protected]/xxxx/xxxx.git
# or
git clone [email protected]:xxxxx/xxxxx.git
# 克隆指定分支,到指定目录
git clone -b branch_name repo path
git config user.name "Your Name"
git config user.email [email protected]
# 查看远程仓库地址
git remote -v
先在githubh上创建好项目
sed [OPTION] [expression] file
[OPTION]
-n 屏蔽输出
-i 替换模式
-i.bak 替换前先备份文件
-E 使用扩展正则表达式,语法更接近现代正则表达式(如 Perl、Python、JavaScript),代码更清晰易读(去掉了很多反斜杠),减少转义错误
-e 使用表达式,可使用多个表达式
[expression]
s/regular/replace/ 替换命令
0,/regular/s//replace/ 仅替换从文件开头(第 0 行)首次匹配regular成功的内容,只用GNU版本的sed
/regular/replace/g 匹配整行,默认只匹配一次
/regular/replace/d 删除行
/regular/replace/p 打印匹配的行
sed -n '1,2p' file
# 删除空行
sed -i '/^\s*$/d' merge1.log
sed -i '/^$/d' filename.txt # `^$` 匹配空行
# 按行号删除
sed -i '5d' filename.txt # 删除第5行
# 删除最后一行
sed -i '$d' filename.txt # `$` 表示最后一行
# 删除连续行
sed -i '10,20d' filename.txt # 删除第10到20行
# 删除不连续的行
sed -i '5d;10d;15d' filename.txt # 删除第5、10、15行
# 删除包含特定文本的行
sed -i '/pattern/d' filename.txt # 删除含"pattern"的行
# 删除不匹配的行(保留匹配行)
sed -i '/pattern/!d' filename.txt # `!` 表示取反
# 删除以某文本开头/结尾的行
sed -i '/^prefix/d' filename.txt # 删除以"prefix"开头的行
sed -i '/suffix$/d' filename.txt # 删除以"suffix"结尾的行
sed -i 's/.*a2p_replyclient_log.*[infoerror].[0-9].log.gz://' merge.log \
&& sed -i 's/org.springframework.amqp.rabbit.RabbitListenerEndpointContainer.* - //' merge.log \
&& sed -i '/.*send 1 time for the url is .*/d' merge.log \
&& sed -i '/.*redis key:[0-9]*,value:.*/d' merge.log
sed -i '/>>>>.* retry:2/d' 2021.8.log
sed -i 's/the content of the url:.*receiveStatusReportResultChinaMobile.shtml //' 2021.8.log
sed -i 's/\.[0-9]\{0,3\}\( \[\)/\1/' merge.log
sed -i 's/.*\(\[INFO\]\)/\1/' 2021.8.log
sed -i 's/.*\(\[ERROR\]\)/\1/' 2021.8.log
sed -i 's/time:.*,\(is_china_mobile\)/\1/' 2021.8.log
sed -i 's/error for the url//' merge.log
sed -i 's/can not read content from the url//' merge.log
sed -n '/ status:DELIVRD,/p' result.log | wc -l
sed -n '/"originalStatus":"DELIVRD"/p' merge.log | wc -l
awk '!x[$0]++' merge.log
sort -n merge.log | uniq
sudo sed -i 's/\(archive\|security\).ubuntu/mirrors.aliyun/' /etc/apt/sources.list
sed -i 's/^#\(ClientAliveInterval\) 0$/\1 60/g' /etc/ssh/sshd_config
sed -i 's/^#\(ClientAliveCountMax\) 3$/\1 5/g' /etc/ssh/sshd_config
systemctl restart sshd
# sed 参考 http://man.linuxde.net/sed
# https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html
sed ......
# debian
apt install -y systemd-timesyncd
# almalinux
# systemd 是默认安装且无法卸载的核心基础包
# 设置时区
timedatectl set-timezone Asia/Shanghai
# 启动NTP服务
timedatectl set-ntp true
; debian
; /etc/systemd/timesyncd.conf
[Time]
NTP=ntp.ntsc.ac.cn
FallbackNTP=ntp.aliyun.com ntp.tencent.com 0.cn.pool.ntp.org
# debian
# 在LXC、Docker 或某些 VPS 环境中
dpkg-reconfigure tzdata
systemctl stop 'postfix@*' ; systemctl disable 'postfix@\x2a' ;
# debian
apt purge -y postfix
# almalinux
dnf remove -y postfix
[docker|podman] image ls -a
# or
[docker|podman] images
[docker|podman] container ls -a
# or
[docker|podman] ps
[docker|podman] compose -f <yaml_file> logs [-f] [service name]
# or
[docker|podman] logs [-f] [container id]
[docker|podman] compose -f <yaml_file> config
echo 'y' | [docker|podman] system prune
# 导出
[docker|podman] save -o <image>.tar <image_name:label | image_id>
# 导入
# 使用image_id导出的镜像,导入时也没有名字
[docker|podman] load -i <image>.tar
# 创建临时容器
[docker|podman] conatiner create --name <container_name> <image_name>
# 从容器复制文件到宿主机
[docker|podman] conatiner cp <container_name>:<file_path> <dest_path>
# 清理临时窗口
[docker|podman] container rm <container_name>
[docker|podman] network create [name]
echo "alias d-ll='[docker|podman] image ls -a; echo; [docker|podman] container ls -a'" >> ~/.bashrc \
&& echo "alias d-ps='[docker|podman] ps'" >> ~/.bashrc \
&& echo "alias d-clean='[docker|podman] system prune -f'" >> ~/.bashrc \
&& echo "alias d-rm='_a(){ [docker|podman] image rm $1; echo; [docker|podman] container rm $1; }; _a'" >> ~/.bashrc \
&& echo "alias d-exec='_a(){ [docker|podman] exec -it $1 /bin/bash; }; _a'" >> ~/.bashrc \
&& echo "alias d-stop='_a(){ [docker|podman] container stop $1; }; _a'" >> ~/.bashrc \
&& echo "alias d-kill='_a(){ [docker|podman] container kill $1; }; _a'" >> ~/.bashrc
source ~/.bashrc