generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: kill信号不同分类的影响 | ||
date: 2023-05-24 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [shell] | ||
tags: [shell] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# kill信号不同分类的影响 | ||
|
||
与`kill -KILL`不同的是,`kill -INT -PID` 将通知被结束进程,等同于`Ctrl+C`。 | ||
例如如果结束一个script,该script中同步启动了一个APP,使用`kill -INT -<PIDofScript>`可以同时将这个APP结束掉,`kill -KILL`则不行。 | ||
|
||
| 分类 | 信号 | | ||
|------------------------------|-----------------------------------------------------------------| | ||
| 程序不可捕获、阻塞或忽略的信号| SIGKILL, SIGSTOP | | ||
| 不能恢复至默认动作的信号 | SIGILL, SIGTRAP | | ||
| 默认会导致进程流产的信号 | SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGIOT, SIGQUIT, SIGSEGV, SIGTRAP, SIGXCPU, SIGXFSZ | | ||
| 默认会导致进程退出的信号 | SIGALRM, SIGHUP, SIGINT, SIGKILL, SIGPIPE, SIGPOLL, SIGPROF, SIGSYS, SIGTERM, SIGUSR1, SIGUSR2, SIGVTALRM | | ||
| 默认会导致进程停止的信号 | SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU | | ||
| 默认进程忽略的信号 | SIGCHLD, SIGPWR, SIGURG, SIGWINCH | | ||
|
||
[Linux 下的KILL函数的用法 - 拂 晓 - 博客园 (cnblogs.com)](https://www.cnblogs.com/leeming0222/articles/3994125.html) | ||
|
||
如果`kill`不能结束掉,则尝试使用`pkill`: | ||
|
||
```bash | ||
pkill -TERM -P <PID of script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: shell参数特殊变量符号 | ||
date: 2023-05-24 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [shell] | ||
tags: [shell] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
## Shell 特殊参数解释 | ||
|
||
首先来看几个特殊变量:`$0`, `$#`, `$*`, `$@`, `$?`, `$$`, `$_` | ||
|
||
```bash | ||
#!/bin/bash | ||
echo $0 # 当前脚本的文件名(间接运行时还包括绝对路径)。 | ||
echo $n # 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是 $1 。 | ||
echo $# # 传递给脚本或函数的参数个数。 | ||
echo $* # 传递给脚本或函数的所有参数。 | ||
echo $@ # 传递给脚本或函数的所有参数。被双引号 (" ") 包含时,与 $* 不同,下面将会讲到。 | ||
echo $? # 上个命令的退出状态,或函数的返回值。 | ||
echo $$ # 当前 Shell 进程 ID。对于 Shell 脚本,就是这些脚本所在的进程 ID。 | ||
echo $_ # 上一个命令的最后一个参数 | ||
echo $! # 后台运行的最后一个进程的 ID 号 | ||
``` | ||
|
||
执行结果如下: | ||
|
||
```bash | ||
$ ./test.sh test test1 test2 test3 test4 | ||
|
||
./test.sh # $0 | ||
# $n | ||
5 # $# | ||
test test1 test2 test3 test4 # $* | ||
test test1 test2 test3 test4 # $@ | ||
0 # $? | ||
12305 # $$ | ||
12305 # $_ | ||
# $! | ||
``` | ||
|
||
### 参数中的双引号 | ||
|
||
`$*` 和 `$@` 都表示传递给函数或脚本的所有参数,不被双引号 ("") 包含时,都以 `$1""$2" … "$n` 的形式输出所有参数。 | ||
|
||
但是当它们被双引号 ("") 包含时,`"$*"` 会将所有的参数作为一个整体,以 `$1 $2 … $n` 的形式输出所有参数;`$@` 会将各个参数分开,以 `"$1""$2" … "$n"` 的形式输出所有参数。 | ||
|
||
## 传递参数方式一 | ||
|
||
采用 `$0`, `$1`, `$2` ... 等方式获取脚本命令行传入的参数,值得注意的是,`$0` 获取到的是脚本路径以及脚本名,后面按顺序获取参数,当参数超过10个时(包括10个),需要使用`${10}`, `${11}`....才能获取到参数。 | ||
|
||
```bash | ||
#!/bin/bash | ||
echo "脚本$0" | ||
echo "第一个参数$1" | ||
echo "第二个参数$2" | ||
``` | ||
|
||
运行结果: | ||
|
||
```bash | ||
$ ./test.sh 1 2 | ||
|
||
#shell中将会输出: | ||
脚本./test.sh | ||
第一个参数1 | ||
第二个参数2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: ubuntu免密登录 | ||
date: 2023-05-24 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [shell] | ||
tags: [shell] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# ubuntu免密登录 | ||
|
||
## vscode | ||
|
||
1. 在windows端 | ||
|
||
```bash | ||
# 生成私钥及公钥文件 | ||
ssh-keygen -t RSA -C "[email protected]" | ||
``` | ||
|
||
2. 在ubuntu端 | ||
|
||
拷贝`id_rsa.pub`文件到ubuntu系统上 | ||
|
||
```bash | ||
cat id_rsa.pub >> ~/.ssh/authorized_keys | ||
rm id_rsa.pub | ||
``` | ||
|
||
3. vscode连接 | ||
|
||
安装上`vscode remote ssh`套件,左下角有连接图标,点击连接,初次梅有ssh_config文件会提示选择`ssh_config`文件路径,并填写`ssh_config`文件。 | ||
|
||
## mobarXterm | ||
|
||
这步操作在windows上已生成私钥公钥,及ubuntu上生成`authorized_keys`文件之后。 | ||
在mobarXterm中新建连接到ubuntu的ssh session,并设置选项:Advanced SSH Settings -> Use private key,选择私钥文件即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ mermaid: true | |
# pin: true | ||
--- | ||
|
||
# cpp code snippet | ||
|
||
## 1. 获取数组长度 | ||
|
||
```cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ mermaid: true | |
# pin: true | ||
--- | ||
|
||
# 通过函数指针地址找到函数 | ||
|
||
```bash | ||
# 通过地址找到函数声明 | ||
info symbol 0x7f0db14cf57e | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: 从Makefile创建compile_commands.json | ||
date: 2023-06-05 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [shell] | ||
tags: [shell] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# 从Makefile创建compile_commands.json | ||
|
||
## 操作步骤 | ||
|
||
```bash | ||
# https://github.com/nickdiego/compiledb | ||
pip install compiledb | ||
``` | ||
|
||
使用方法: | ||
|
||
```bash | ||
compiledb make | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: Ubuntu 安装VNCServer及使用 | ||
date: 2023-06-05 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [shell] | ||
tags: [shell] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
## 1. 安装 | ||
|
||
```bash | ||
sudo apt-get install gnome-panel | ||
sudo apt-get install tightvncserver | ||
|
||
# 创建端口 | ||
vncserver :1 -geometry 1920x1000 -depth 24 | ||
|
||
# 关闭端口 | ||
vncserver -kill :1 | ||
|
||
# 重新设置密码 | ||
vncpasswd | ||
|
||
# 重启vncserver | ||
vncserver :1 | ||
|
||
# 重启vncserver方式2 | ||
vncserver -geometry 1920x1080 :1 | ||
|
||
# 查看vncserver log | ||
tail -f ~/.vnc/log_name.log | ||
``` | ||
|
||
编辑配置文件 `.vnc/xstartup` | ||
|
||
```bash | ||
#!/bin/sh | ||
|
||
unset SESSION_MANAGER | ||
unset DBUS_SESSION_BUS_ADDRESS | ||
export XKL_XMODMAP_DISABLE=1 | ||
export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME" | ||
export XDG_MENU_PREFIX="gnome-flashback-" | ||
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup | ||
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources | ||
xsetroot -solid grey | ||
vncconfig -iconic & | ||
#gnome-terminal & | ||
#nautilus & | ||
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check & | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ mermaid: true | |
# pin: true | ||
--- | ||
|
||
# Ubuntu 22.04 安装 Qt5,以编译 VTK | ||
|
||
## 1. install commands | ||
|
||
```bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: Linux 系统console使用命令清屏 | ||
date: 2023-07-02 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [shell] | ||
tags: [shell] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
|
||
```bash | ||
echo -en "\e[H\e[J\e[3J" | ||
``` | ||
|
||
## reference | ||
* [clear command in Konsole](https://superuser.com/questions/122911/what-commands-can-i-use-to-reset-and-clear-my-terminal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters