mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-19 05:31:21 +08:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
56b4b78d7d | |||
f28c93b918 | |||
0bfe15e4dc | |||
c1394813bc | |||
06c6229cac | |||
04dd94d6f8 | |||
5f19d3feee | |||
e48fd74c38 | |||
7c7f25bf9f | |||
2dde0c4408 | |||
a2d7cd6e7b | |||
10366e3317 | |||
4bf8a55bf3 | |||
0101ef71d0 | |||
aa38a0e765 | |||
4a1eb6964d | |||
f6ff51be15 | |||
6c89718254 | |||
8c79a648a4 | |||
f021d73b77 | |||
c060c36559 | |||
39aa2c4387 | |||
aeca8351bd | |||
d7d6b0d447 | |||
4d69a0ef24 |
34
README.md
34
README.md
@ -12,13 +12,14 @@ Quick Reference
|
||||
[](https://jaywcjlove.github.io/reference)
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
为开发人员分享快速参考备忘清单【速查表】 _(主要是方便自己)_,在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
为开发人员分享快速参考备忘清单【速查表】。在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造中文版本的轮子使命感突然来了,为了方便自己的技术栈查阅,如果您提供一个清单,我将抽空搬运,立即撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
|
||||
## 正在建设中...
|
||||
|
||||
坑已挖,需要您的参与完善和贡献!🙏
|
||||
<!--rehype:style=padding-bottom: 23px;-->
|
||||
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(238 0 0/var(\-\-bg\-opacity));&class=contributing tag&data-lang=RedHad&data-info=👆看看还缺点儿什么?-->
|
||||
[CMake](./docs/cmake.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
@ -32,13 +33,16 @@ Quick Reference
|
||||
[C](./docs/c.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));-->
|
||||
[Docker](./docs/docker.md)<!--rehype:style=background: rgb(72 143 223/var(\-\-bg\-opacity));-->
|
||||
[Dockerfile](./docs/dockerfile.md)<!--rehype:style=background: rgb(0 72 153/var(\-\-bg\-opacity));&class=tag&data-lang=Docker-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python-->
|
||||
[Golang](./docs/golang.md)<!--rehype:style=background: rgb(39 160 193/var(\-\-bg\-opacity));-->
|
||||
[INI](./docs/ini.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[JSON](./docs/json.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[Java](./docs/java.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
|
||||
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));&class=tag&data-lang=SQL-->
|
||||
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Python](./docs/python.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[PostgreSQL](./docs/postgres.md)<!--rehype:style=background: rgb(43 109 163/var(\-\-bg\-opacity));&class=tag&data-lang=SQL-->
|
||||
[Rust](./docs/rust.md)<!--rehype:style=background: rgb(71 71 71/var(\-\-bg\-opacity));-->
|
||||
[Swift](./docs/swift.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[SwiftUI](./docs/swiftui.md)<!--rehype:style=background: rgb(10 127 247/var(\-\-bg\-opacity));&class=tag&data-lang=swift-->
|
||||
@ -59,9 +63,10 @@ Quick Reference
|
||||
[JavaScript](./docs/javascript.md)<!--rehype:style=background: rgb(203 183 31/var(\-\-bg\-opacity));-->
|
||||
[Less.js](./docs/lessjs.md)<!--rehype:style=background: rgb(29 54 93/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[React](./docs/react.md)<!--rehype:style=background: rgb(34 143 173/var(\-\-bg\-opacity));-->
|
||||
[RegEx](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
|
||||
[RegEx 正则表达式](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
|
||||
[TypeScript](./docs/typescript.md)<!--rehype:style=background: rgb(49 120 198/var(\-\-bg\-opacity));-->
|
||||
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
[Vue 3 ](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Nodejs
|
||||
@ -72,48 +77,53 @@ Quick Reference
|
||||
[Lerna](./docs/lerna.md)<!--rehype:style=background: rgb(192 132 252/var(\-\-bg\-opacity));-->
|
||||
[npm](./docs/npm.md)<!--rehype:style=background: rgb(203 2 0/var(\-\-bg\-opacity));-->
|
||||
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(33 136 182/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 工具
|
||||
|
||||
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[Gmail](./docs/gmail.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(98 36 134/var(\-\-bg\-opacity));-->
|
||||
[Gmail](./docs/gmail.md)<!--rehype:style=background: rgb(234 67 54/var(\-\-bg\-opacity));-->
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 153 0/var(\-\-bg\-opacity));-->
|
||||
[Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141/var(\-\-bg\-opacity));-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));&class=tag&data-lang=macOS-->
|
||||
[Sublime Text](./docs/sublime-text.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
[VSCode](./docs/vscode.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[Vim](./docs/vim.md)<!--rehype:style=background: rgb(9 150 8/var(\-\-bg\-opacity));-->
|
||||
[WebStorm](./docs/webstorm.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[WebStorm](./docs/webstorm.md)<!--rehype:style=background: rgb(32 148 220/var(\-\-bg\-opacity));-->
|
||||
[XPath](./docs/xpath.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[Xcode](./docs/xcode.md)<!--rehype:style=background: rgb(24 151 233/var(\-\-bg\-opacity));&class=tag&data-lang=macOS-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Linux 命令
|
||||
## 命令
|
||||
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(238 0 0/var(\-\-bg\-opacity));&class=contributing tag&data-lang=RedHad&data-info=👆看看还缺点儿什么?-->
|
||||
[Awk](./docs/awk.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Conan](./docs/conan.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=tag&data-lang=C/C++-->
|
||||
[Cargo](./docs/cargo.md)<!--rehype:style=background: rgb(71 71 71/var(\-\-bg\-opacity));&class=tag&data-lang=Rust-->
|
||||
[Curl](./docs/curl.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Chmod](./docs/chmod.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Cron](./docs/cron.md)<!--rehype:style=background: rgb(239 68 68/var(\-\-bg\-opacity));-->
|
||||
[CMake](./docs/cmake.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Git](./docs/git.md)<!--rehype:style=background: rgb(215 89 62/var(\-\-bg\-opacity));-->
|
||||
[Grep](./docs/grep.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Find](./docs/find.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Htop](./docs/htop.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Home Brew](./docs/homebrew.md)<!--rehype:style=background: rgb(252 185 87/var(\-\-bg\-opacity));-->
|
||||
[Home Brew](./docs/homebrew.md)<!--rehype:style=background: rgb(252 185 87/var(\-\-bg\-opacity));&class=tag&data-lang=macOS-->
|
||||
[Netstat](./docs/netstat.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[jq](./docs/jq.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));&class=tag&data-lang=JSON-->
|
||||
[Lsof](./docs/lsof.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Netcat](./docs/netcat.md)<!--rehype:style=background: rgb(4 92 135/var(\-\-bg\-opacity));-->
|
||||
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
|
||||
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
|
||||
[YUM](./docs/yum.md)<!--rehype:style=background: rgb(86 86 123/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 其它
|
||||
|
||||
[Quick Reference](./docs/quickreference.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Quick Reference](./docs/quickreference.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));&class=tag&data-lang=排版说明-->
|
||||
[Github Actions](./docs/github-actions.md)<!--rehype:style=background: rgb(121 184 255/var(\-\-bg\-opacity));-->
|
||||
[Colors Named](./docs/colors-named.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[HTTP 状态码](./docs/http-status-code.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
|
@ -48,7 +48,7 @@ bar.example.com
|
||||
检查Inventory是否生效
|
||||
|
||||
```shell
|
||||
ansible all --list-hosts
|
||||
$ ansible all --list-hosts
|
||||
```
|
||||
ping所有目标
|
||||
|
||||
@ -364,3 +364,4 @@ $ ansible-pull -U <repository> [options]
|
||||
---
|
||||
[Getting started with Ansible](https://docs.ansible.com/ansible/latest/getting_started/index.html)
|
||||
[Introduction to ad hoc commands](https://docs.ansible.com/ansible/latest/user_guide/intro_adhoc.html)
|
||||
[Ansible cheatsheet](https://github.com/luckylittle/ansible-cheatsheet/blob/master/ansible-cheatsheet.txt)
|
@ -6,8 +6,7 @@ Cargo 备忘清单
|
||||
入门
|
||||
--------
|
||||
|
||||
### 安装 Rust 和 Cargo
|
||||
|
||||
### 安装/升级 Rust 和 Cargo
|
||||
|
||||
```bash
|
||||
$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
||||
@ -36,6 +35,32 @@ $ curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
||||
`cargo clippy --all-targets -- --D warnings` | Linter 检查错误
|
||||
`cargo tarpaulin --ignore-tests` | 检查代码覆盖率
|
||||
|
||||
### 切换源
|
||||
<!--rehype:wrap-class=col-span-2&style=background:#e91e63;--->
|
||||
|
||||
```bash
|
||||
$ touch ~/.cargo/config # 添加配置文件
|
||||
$ vim ~/.cargo/config # 编辑配置文件
|
||||
```
|
||||
|
||||
配置文件 `config` 内容
|
||||
|
||||
```toml
|
||||
[source.crates-io]
|
||||
registry = "https://github.com/rust-lang/crates.io-index"
|
||||
replace-with = 'tuna' # 👈 如果需要提交包注释配置源
|
||||
|
||||
[source.tuna]
|
||||
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
|
||||
# registry = "git://mirrors.ustc.edu.cn/crates.io-index"
|
||||
```
|
||||
|
||||
💥 注意切换源需要删除缓存目录
|
||||
|
||||
```bash
|
||||
$ rm -rf ~/.cargo/.package-cache # ⚠️ 删除缓存目录内容
|
||||
```
|
||||
|
||||
### 创建新项目
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
@ -43,6 +68,8 @@ $ curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
||||
$ cargo new hello_world --bin
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- `--bin` 正在制作一个二进制程序
|
||||
- `--lib` 正在创建一个库(lib)
|
||||
|
||||
@ -167,7 +194,7 @@ edition = '2015'
|
||||
# `source` 表下,就是存储有关要更换的来源名称
|
||||
[source]
|
||||
|
||||
# 在`source` 表格之下的,可为一定数量的有关来源名称. 示例下面就# 定义了一个新源, 叫 `my-awesome-source`, 其内容来自本地 # `vendor`目录 ,其相对于包含`.cargo/config`文件的目录
|
||||
# 在`source` 表格之下的,可为一定数量的有关来源名称. 示例下面就,定义了一个新源, 叫 `my-awesome-source`,其内容来自本地,`vendor`目录 ,其相对于包含 `.cargo/config` 文件的目录
|
||||
[source.my-awesome-source]
|
||||
directory = "vendor"
|
||||
|
||||
@ -177,7 +204,7 @@ git = "https://example.com/path/to/repo"
|
||||
# tag = "v1.0.1"
|
||||
# rev = "313f44e8"
|
||||
|
||||
# The crates.io 默认源 在"crates-io"名称下, 且在这里我们使用 `replace-with` 字段指明 默认源更换成"my-awesome-source"源
|
||||
# crates.io 默认源 在"crates-io"名称下,且在这里我们使用 `replace-with` 字段指明 默认源更换成"my-awesome-source"源
|
||||
[source.crates-io]
|
||||
replace-with = "my-awesome-source"
|
||||
```
|
||||
@ -199,7 +226,7 @@ directory = "path/to/vendor"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
更换源的配置通过完成 `.cargo/config`,下面为全套可用字段是
|
||||
更换源的配置通过完成 `.cargo/config`,上面是全套可用字段
|
||||
|
||||
包相关命令
|
||||
---
|
||||
|
39
docs/css.md
39
docs/css.md
@ -1374,10 +1374,11 @@ a[href^="http"]:empty::before {
|
||||
}
|
||||
```
|
||||
|
||||
如果你的 `<a>` 标签里面没有内容,将 `href` 的值作为内容展示
|
||||
如果 `<a>` 标签里面没有内容,将 `href` 的值作为内容展示
|
||||
|
||||
|
||||
### 使用 :root 表示灵活类型
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
响应式布局中的字体大小应该能够根据每个视口进行调整,您可以使用 `:root` 根据视口高度和宽度计算字体大小
|
||||
|
||||
@ -1387,7 +1388,7 @@ a[href^="http"]:empty::before {
|
||||
}
|
||||
```
|
||||
|
||||
现在您可以根据 `:root` 计算的值使用根 `em` 单位:
|
||||
您可以根据 `:root` 计算的值使用根 `em` 单位:
|
||||
|
||||
```css
|
||||
body {
|
||||
@ -1395,6 +1396,40 @@ body {
|
||||
}
|
||||
```
|
||||
|
||||
### 吸附滚动
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```css {5,12}
|
||||
.container {
|
||||
height: 250px;
|
||||
overflow-x: scroll;
|
||||
display: flex;
|
||||
scroll-snap-type: x mandatory;
|
||||
column-gap: 10px;
|
||||
}
|
||||
.child {
|
||||
flex: 0 0 66%;
|
||||
width: 250px;
|
||||
background-color: #663399;
|
||||
scroll-snap-align: center;
|
||||
}
|
||||
```
|
||||
|
||||
可用于 `轮播图` 效果,[效果预览](https://codesandbox.io/embed/pensive-leftpad-w9p8rk?fontsize=14&hidenavigation=1&theme=dark)
|
||||
|
||||
### 类似 contenteditable 的样式
|
||||
|
||||
```css
|
||||
div {
|
||||
-webkit-user-modify:
|
||||
read-write-plaintext-only;
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
通过样式来控制一个元素 `div` 是否可以编辑
|
||||
|
||||
|
||||
另见
|
||||
---------
|
||||
|
||||
|
55
docs/curl.md
55
docs/curl.md
@ -228,3 +228,58 @@ curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp"
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
下载一系列文件(输出`foo_file1.webp`、`foo_file2.webp…bar_file1_webp`等)
|
||||
|
||||
### 将输出重定向到文件
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
$ curl http://url/file > file
|
||||
```
|
||||
|
||||
### 基本认证
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
$ curl --user username:password http://example.com/
|
||||
$ curl -u username:password http://example.com/
|
||||
```
|
||||
|
||||
### 写入文件而不是标准输出
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -o file http://url/file
|
||||
$ curl --output file http://url/file
|
||||
```
|
||||
|
||||
### 下载头信息
|
||||
|
||||
```bash
|
||||
$ curl -I url
|
||||
# 显示头信息
|
||||
```
|
||||
|
||||
### 将输出写入名为远程文件的文件
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -o file http://url/file
|
||||
$ curl --output file http://url/file
|
||||
```
|
||||
|
||||
### 执行远程脚本
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -s http://url/myscript.sh
|
||||
```
|
||||
|
||||
### 配置文件
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
curl -K file
|
||||
# 从文件中读取配置
|
||||
curl --config file
|
||||
$HOME/.curlrc # 类 UNIX 系统中的默认配置文件
|
||||
```
|
@ -134,6 +134,7 @@ Docker 镜像
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 操控
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
| `Example` | Description |
|
||||
|-----------|-----------|
|
||||
@ -159,6 +160,12 @@ $ docker build -f myOtherDockerfile .
|
||||
$ curl example.com/remote/Dockerfile | docker build -f - .
|
||||
```
|
||||
|
||||
### 删除 \<none> 镜像
|
||||
|
||||
```bash
|
||||
$ docker rmi -f $(docker images | grep "none" | awk '{print $3}')
|
||||
```
|
||||
|
||||
Docker 网络
|
||||
----
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
308
docs/ffmpeg.md
308
docs/ffmpeg.md
@ -7,6 +7,7 @@ FFmpeg 参考
|
||||
---
|
||||
|
||||
### 安装
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
Linux
|
||||
|
||||
@ -22,6 +23,7 @@ $ brew install ffmpeg
|
||||
```
|
||||
|
||||
### 示例
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
mp4 转 avi:
|
||||
|
||||
@ -35,40 +37,86 @@ webm 转 mp4:
|
||||
$ ffmpeg -i movie.webm movie.mp4
|
||||
```
|
||||
|
||||
### 常用开关
|
||||
### 全局选项
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-y` | 覆盖输出文件
|
||||
`-n` | 不要覆盖输出文件
|
||||
|
||||
### 主要选项
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-f fmt` | 强制输入或输出文件格式
|
||||
`-i fName` | 输入文件名,未指定显示内容流的摘要
|
||||
`-c codecName` | 指定编解码器 [输入或输出]
|
||||
`-fs Nbytes` | 以 Nbytes 指定最大输出文件大小
|
||||
|
||||
### 基础参数
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-codecs` | 列出可用编码
|
||||
`-formats` | 列出支持的格式
|
||||
`-protocols` | 列出支持的协议
|
||||
`-i input.mp4` | 指定输入文件
|
||||
`-c:v libx264` | 指定视频编码
|
||||
`-c:a aac` | 指定音频编码
|
||||
`-vcodec libx264` | 旧写法
|
||||
`-acodec aac` | 旧写法
|
||||
`-fs SIZE` | 指定文件大小
|
||||
|
||||
### 视频参数
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-b bRate` | 设置视频比特率(单位 kbit/s)
|
||||
`-fixaspect` | 固定纵横比
|
||||
`-bt tolerance` | 设置视频比特率容差(单位 kbit/s)
|
||||
`-maxrate bRate` | 设置最大视频比特率容差(单位 kbit/s)
|
||||
`-minrate bRate` | 设置最小视频比特率容差(单位 kbit/s)
|
||||
`-bufsize size` | 设置速率控制缓冲区大小(以 kByte 为单位)
|
||||
`-sameq` | 使用与源相同的视频质量(意味着 VBR)
|
||||
`-newvideo` | 将新的视频流添加到当前输出流
|
||||
`-aspect RATIO` | 纵横比(4:3、16:9 或 1.25)
|
||||
`-r RATE` | 每秒帧率
|
||||
`-s WIDTHxHEIGHT` | 帧大小
|
||||
`-vn` | 没有视频
|
||||
|
||||
### 码率设置
|
||||
|
||||
```bash
|
||||
-codecs # 列出编解码器
|
||||
-c:v # 视频编解码器(-vcodec)-'copy'复制流
|
||||
-c:a # 音频编解码器(-acodec)
|
||||
-fs SIZE # 限制文件大小(字节)
|
||||
-b:v 1M # 视频比特率(1M = 1Mbit/s)
|
||||
-b:a 1M # 音频比特率(1M = 1Mbit/s)
|
||||
```
|
||||
|
||||
### 音频
|
||||
### 尺寸规格
|
||||
|
||||
```bash
|
||||
-aq QUALITY # 音频质量(特定于编解码器)
|
||||
-ar 44100 # 音频采样率 (Hz)
|
||||
-ac 1 # 音频通道(1=单声道,2=立体声)
|
||||
-an # 没有音频
|
||||
-vol N # 音量(256=正常)
|
||||
```
|
||||
:- | - | - | -
|
||||
:- | - | - | -
|
||||
`K` 或 `k` | 103 | 1000 字节 | 千字节 Kilobytes
|
||||
`M` | 106 | 1000000 字节 | 兆字节 Megabytes
|
||||
`G` | 109 | 1000000000 | 千兆字节 Gigabytes
|
||||
`Ki` | 210 | 1024 | 千字节 Kibibyte
|
||||
`Mi` | 220 | 1048576 | 兆字节 Mebibyte
|
||||
`Gi` | 230 | 1073741824 | Gibibyte
|
||||
|
||||
### 比特率
|
||||
|
||||
```bash
|
||||
-b:v 1M # 视频比特率(1M = 1Mbit/s)
|
||||
-b:a 1M # 音频比特率
|
||||
```
|
||||
### 音频参数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
#### 视频
|
||||
|
||||
```bash
|
||||
-aspect RATIO # 纵横比(4:3、16:9 或 1.25)
|
||||
-r RATE # 每秒帧率
|
||||
-s WIDTHxHEIGHT # 帧大小
|
||||
-vn # 没有视频
|
||||
```
|
||||
:- | -
|
||||
:- | -
|
||||
`-ab bRate` | 设置音频比特率(单位 kbit/s)
|
||||
`-aframes N` | 设置要录制的音频帧数 [-frames:a 的别名]
|
||||
`-aq q` | 设置音频质量(特定于编解码器,VBR) [-q:a 的别名]
|
||||
`-an` | 禁用录音
|
||||
`-acodec codec` | 设置音频编解码器。[-codec:a 的别名] 使用 'copy' 复制流。
|
||||
`-vol` | 以 256 的倍数更改音频音量,其中 256 = 100%(正常)音量。例如 512 = 200%
|
||||
`-newaudio` | 将新的音频流添加到当前输出流
|
||||
`-alang code` | 设置当前音频流的 ISO 639 语言代码(3 个字母)
|
||||
|
||||
视频编辑
|
||||
---
|
||||
@ -116,7 +164,7 @@ $ ffmpeg -i input.avi -r 24 output.avi
|
||||
$ ffmpeg -r 1 -i input.m2v -r 24 output.avi
|
||||
```
|
||||
|
||||
将输入文件的帧速率(仅对原始格式有效)强制为 1 fps,将输出文件的帧速率强制为 24 fps
|
||||
将输入文件的帧速率(仅对原始格式有效)强制为 1 fps,将输出文件的帧速率强制为 24 fps
|
||||
|
||||
### 剪切视频部分
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
@ -188,7 +236,7 @@ $ ffmpeg -i file.mp4 -vn -acodec copy output.aac
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
将`-vn`(无视频)与 `-acodec copy` 结合起来。请注意,输出文件扩展名必须与输入文件中的音频编解码器匹配,`-acodec copy` 才能工作。
|
||||
将`-vn`(无视频)与 `-acodec copy` 结合起来。请注意,输出文件扩展名必须与输入文件中的音频编解码器匹配,`-acodec copy` 才能工作。
|
||||
|
||||
### 创建缩略图
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
@ -259,7 +307,7 @@ $ ffmpeg -i input.mov -itsoffset 3 -i input.mov -map 0:v -map 1:a -codec:a copy
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
将视频延迟 3 秒(即将音频提前 3 秒)
|
||||
将视频延迟 3 秒(即将音频提前 3 秒)
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.mov -itsoffset 3 -i input.mov -map 1:v -map 0:a -codec:a copy -codec:v copy output.mov
|
||||
@ -283,7 +331,7 @@ $ ffmpeg -i video.mp4 image%d.jpg
|
||||
```
|
||||
|
||||
### 转换为 Gif
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
```bash
|
||||
$ ffmpeg -ss 2 -t 28 -i input.mp4 -vf "fps=10,scale=1080:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
|
||||
@ -308,8 +356,23 @@ $ ffmpeg -i input.mov -codec:v copy -an output.mov
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将输入文件转码为 DVD PAL 格式
|
||||
|
||||
```bash
|
||||
$ ffmpeg -y -threads 8 -i inFile -target pal-dvd -ac 2 -aspect 16:9 -acodec mp2 -ab 224000 -vf pad=0:0:0:0 outFile
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
|
||||
### 转换为灰度
|
||||
|
||||
```bash
|
||||
$ ffmpeg -y -i inFile -flags gray outFile
|
||||
```
|
||||
|
||||
|
||||
### 字幕
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
将字幕写入视频
|
||||
|
||||
@ -322,9 +385,24 @@ $ ffmpeg -i input.mov -filter:v 'subtitles=subtitles.srt' -codec:a copy output.m
|
||||
```bash
|
||||
$ ffmpeg -i input.mov -filter:v "subtitles=subtitles.srt:force_style='FontName=Menlo Bold,Fontsize=18'" -codec:a copy output.mov
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 制造 1 分钟的音频噪音
|
||||
|
||||
```bash
|
||||
$ ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -i /dev/urandom -ab 64K -f mp2 -acodec mp2 -y noise.mp2
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 从视频中提取图像
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i foo.avi -r 1 -s WxH -f image2 outFile%03d.png
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 音量
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
将音量减半
|
||||
|
||||
@ -338,6 +416,171 @@ $ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=0.5' output.mov
|
||||
$ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=2' output.mov
|
||||
```
|
||||
|
||||
### 将图像文件转换为其他格式
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i foo0122.png foo.tiff
|
||||
```
|
||||
|
||||
pgm, ppm, pam, pgmyuv, jpeg, gif, png, tiff, sgi
|
||||
|
||||
### 将图像转换为 AVI 文件
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将 WAV 文件转换为 MP3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i source_song.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final_song.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 从视频中提取音频,将其转码为 MP3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i source.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将 .avi 转换为 .flv
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i source.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output.flv
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将图片附加到 mp3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将视频与声音文件混合
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i song.wav -i source_video.avi outvideo.mpg
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 编写带有 ID3v2.3 页眉和 ID3v1 页脚的 mp3
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i inFile -id3v2_version 3 -write_id3v1 1 outFile.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 连接输入文件
|
||||
|
||||
```bash
|
||||
$ cat inFile1 inFile2 | ffmpeg -f mpeg -i - -vcodec copy -acodec copy outFile.mpg
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 使用比特率和 mp3 音频的编解码器对剪辑进行编码
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i clip.avi -vcodec libxvid -b 800000 -acodec libmp3lame -ab 128 new-clip.avi
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将音频流与来自不同文件的视频流合并
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i audioS.mp4 -i videoS.mp4 -c copy -map 0:a -map 1:v outFile.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 合并视频
|
||||
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
合并相同规格(解码/分辨率/帧率)视频
|
||||
|
||||
```bash
|
||||
# mylist.txt >>>
|
||||
file '1.mp4'
|
||||
file '2.mp4'
|
||||
file '3.mp4'
|
||||
|
||||
# 这些文件是相对路径,如使用绝对路径需要添加 `-safe 0` 参数
|
||||
$ ffmpeg -f concat -i mylist.txt -c copy output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并当前目录下所有视频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并不同规格视频,保证视频不变形
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i 1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmp1.ts
|
||||
$ ffmpeg -i 2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmp2.ts
|
||||
$ ffmpeg -i 3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts tmp3.ts
|
||||
|
||||
$ ffmpeg -threads 2 -i "concat:tmp1.ts|tmp2.ts|tmp3.ts" -vf "scale=720:1080:force_original_aspect_ratio=decrease,pad=720:1080:(ow-iw)/2:(oh-ih)/2" -pix_fmt yuvj420p -shortest -y output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并不同解码视频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input1.mp4 -i input2.webm -i input3.mov \
|
||||
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]" \
|
||||
-map "[outv]" -map "[outa]" output.mkv
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
合并视频并重新编码音频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f concat -i mylist.txt -c:v copy -c:a flac -strict -2 output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 合并音频与图片
|
||||
|
||||
合并多个音频,自定义背景图片,生成视频音乐
|
||||
|
||||
```bash
|
||||
# mylist.txt >>>
|
||||
file '1.mp3'
|
||||
file '2.mp3'
|
||||
file '3.mp3'
|
||||
|
||||
# OBS: 46500 = 25:50 minutes * 60 * 30fps
|
||||
# echo "00:25:50" | awk -F: '{ print (($1 * 3600) + ($2 * 60) + $3) * 30 }'
|
||||
$ ffmpeg -y -loop 1 -i cover.jpg -f concat -i mylist.txt -c:v libx264 -r 30 -pix_fmt yuv420p -vframes 46500 -c:a aac -b:a 192k -strict experimental -shortest output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 添加水印
|
||||
|
||||
在视频左上方 20,20 的位置插入 logo.png 图片
|
||||
|
||||
```bash
|
||||
# -b:v 548k 可选参数,设置视频比特率,默认 200k 最好设置与原视频一致
|
||||
ffmpeg -i 1.mp4 -acodec copy -b:v 548k -vf "movie=logo.png[watermark];[in][watermark]overlay=20:20" output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 去除水印
|
||||
|
||||
设置一个矩形覆盖区域 x=10:y=10:w=120:h=45
|
||||
|
||||
```bash
|
||||
# show=1 为可选参数,设置显示边框,方便调试用的
|
||||
ffmpeg -i 1.mp4 -b:v 548k -vf delogo=x=10:y=10:w=120:h=45:show=1 output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
@ -345,3 +588,4 @@ $ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=2' output.mov
|
||||
- [FFmpeg Cheat Sheet](https://lzone.de/cheat-sheet/ffmpeg) _(lzone.de)_
|
||||
- [FFmpeg Cheat Sheet](https://devhints.io/ffmpeg) _(devhints.io)_
|
||||
- [FFmpeg Cheat Sheet](https://github.com/yuanqing/ffmpeg-cheatsheet) _(github.com)_
|
||||
- [FFmpeg Cheat Sheet](https://cheatography.com/thetartankilt/cheat-sheets/ffmpeg/) _(cheatography.com)_
|
@ -89,7 +89,7 @@ Golang 基本类型
|
||||
s1 := "Hello" + "World"
|
||||
s2 := `A "raw" string literal
|
||||
can include line breaks.`
|
||||
// 输出:11
|
||||
// 输出:10
|
||||
fmt.Println(len(s1))
|
||||
// 输出:Hello
|
||||
fmt.Println(string(s1[0:5]))
|
||||
|
236
docs/jq.md
Normal file
236
docs/jq.md
Normal file
@ -0,0 +1,236 @@
|
||||
jq 备忘清单
|
||||
===
|
||||
|
||||
这个快速参考备忘单提供了使用 [jq](https://stedolan.github.io/jq/) 命令的各种方法。
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
### 介绍
|
||||
|
||||
jq 就像用于 JSON 数据的 [sed](./sed.md) - 您可以使用它来切片、过滤、映射和转换结构化数据
|
||||
|
||||
- [jq 官网](https://stedolan.github.io/jq/) _(stedolan.github.io)_
|
||||
- [jq 命令使用](https://jaywcjlove.github.io/linux-command/c/jq.html) _(jaywcjlove.github.io)_
|
||||
|
||||
安装
|
||||
|
||||
```bash
|
||||
$ sudo apt-get install jq # Debian& Ubuntu
|
||||
$ sudo dnf install jq # Fedora
|
||||
$ sudo zypper install jq # openSUSE
|
||||
$ sudo pacman -S jq # Arch
|
||||
$ brew install jq # macOS & Homebrew
|
||||
$ port install jq # macOS & MacPorts
|
||||
```
|
||||
|
||||
语法
|
||||
|
||||
```bash
|
||||
$ jq [options] <jq filter> [file...]
|
||||
$ jq [options] --args <jq filter> [strings...]
|
||||
$ jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 选项
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-c` | 紧凑而不是漂亮的输出
|
||||
`-n` | 使用`null`作为单个输入值
|
||||
`-e` | 根据输出设置退出状态代码
|
||||
`-s` | 将所有输入读取(吸取)到数组中;应用过滤器
|
||||
`-r` | 输出原始字符串,而不是JSON文本
|
||||
`-R` | 读取原始字符串,而不是JSON文本
|
||||
`-C` | 为 JSON 着色
|
||||
`-M` | 单色(不要为JSON着色)
|
||||
`-S` | 在输出上排序对象的键
|
||||
`--tab` | 使用制表符进行缩进
|
||||
`--arg a v` | 将变量 `$a` 设置为 value `<v>`
|
||||
`--argjson a v` | 将变量 `$a` 设置为 JSON value `<v>`
|
||||
`--slurpfile a f` | 将变量 `$a` 设置为从`<f>`读取的JSON文本数组
|
||||
`--rawfile a f` | 将变量 `$a` 设置为包含`<f>`内容的字符串
|
||||
`--args` | 其余参数是字符串参数,而不是文件
|
||||
`--jsonargs` | 其余的参数是JSON参数,而不是文件
|
||||
`--` | 终止参数处理
|
||||
|
||||
学习示例
|
||||
---
|
||||
|
||||
### 获取一个键的值
|
||||
|
||||
```bash
|
||||
$ echo '{"foo": 42, "bar": "less interesting data"}' | jq '.foo'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
42
|
||||
```
|
||||
|
||||
### 数组运算
|
||||
|
||||
```bash
|
||||
$ echo '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' | jq '.[1]'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
{
|
||||
"name": "XML",
|
||||
"good": false
|
||||
}
|
||||
```
|
||||
|
||||
### 构造一个数组/对象
|
||||
|
||||
```bash
|
||||
$ echo '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}' | jq '{user, title: .titles[]}'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
{
|
||||
"user": "stedolan",
|
||||
"title": "JQ Primer"
|
||||
}
|
||||
{
|
||||
"user": "stedolan",
|
||||
"title": "More JQ"
|
||||
}
|
||||
```
|
||||
|
||||
### 计算一个值的长度
|
||||
|
||||
```bash
|
||||
$ echo '[[1,2], "string", {"a":2}, null]' | jq '.[] | length'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
2
|
||||
6
|
||||
1
|
||||
0
|
||||
```
|
||||
|
||||
### 取出数组中的键
|
||||
|
||||
```bash
|
||||
$ echo '{"abc": 1, "abcd": 2, "Foo": 3}' | jq 'keys'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
[
|
||||
"Foo",
|
||||
"abc",
|
||||
"abcd"
|
||||
]
|
||||
```
|
||||
|
||||
### 使用多个过滤器
|
||||
|
||||
```bash
|
||||
$ echo '{ "foo": 42, "bar": "something else", "baz": true}' | jq '.foo, .bar'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
42
|
||||
"something else"
|
||||
```
|
||||
|
||||
### 管道传递给下一个过滤器
|
||||
|
||||
```bash
|
||||
$ echo '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' | jq '.[] | .name'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
"JSON"
|
||||
"XML"
|
||||
```
|
||||
|
||||
### 条件语句判断
|
||||
|
||||
```bash
|
||||
$ echo '[1,5,3,0,7]' | jq 'map(select(. >= 2))'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
[
|
||||
5,
|
||||
3,
|
||||
7
|
||||
]
|
||||
```
|
||||
|
||||
### 每个输入调用过滤器
|
||||
|
||||
```bash
|
||||
$ echo '[1,2,3]' | jq 'map(.+1)'
|
||||
```
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
[
|
||||
2,
|
||||
3,
|
||||
4
|
||||
]
|
||||
```
|
||||
|
||||
### 条件判断
|
||||
|
||||
```bash
|
||||
$ echo '2' | jq 'if . == 0 then "zero" elif . == 1 then "one" else "many" end'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
"many"
|
||||
```
|
||||
|
||||
### 字符串插入值并进行运算
|
||||
|
||||
```bash
|
||||
$ echo '42' | jq '"The input was \(.), which is one less than \(.+1)"'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
输出结果
|
||||
|
||||
```bash
|
||||
"The input was 42, which is one less than 43"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
- [jq 官网](https://stedolan.github.io/jq/) _(stedolan.github.io)_
|
||||
- [jq 命令使用](https://jaywcjlove.github.io/linux-command/c/jq.html) _(jaywcjlove.github.io)_
|
@ -1,7 +1,7 @@
|
||||
NGINX 备忘清单
|
||||
===
|
||||
|
||||
这个 nginx 快速参考备忘单显示了它的常用命和配置使用清单。
|
||||
这个 [nginx](https://nginx.org/en/) 快速参考备忘单显示了它的常用命和配置使用清单。
|
||||
|
||||
入门
|
||||
----
|
||||
|
160
docs/npm.md
160
docs/npm.md
@ -1,7 +1,7 @@
|
||||
npm 备忘清单
|
||||
===
|
||||
|
||||
这个 npm 快速参考备忘单显示了它的常用命令使用清单。
|
||||
这个 [npm](https://www.npmjs.com/) 快速参考备忘单显示了它的常用命令使用清单
|
||||
|
||||
常用命令
|
||||
----
|
||||
@ -67,112 +67,94 @@ npm 备忘清单
|
||||
### 缓存 cache
|
||||
|
||||
```bash
|
||||
npm cache add <package-spec> # 将指定的包添加到本地缓存
|
||||
npm cache clean [<key>] # 删除缓存文件夹中的所有数据
|
||||
npm cache ls [<name>@<version>]
|
||||
npm cache verify # 验证缓存文件夹的内容,垃圾收集任何不需要的数据,
|
||||
$ npm cache add <package-spec> # 将指定的包添加到本地缓存
|
||||
$ npm cache clean [<key>] # 删除缓存文件夹中的所有数据
|
||||
$ npm cache ls [<name>@<version>]
|
||||
$ npm cache verify # 验证缓存文件夹的内容,垃圾收集任何不需要的数据,
|
||||
# 并验证缓存索引和所有缓存数据的完整性
|
||||
```
|
||||
|
||||
用于添加、列出或清理 npm 缓存文件夹
|
||||
用于添加、列出或清理 [npm](https://www.npmjs.com/) 缓存文件夹
|
||||
|
||||
### 更新
|
||||
|
||||
| 命令 | 描述 |
|
||||
| --- | --- |
|
||||
| `npm version <version>` | 要更改 `package.json` 中的版本号 |
|
||||
| `npm update` | 更新生产包 |
|
||||
| `npm update --dev` | 更新开发包 |
|
||||
| `npm update -g` | 更新全局包 |
|
||||
| `npm update lodash` | 更新 `lodash` 包 |
|
||||
命令 | 描述
|
||||
:- | -
|
||||
`npm version <version>` | 要更改 `package.json` 中的版本号
|
||||
`npm update` | 更新生产包
|
||||
`npm update --dev` | 更新开发包
|
||||
`npm update -g` | 更新全局包
|
||||
`npm update lodash` | 更新 `lodash` 包
|
||||
|
||||
|
||||
### 杂项功能
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
将某人添加为所有者
|
||||
|
||||
```bash
|
||||
npm owner add USERNAME PACKAGENAME
|
||||
```
|
||||
|
||||
列出包
|
||||
|
||||
```bash
|
||||
npm ls
|
||||
```
|
||||
|
||||
向安装旧版本软件包的用户添加警告(弃用)
|
||||
|
||||
```bash
|
||||
npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
|
||||
```
|
||||
|
||||
更新所有包或选定的包
|
||||
|
||||
```bash
|
||||
npm update [-g] PACKAGE
|
||||
```
|
||||
|
||||
检查过时的包
|
||||
|
||||
```bash
|
||||
npm outdated [PACKAGE]
|
||||
```
|
||||
|
||||
### 更改包裹可见性
|
||||
|
||||
将公共包设为私有
|
||||
|
||||
```bash
|
||||
npm access restricted <package-name>
|
||||
```
|
||||
|
||||
公开私有包
|
||||
|
||||
```bash
|
||||
npm access public <package-name>
|
||||
```
|
||||
|
||||
授予私有包访问权限
|
||||
|
||||
```bash
|
||||
npm owner add <user> <your-package-name>
|
||||
```
|
||||
|
||||
### 要将包转移到 npm 用户帐户
|
||||
|
||||
```bash
|
||||
npm owner add <their-username> <package-name>
|
||||
# 新维护者接受邀请
|
||||
npm owner rm <your-username> <package-name>
|
||||
```
|
||||
|
||||
写入启用了双因素身份验证
|
||||
|
||||
```bash
|
||||
npm owner add <their-username> <package-name> --otp=123456
|
||||
# 将某人添加为所有者
|
||||
$ npm owner add USERNAME PACKAGENAME
|
||||
# 列出包
|
||||
$ npm ls
|
||||
# 向安装旧版本软件包的用户添加警告(弃用)
|
||||
$ npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0"
|
||||
# 更新所有包或选定的包
|
||||
$ npm update [-g] PACKAGE
|
||||
# 检查过时的包
|
||||
$ npm outdated [PACKAGE]
|
||||
```
|
||||
|
||||
### 取消发布包
|
||||
|
||||
```bash
|
||||
npm unpublish <package-name> -f
|
||||
$ npm unpublish <package-name> -f
|
||||
# 取消指定版本
|
||||
npm unpublish <package-name>@<version>
|
||||
$ npm unpublish <package-name>@<version>
|
||||
```
|
||||
|
||||
注意:如果您取消发布整个包,则必须在 24 小时后才能发布该包的任何新版本。
|
||||
注意:如果您取消发布整个包,则必须在 24 小时后才能发布该包的任何新版本
|
||||
|
||||
### 更改包裹可见性
|
||||
|
||||
```bash
|
||||
# 将公共包设为私有
|
||||
$ npm access restricted <package-name>
|
||||
# 公开私有包
|
||||
$ npm access public <package-name>
|
||||
# 授予私有包访问权限
|
||||
$ npm owner add <user> <your-package-name>
|
||||
```
|
||||
|
||||
### 要将包转移到 npm 用户帐户
|
||||
|
||||
```bash
|
||||
# 新维护者接受邀请
|
||||
$ npm owner add <their-username> <package-name>
|
||||
# 删除维护者
|
||||
$ npm owner rm <your-username> <package-name>
|
||||
# 写入启用了双因素身份验证
|
||||
$ npm owner add <their-username> <package-name> --otp=123456
|
||||
```
|
||||
|
||||
### 发布包 npmjs.org
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
$ npm publish
|
||||
# 第一次需要指定公开参数
|
||||
npm publish --access public
|
||||
$ npm publish --access public
|
||||
```
|
||||
|
||||
发布公开包,到 npmjs.org
|
||||
发布公开包,到 [npmjs.org](https://docs.npmjs.com)
|
||||
|
||||
### 使用 nrm 切换 registry
|
||||
|
||||
```bash
|
||||
$ npm install -g nrm # 安装 nrm 包
|
||||
# 查看 registry 列表
|
||||
$ nrm ls
|
||||
# 将注册表切换到 cnpm
|
||||
$ nrm use cnpm
|
||||
```
|
||||
|
||||
配置
|
||||
---
|
||||
@ -188,15 +170,27 @@ npm publish --access public
|
||||
|
||||
|
||||
### 配置内容
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```ini
|
||||
# last modified: 01 Jan 2016
|
||||
; Set a new registry for a scoped package
|
||||
@myscope:registry=https://registry.npmmirror.com
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
注释使用 `#`, `;` 放置到一行的开头。`.npmrc` 文件由指定此注释语法的 [`npm/ini`](https://github.com/npm/ini) 解析
|
||||
注释使用 `#`, `;` 放置到一行的开头, [`.npmrc`](https://docs.npmjs.com/cli/v8/configuring-npm/npmrc) 文件由指定此注释语法的 [`npm/ini`](https://github.com/npm/ini) 解析
|
||||
|
||||
|
||||
### registry
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`npm` | https://registry.npmjs.org/
|
||||
`yarn` | https://registry.yarnpkg.com/
|
||||
`tencent` | https://mirrors.cloud.tencent.com/npm/
|
||||
`cnpm` | https://r.cnpmjs.org/
|
||||
`taobao` | https://registry.npmmirror.com/
|
||||
`npmMirror` | https://skimdb.npmjs.com/registry/
|
||||
|
||||
### `.npmignore`
|
||||
|
||||
@ -223,7 +217,7 @@ npm publish --access public
|
||||
$ npm install -g <package-name> --registry=https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
将配置放置在 `.npmrc` 全局配置文件中,或者在项目的根目录中。
|
||||
将配置放置在 [`.npmrc`](https://docs.npmjs.com/cli/v8/configuring-npm/npmrc) 全局配置文件中,或者在项目的根目录中。
|
||||
|
||||
```ini
|
||||
; registry=https://registry.npmjs.org/
|
||||
@ -241,7 +235,7 @@ registry=https://registry.npmmirror.com
|
||||
替换 npm 仓库地址为 npmmirror(淘宝) 镜像地址
|
||||
|
||||
```bash
|
||||
npm config set registry https://registry.npmmirror.com
|
||||
$ npm config set registry https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
请参阅:[npmmirror 中国镜像站](https://npmmirror.com/)
|
||||
|
638
docs/postgres.md
Normal file
638
docs/postgres.md
Normal file
@ -0,0 +1,638 @@
|
||||
PostgreSQL 备忘清单
|
||||
===
|
||||
|
||||
[PostgreSQL](https://www.postgresql.org/docs/current/) 备忘清单为您提供了常用的 PostgreSQL 命令和语句。
|
||||
|
||||
|
||||
入门
|
||||
---------------
|
||||
|
||||
### 入门
|
||||
|
||||
切换和连接
|
||||
|
||||
```shell
|
||||
$ sudo -u postgres psql
|
||||
```
|
||||
|
||||
列出所有数据库
|
||||
|
||||
```shell
|
||||
postgres=# \l
|
||||
```
|
||||
|
||||
连接到名为 postgres 的数据库
|
||||
|
||||
```shell
|
||||
postgres=# \c postgres
|
||||
```
|
||||
|
||||
断开
|
||||
|
||||
```shell
|
||||
postgres=# \q
|
||||
postgres=# \!
|
||||
```
|
||||
|
||||
|
||||
### psql 命令
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
参数 | 示例 | 说明
|
||||
:- |- | -
|
||||
`[-d] <database>` | psql -d mydb | 连接到数据库
|
||||
`-U` | psql -U john mydb | 以特定用户身份连接
|
||||
`-h` `-p` | psql -h localhost -p 5432 mydb | 连接到主机/端口
|
||||
`-U` `-h` `-p` `-d` | psql -U admin -h 192.168.1.5 -p 2506 -d mydb | 连接远程 PostgreSQL
|
||||
`-W` | psql -W mydb | 强制密码
|
||||
`-c` | psql -c '\c postgres' -c '\dt' | 执行 SQL 查询或命令
|
||||
`-H` | psql -c "\l+" -H postgres > database.html | 生成 HTML 报告
|
||||
`-l` | psql -l | 列出所有数据库
|
||||
`-f` | psql mydb -f file.sql | 从文件执行命令
|
||||
`-V` | psql -V | 打印 psql 版本
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
|
||||
### 获得帮助
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\h` | SQL 命令语法帮助
|
||||
`\h` DELETE | DELETE SQL 语句语法
|
||||
`\?` | PostgreSQL 命令列表
|
||||
|
||||
在 PostgreSQL 控制台中运行
|
||||
|
||||
PostgreSQL 工作
|
||||
-------
|
||||
|
||||
### Recon 观察
|
||||
|
||||
显示版本
|
||||
|
||||
```sql
|
||||
SHOW SERVER_VERSION;
|
||||
```
|
||||
|
||||
显示系统状态
|
||||
|
||||
```sql
|
||||
\conninfo
|
||||
```
|
||||
|
||||
显示环境变量
|
||||
|
||||
```sql
|
||||
SHOW ALL;
|
||||
```
|
||||
|
||||
列出用户
|
||||
|
||||
```sql
|
||||
SELECT rolname FROM pg_roles;
|
||||
```
|
||||
|
||||
显示当前用户
|
||||
|
||||
```sql
|
||||
SELECT current_user;
|
||||
```
|
||||
|
||||
显示当前用户的权限
|
||||
|
||||
```sql
|
||||
\du
|
||||
```
|
||||
|
||||
显示当前数据库
|
||||
|
||||
```sql
|
||||
SELECT current_database();
|
||||
```
|
||||
|
||||
显示数据库中的所有表
|
||||
|
||||
```sql
|
||||
\dt
|
||||
```
|
||||
|
||||
列出函数
|
||||
|
||||
```sql
|
||||
\df <schema>
|
||||
```
|
||||
|
||||
### Databases 数据库
|
||||
|
||||
列出数据库
|
||||
|
||||
```sql
|
||||
\l
|
||||
```
|
||||
|
||||
连接到数据库
|
||||
|
||||
```sql
|
||||
\c <database_name>
|
||||
```
|
||||
|
||||
显示当前数据库
|
||||
|
||||
```sql
|
||||
SELECT current_database();
|
||||
```
|
||||
|
||||
[创建数据库](http://www.postgresql.org/docs/current/static/sql-createdatabase.html)
|
||||
|
||||
```sql
|
||||
CREATE DATABASE <database_name> WITH OWNER <username>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[删除数据库](http://www.postgresql.org/docs/current/static/sql-dropdatabase.html)
|
||||
|
||||
```sql
|
||||
DROP DATABASE IF EXISTS <database_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[重命名数据库](http://www.postgresql.org/docs/current/static/sql-alterdatabase.html)
|
||||
|
||||
```sql
|
||||
ALTER DATABASE <old_name> RENAME TO <new_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Tables 表
|
||||
|
||||
列出当前数据库中的表
|
||||
|
||||
```sql
|
||||
\dt
|
||||
SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
全局列表
|
||||
|
||||
```sql
|
||||
\dt *.*.
|
||||
SELECT * FROM pg_catalog.pg_tables
|
||||
```
|
||||
|
||||
列表表架构
|
||||
|
||||
```sql
|
||||
\d <table_name>
|
||||
\d+ <table_name>
|
||||
SELECT column_name, data_type, character_maximum_length
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = '<table_name>';
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[创建表](http://www.postgresql.org/docs/current/static/sql-createtable.html)
|
||||
|
||||
```sql
|
||||
CREATE TABLE <table_name>(
|
||||
<column_name> <column_type>,
|
||||
<column_name> <column_type>
|
||||
);
|
||||
```
|
||||
|
||||
创建表,主键自增
|
||||
|
||||
```sql
|
||||
CREATE TABLE <table_name> (
|
||||
<column_name> SERIAL PRIMARY KEY
|
||||
);
|
||||
```
|
||||
|
||||
[删除表](http://www.postgresql.org/docs/current/static/sql-droptable.html)
|
||||
|
||||
```sql
|
||||
DROP TABLE IF EXISTS <table_name> CASCADE;
|
||||
```
|
||||
|
||||
### Permissions 权限
|
||||
|
||||
成为 postgres 用户,如果您有权限错误
|
||||
|
||||
```shell
|
||||
sudo su - postgres
|
||||
psql
|
||||
```
|
||||
|
||||
[授予](http://www.postgresql.org/docs/current/static/sql-grant.html) 对数据库的所有权限
|
||||
|
||||
```sql
|
||||
GRANT ALL PRIVILEGES ON DATABASE <db_name> TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予数据库连接权限
|
||||
|
||||
```sql
|
||||
GRANT CONNECT ON DATABASE <db_name> TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予架构权限
|
||||
|
||||
```sql
|
||||
GRANT USAGE ON SCHEMA public TO <user_name>;
|
||||
```
|
||||
|
||||
授予函数权限
|
||||
|
||||
```sql
|
||||
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予在所有表上选择、更新、插入、删除的权限
|
||||
|
||||
```sql
|
||||
GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA public TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
在表上授予权限
|
||||
|
||||
```sql
|
||||
GRANT SELECT, UPDATE, INSERT ON <table_name> TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
授予对表的选择权限
|
||||
|
||||
```sql
|
||||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <user_name>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Columns 列
|
||||
|
||||
[添加栏目](http://www.postgresql.org/docs/current/static/sql-altertable.html)
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name> IF EXISTS
|
||||
ADD <column_name> <data_type> [<constraints>];
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
更新栏
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name> IF EXISTS
|
||||
ALTER <column_name> TYPE <data_type> [<constraints>];
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
删除列
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name> IF EXISTS
|
||||
DROP <column_name>;
|
||||
```
|
||||
|
||||
将列更新为自增主键
|
||||
|
||||
```sql
|
||||
ALTER TABLE <table_name>
|
||||
ADD COLUMN <column_name> SERIAL PRIMARY KEY;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
使用自动递增的主键插入表中
|
||||
|
||||
```sql
|
||||
INSERT INTO <table_name>
|
||||
VALUES (DEFAULT, <value1>);
|
||||
INSERT INTO <table_name> (<column1_name>,<column2_name>)
|
||||
VALUES ( <value1>,<value2> );
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### Data 数据
|
||||
|
||||
[选择](http://www.postgresql.org/docs/current/static/sql-select.html) 所有数据
|
||||
|
||||
```sql
|
||||
SELECT * FROM <table_name>;
|
||||
```
|
||||
|
||||
读取一行数据
|
||||
|
||||
```sql
|
||||
SELECT * FROM <table_name> LIMIT 1;
|
||||
```
|
||||
|
||||
搜索数据
|
||||
|
||||
```sql
|
||||
SELECT * FROM <table_name> WHERE <column_name> = <value>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[插入](http://www.postgresql.org/docs/current/static/sql-insert.html) 数据
|
||||
|
||||
```sql
|
||||
INSERT INTO <table_name> VALUES( <value_1>, <value_2> );
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[更新](http://www.postgresql.org/docs/current/static/sql-update.html) 数据
|
||||
|
||||
```sql
|
||||
UPDATE <table_name>
|
||||
SET <column_1> = <value_1>, <column_2> = <value_2>
|
||||
WHERE <column_1> = <value>;
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
[删除](http://www.postgresql.org/docs/current/static/sql-delete.html) 所有数据
|
||||
|
||||
```sql
|
||||
DELETE FROM <table_name>;
|
||||
```
|
||||
|
||||
删除特定数据
|
||||
|
||||
```sql
|
||||
DELETE FROM <table_name>
|
||||
WHERE <column_name> = <value>;
|
||||
```
|
||||
|
||||
### Users 用户
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
列出角色
|
||||
|
||||
```sql
|
||||
SELECT rolname FROM pg_roles;
|
||||
```
|
||||
|
||||
[创建用户](http://www.postgresql.org/docs/current/static/sql-createuser.html)
|
||||
|
||||
```sql
|
||||
CREATE USER <user_name> WITH PASSWORD '<password>';
|
||||
```
|
||||
|
||||
[删除用户](http://www.postgresql.org/docs/current/static/sql-dropuser.html)
|
||||
|
||||
```sql
|
||||
DROP USER IF EXISTS <user_name>;
|
||||
```
|
||||
|
||||
[更改](http://www.postgresql.org/docs/current/static/sql-alterrole.html) 用户密码
|
||||
|
||||
```sql
|
||||
ALTER ROLE <user_name> WITH PASSWORD '<password>';
|
||||
```
|
||||
|
||||
### Schema
|
||||
|
||||
列出 Schemas
|
||||
|
||||
```sql
|
||||
\dn
|
||||
SELECT schema_name FROM information_schema.schemata;
|
||||
SELECT nspname FROM pg_catalog.pg_namespace;
|
||||
```
|
||||
|
||||
[创建架构](http://www.postgresql.org/docs/current/static/sql-createschema.html)
|
||||
|
||||
```sql
|
||||
CREATE SCHEMA IF NOT EXISTS <schema_name>;
|
||||
```
|
||||
|
||||
[删除模式](http://www.postgresql.org/docs/current/static/sql-dropschema.html)
|
||||
|
||||
```sql
|
||||
DROP SCHEMA IF EXISTS <schema_name> CASCADE;
|
||||
```
|
||||
|
||||
PostgreSQL 命令
|
||||
-----------
|
||||
|
||||
### 表
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\d <table>` | 描述表
|
||||
`\d+ <table>` | 详细描述表格
|
||||
`\dt` | 列出当前模式中的表
|
||||
`\dt *.*` | 列出所有模式中的表
|
||||
`\dt <schema>.*` | 列出架构的表
|
||||
`\dp` | 列出表访问权限
|
||||
`\det[+]` | 列出外部表
|
||||
|
||||
|
||||
|
||||
### 查询缓冲区
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\e [FILE]` | 编辑查询缓冲区(或文件)
|
||||
`\ef [FUNC]` | 编辑函数定义
|
||||
`\p` | 显示内容
|
||||
`\r` | 重置(清除)查询缓冲区
|
||||
`\s [FILE]` | 显示历史记录或保存到文件
|
||||
`\w FILE` | 将查询缓冲区写入文件
|
||||
|
||||
|
||||
|
||||
### 信息
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\l[+]` | 列出所有数据库
|
||||
`\dn[S+]` | 列出架构
|
||||
`\di[S+]` | 列出索引
|
||||
`\du[+]` | 列出角色
|
||||
`\ds[S+]` | 列出序列
|
||||
`\df[antw][S+]` | 列出函数
|
||||
`\deu[+]` | 列出用户映射
|
||||
`\dv[S+]` | 列表视图
|
||||
`\dl` | 列出大对象
|
||||
`\dT[S+]` | 列出数据类型
|
||||
`\da[S]` | 列出聚合
|
||||
`\db[+]` | 列出表空间
|
||||
`\dc[S+]` | 列出转化
|
||||
`\dC[+]` | 列出演员表
|
||||
`\ddp` | 列出默认权限
|
||||
`\dd[S]` | 显示对象描述
|
||||
`\dD[S+]` | 列出域
|
||||
`\des[+]` | 列出国外服务器
|
||||
`\dew[+]` | 列出外部数据包装器
|
||||
`\dF[+]` | 列出文本搜索配置
|
||||
`\dFd[+]` | 列出文本搜索词典
|
||||
`\dFp[+]` | 列出文本搜索解析器
|
||||
`\dFt[+]` | 列出文本搜索模板
|
||||
`\dL[S+]` | 列出程序语言
|
||||
`\do[S]` | 列出运算符
|
||||
`\dO[S+]` | 列出排序规则
|
||||
`\drds` | 列出每个数据库的角色设置
|
||||
`\dx[+]` | 列出扩展
|
||||
|
||||
`S`:显示系统对象,`+`:附加细节
|
||||
|
||||
|
||||
### 连接
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\c [DBNAME]` | 连接到新数据库
|
||||
`\encoding [ENCODING]` | 显示或设置客户端编码
|
||||
`\password [USER]` | 更改密码
|
||||
`\conninfo` | 显示信息
|
||||
|
||||
|
||||
### 格式化
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\a` | 在未对齐和对齐之间切换
|
||||
`\C [STRING]` | 设置表格标题,如果没有则取消设置
|
||||
`\f [STRING]` | 显示或设置未对齐的字段分隔符
|
||||
`\H` | 切换 HTML 输出模式
|
||||
`\t [on\|off]` | 仅显示行
|
||||
`\T [STRING]` | 设置或取消设置 HTML \<table\> 标签属性
|
||||
`\x [on\|off]` | 切换扩展输出
|
||||
|
||||
### 输入输出
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\copy ...` | 导入/导出表 _另见:_ [复制](#导入导出-csv)
|
||||
`\echo [STRING]` | 打印字符串
|
||||
`\i FILE` | 执行文件
|
||||
`\o [FILE]` | 将所有结果导出到文件
|
||||
`\qecho [STRING]` | 输出流的字符串
|
||||
|
||||
### 变量
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\prompt [TEXT] NAME` | 设置变量
|
||||
`\set [NAME [VALUE]]` | 设置变量 _(如果没有参数,则列出所有变量)_
|
||||
`\unset NAME` | 删除变量
|
||||
|
||||
### 杂项
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`\cd [DIR]` | 更改目录
|
||||
`\timing [on\|off]` | 切换时间
|
||||
`\! [COMMAND]` | 在shell中执行
|
||||
`\! ls -l` | 在shell中列出所有
|
||||
|
||||
### 大对象
|
||||
|
||||
- `\lo_export LOBOID FILE`
|
||||
- `\lo_import FILE [COMMENT]`
|
||||
- `\lo_list`
|
||||
- `\lo_unlink LOBOID`
|
||||
|
||||
|
||||
各种各样的
|
||||
-------------
|
||||
|
||||
### 备份
|
||||
|
||||
使用 pg_dumpall 备份所有数据库
|
||||
|
||||
```shell
|
||||
$ pg_dumpall -U postgres > all.sql
|
||||
```
|
||||
|
||||
使用 pg_dump 备份数据库
|
||||
|
||||
```shell
|
||||
$ pg_dump -d mydb -f mydb_backup.sql
|
||||
```
|
||||
|
||||
- `-a` 只转储数据,而不是模式(schema)
|
||||
- `-s` 只转储模式,不转储数据
|
||||
- `-c` 在重新创建之前删除数据库
|
||||
- `-C` 还原前创建数据库
|
||||
- `-t` 仅转储命名表
|
||||
- `-F` 格式(`c`:自定义,`d`:目录,`t`:tar)
|
||||
<!--rehype:className=style-none-->
|
||||
|
||||
使用 `pg_dump -?` 获取完整的选项列表
|
||||
|
||||
### 恢复
|
||||
|
||||
使用 psql 恢复数据库
|
||||
|
||||
```shell
|
||||
$ psql -U user mydb < mydb_backup.sql
|
||||
```
|
||||
|
||||
使用 pg_restore 恢复数据库
|
||||
|
||||
```shell
|
||||
$ pg_restore -d mydb mydb_backup.sql -c
|
||||
```
|
||||
|
||||
- `-U` 指定数据库用户
|
||||
- `-c` 在重新创建之前删除数据库
|
||||
- `-C` 还原前创建数据库
|
||||
- `-e` 如果遇到错误退出
|
||||
- `-F` 格式(`c`:自定义,`d`:目录,`t`:tar,`p`:纯文本sql(默认))
|
||||
<!--rehype:className=style-none-->
|
||||
|
||||
使用 `pg_restore -?` 获取完整的选项列表
|
||||
|
||||
### 远程访问
|
||||
|
||||
获取 postgresql.conf 的位置
|
||||
|
||||
```shell
|
||||
$ psql -U postgres -c 'SHOW config_file'
|
||||
```
|
||||
|
||||
附加到 postgresql.conf
|
||||
|
||||
```shell
|
||||
listen_addresses = '*'
|
||||
```
|
||||
|
||||
附加到 pg_hba.conf(与 postgresql.conf 相同的位置)
|
||||
|
||||
```shell
|
||||
host all all 0.0.0.0/0 md5
|
||||
host all all ::/0 md5
|
||||
```
|
||||
|
||||
重启 PostgreSQL 服务器
|
||||
|
||||
```shell
|
||||
$ sudo systemctl restart postgresql
|
||||
```
|
||||
|
||||
### 导入/导出 CSV
|
||||
|
||||
将表格导出为 CSV 文件
|
||||
|
||||
```sql
|
||||
\copy table TO '<path>' CSV
|
||||
\copy table(col1,col1) TO '<path>' CSV
|
||||
\copy (SELECT...) TO '<path>' CSV
|
||||
```
|
||||
|
||||
将 CSV 文件导入表格
|
||||
|
||||
```sql
|
||||
\copy table FROM '<path>' CSV
|
||||
\copy table(col1,col1) FROM '<path>' CSV
|
||||
```
|
||||
|
||||
另见:[复制](https://www.postgresql.org/docs/current/sql-copy.html)
|
||||
|
||||
Also see
|
||||
--------
|
||||
- [Posgres-cheatsheet](https://gist.github.com/apolloclark/ea5466d5929e63043dcf#posgres-cheatsheet) _(gist.github.com)_
|
@ -29,7 +29,7 @@ HTML 存放在仓库根目录下的 `dist` 目录中,将 `dist/index.html` 静
|
||||
|
||||
### 介绍
|
||||
|
||||
在备忘清单采用 `HTML 注释语法`,标识网站布局和一些样式,目的是为了在 `GitHub` 中也是正常毫无瑕疵的预览 `Markdown`。
|
||||
在备忘清单采用 `HTML 注释语法`,标识网站布局和一些样式,目的是为了在 `GitHub` 中也是正常毫无瑕疵的预览 [`Markdown`](./markdown.md)。
|
||||
|
||||
```markdown
|
||||
### 卡片标题
|
||||
@ -45,7 +45,7 @@ HTML 存放在仓库根目录下的 `dist` 目录中,将 `dist/index.html` 静
|
||||
### 注释语法介绍
|
||||
<!--rehype:wrap-class=row-span-3&style=color:black;background-color: #d7a100;-->
|
||||
|
||||
- 在某个 Markdown 语法下方或者后面,添加 HTML注释
|
||||
- 在某个 [`Markdown`](./markdown.md) 语法下方或者后面,添加 HTML注释
|
||||
- 以 `<!--rehype:` 开始,`-->` 结束,包裹参数内容
|
||||
- 内容采用 URL 参数的字符拼接方式
|
||||
|
||||
@ -78,7 +78,7 @@ HTML 存放在仓库根目录下的 `dist` 目录中,将 `dist/index.html` 静
|
||||
---- | ----
|
||||
`body-style` | 包裹所有卡片`外壳`的样式
|
||||
`body-class` | 用于卡片栏布局,添加`类`名
|
||||
`wrap-style` | 卡片栏添加 CSS 样式
|
||||
`wrap-style` | 卡片栏添加 [CSS](./css.md) 样式
|
||||
`wrap-class` | 用于卡片占位,添加`类`名
|
||||
|
||||
### 文字颜色
|
||||
@ -135,7 +135,7 @@ export const Student = (
|
||||
);
|
||||
```
|
||||
|
||||
上面 `{1,4-5}` 行代码高亮,下面是 `Markdown` 代码示例
|
||||
上面 `{1,4-5}` 行代码高亮,下面是 [`Markdown`](./markdown.md) 代码示例
|
||||
|
||||
```markdown
|
||||
```jsx {1,4-5}
|
||||
@ -258,7 +258,7 @@ const school = <div>学校</div>;
|
||||
<b>这里是你的 HTML 代码</b>
|
||||
```
|
||||
|
||||
上面的 `markdown` 代码在 `meta` 位置添加 `preview` 标识,HTML 代码将被执行预览
|
||||
上面的 [`markdown`](./markdown.md) 代码在 `meta` 位置添加 `preview` 标识,[HTML](./html.md) 代码将被执行预览
|
||||
|
||||
### KaTeX 数学渲染
|
||||
|
||||
@ -267,7 +267,7 @@ c = \pm\sqrt{a^2 + b^2}
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
```
|
||||
|
||||
上面示例 `Markdown` 代码源码
|
||||
上面示例 [`Markdown`](./markdown.md) 代码源码
|
||||
|
||||
```markdown {1}
|
||||
```KaTeX
|
||||
@ -275,7 +275,7 @@ L = \frac{1}{2} \rho v^2 S C_L
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
```
|
||||
|
||||
还可以单行展示 `KaTeX:c = \pm\sqrt{a^2 + b^2}`,需要标记 \`KaTeX:数学公式\` 将被显示成数学公式,这是基于 [KaTeX](https://katex.org/) 生成
|
||||
还可以单行展示 `KaTeX:c = \pm\sqrt{a^2 + b^2}`,需要标记 <code>\`KaTeX:数学公式\`</code> 将被显示成数学公式,这是基于 [KaTeX](https://katex.org/) 生成
|
||||
|
||||
布局
|
||||
---
|
||||
@ -368,7 +368,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### H3 Title 1
|
||||
@ -393,7 +393,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@ -441,7 +441,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@ -465,7 +465,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈┈┈┈┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@ -489,7 +489,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@ -513,7 +513,7 @@ H2 部分
|
||||
╰┈┈┈┈┈┈┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
@ -537,7 +537,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
H2 部分
|
||||
@ -568,7 +568,7 @@ H2 部分
|
||||
╰┈┈┈╯ ╰┈┈┈╯ ╰┈┈┈╯
|
||||
```
|
||||
|
||||
上面布局效果 Markdown 源码:
|
||||
上面布局效果 [Markdown](./markdown.md) 源码:
|
||||
|
||||
```markdown
|
||||
### Title 1
|
||||
|
107
docs/xcode.md
Normal file
107
docs/xcode.md
Normal file
@ -0,0 +1,107 @@
|
||||
Xcode 备忘清单
|
||||
====
|
||||
|
||||
这个 Xcode 快速参考备忘单显示了它的键盘快捷键和命令。
|
||||
|
||||
Xcode
|
||||
---
|
||||
|
||||
### 搜索
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + F` | 在文件中查找
|
||||
`Cmd + Option + F` | 在文件中查找和替换
|
||||
`Cmd + Shift + F` | 在项目中查找
|
||||
`Cmd + Option + Shift + F` | 在项目中查找和替换
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 选项卡
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + T` | 新选项卡
|
||||
`Cmd + }` | 上一个选项卡
|
||||
`Cmd + {` | 下一个选项卡
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 导航
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Shift + O` | 快速打开
|
||||
`Cmd + J` | 专注于编辑
|
||||
`Cmd + Ctrl + UP` | 下一个对手
|
||||
`Cmd + Ctrl + DOWN` | 上一个对手
|
||||
`Cmd + Ctrl + RIGHT` | 下一个最近的文件
|
||||
`Cmd + Ctrl + LEFT` | 上一个 最近的文件
|
||||
`Cmd + click` | 符号的定义
|
||||
`Cmd + L` | 去线
|
||||
`Cmd + Option + LEFT` | 折叠部分
|
||||
`Cmd + Option + RIGHT` | 展开部分
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 调试
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Shift + Y` | 切换调试区域
|
||||
`Cmd + '` | 下一期
|
||||
`Cmd + "` | 上一期
|
||||
`Cmd + \` | 添加/删除断点
|
||||
`Cmd + Y` | 活动/非活动断点
|
||||
`Cmd + K` | 清除控制台
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 导航器(左侧面板)
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + 0` | 显示隐藏
|
||||
`Cmd + 1-8` | 切换标签
|
||||
`Option + click` | 打开助理编辑器
|
||||
`Shift + Option + click` | 决定在哪里打开
|
||||
`double click` | 在新窗口中打开
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 编辑
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Option + ENTER` | 显示助理编辑器
|
||||
`Cmd + ENTER` | 隐藏助理编辑器
|
||||
`Ctrl + SPACE or ESC` | 切换完成
|
||||
`Cmd + ]` | 缩进部分
|
||||
`Cmd + [` | 突出部分
|
||||
`Ctrl + i` | 修复缩进
|
||||
`Cmd + /` | 评论/取消评论
|
||||
`Cmd + Option + [` | 向上移动队列
|
||||
`Cmd + Option + ]` | 下移线
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
|
||||
### 实用程序(右面板)
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + Option + 0` | 显示隐藏
|
||||
`Cmd + Option + 1-9` | 转到选项卡
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 调试和运行
|
||||
|
||||
快捷键 | 描述
|
||||
:---- | ----
|
||||
`Cmd + B` | 建造
|
||||
`Cmd + R` | 运行
|
||||
`Cmd + .` | 停止
|
||||
`Cmd + Shift + B` | 分析
|
||||
`Cmd + U` | 测试
|
||||
`Cmd + Shift + K` | 清理
|
||||
<!--rehype:className=shortcuts-->
|
423
docs/yum.md
Normal file
423
docs/yum.md
Normal file
@ -0,0 +1,423 @@
|
||||
YUM 备忘清单
|
||||
===
|
||||
|
||||
这个 YUM 快速参考备忘单显示了它的常用命令使用清单。
|
||||
|
||||
YUM 清单查询
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
yum(`Y`ellow dog `U`pdater, `M`odified)是一个在 `Fedora` 和 `RedHat` 以及 SUSE 中的 `Shell` 前端软件包管理器
|
||||
|
||||
```bash
|
||||
$ yum [options] [command] [package ...]
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- [YUM 官方网站](http://yum.baseurl.org/) _(yum.baseurl.org)_
|
||||
- [Fedora 中的 Yum 文档](https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/ch-yum.html) _(fedoraproject.org)_
|
||||
- [CentOS 中的 Yum 文档](http://wiki.centos.org/PackageManagement/Yum/) _(wiki.centos.org)_
|
||||
- [Scientific Linux 中的 Yum 文档](https://www.scientificlinux.org/documentation/faq/yum.apt.repo) _(scientificlinux.org)_
|
||||
|
||||
### YUM 查询
|
||||
|
||||
子命令描述和任务
|
||||
|
||||
#### help
|
||||
|
||||
显示 yum 命令和选项
|
||||
|
||||
```bash
|
||||
yum help
|
||||
```
|
||||
|
||||
显示 yum 子命令和选项
|
||||
|
||||
### 单独的包
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
#### list
|
||||
|
||||
列出存储库中的包名称
|
||||
|
||||
```bash
|
||||
# 列出存储库中的包名称
|
||||
yum list available
|
||||
# 列出所有可用的包
|
||||
yum list installed
|
||||
# 列出所有已安装的包
|
||||
yum list all
|
||||
# 列出已安装和可用的软件包
|
||||
yum list kernel
|
||||
```
|
||||
|
||||
#### info
|
||||
|
||||
列出已安装和可用的内核包
|
||||
|
||||
```bash
|
||||
# 列出有关 `vsftpd` 软件包的信息
|
||||
$ yum info vsftpd
|
||||
```
|
||||
|
||||
#### deplist
|
||||
|
||||
显示包的依赖项
|
||||
|
||||
```bash
|
||||
$ yum deplist nfs-utils
|
||||
```
|
||||
|
||||
列出依赖项和提供它们的包
|
||||
|
||||
#### provides
|
||||
|
||||
```bash
|
||||
# 查找提供查询文件的包
|
||||
$ yum provides “*bin/top”
|
||||
# 显示包含 README.top 文件的包
|
||||
$ yum provides “*/README.top”
|
||||
```
|
||||
|
||||
#### search
|
||||
|
||||
```bash
|
||||
# 查找名称或描述中带有 samba 的软件包
|
||||
$ yum search samba
|
||||
```
|
||||
|
||||
#### updateinfo
|
||||
|
||||
```bash
|
||||
# 获取有关可用软件包更新的信息
|
||||
$ yum updateinfo security
|
||||
```
|
||||
|
||||
获取有关可用 security 更新的信息
|
||||
|
||||
### 包组
|
||||
|
||||
#### grouplist
|
||||
|
||||
列出已安装和可用软件包组的名称
|
||||
|
||||
#### groupinfo
|
||||
|
||||
```bash
|
||||
# 查看 Web 服务器组中的包
|
||||
$ yum groupinfo "Web Server"
|
||||
```
|
||||
|
||||
#### check-update
|
||||
|
||||
查询存储库以获取可用的软件包更新
|
||||
|
||||
### 管理 YUM 存储库
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### repolist
|
||||
|
||||
显示启用的软件存储库
|
||||
|
||||
#### repoinfo
|
||||
|
||||
显示有关启用的 `yum` 存储库的信息 *
|
||||
|
||||
```bash
|
||||
$ yum repoinfo rhel-7-server-rpms
|
||||
```
|
||||
|
||||
请参阅有关 rhel-7-server-rpms 存储库的信息
|
||||
|
||||
#### repo-pkgs
|
||||
|
||||
使用特定存储库中的包 *
|
||||
|
||||
```bash
|
||||
# 列出来自 my-rpms 存储库的软件包
|
||||
$ yum repo-pkgs my-rpms list
|
||||
# 从 my-rpms repo 安装所有软件包
|
||||
$ yum repo-pkgs my-rpms install
|
||||
# 从 my-rpms 存储库中删除所有软件包
|
||||
$ yum repo-pkgs my-rpms remove
|
||||
```
|
||||
|
||||
#### makecache
|
||||
|
||||
下载 `yum` 存储库数据到缓存
|
||||
|
||||
### 故障排除和维护 YUM
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### check
|
||||
|
||||
检查本地 RPM 数据库是否有问题(运行了很长时间)
|
||||
|
||||
#### history
|
||||
|
||||
```bash
|
||||
# 列出所有 yum 安装、更新和清理操作
|
||||
$ yum history list
|
||||
# 显示 yum info 3 的详细信息
|
||||
$ yum history info 3
|
||||
# 撤消事务 3 中的 yum 操作
|
||||
$ yum history undo 3
|
||||
# 重做事务 3 中撤消的 yum 操作
|
||||
$ yum history redo 3
|
||||
```
|
||||
|
||||
#### clean
|
||||
|
||||
```bash
|
||||
# 删除缓存中保存的包
|
||||
$ yum clean packages
|
||||
# 从缓存中清除所有包和元数据
|
||||
$ yum clean all
|
||||
```
|
||||
|
||||
清除缓存的包数据
|
||||
|
||||
#### fssnapshot
|
||||
|
||||
列出 LVM 快照(帮助在包更新后回滚)
|
||||
|
||||
#### fs
|
||||
|
||||
```bash
|
||||
# 列出启用的文件系统过滤器
|
||||
$ yum fs filters
|
||||
# 过滤所有正在安装的文档(小心!)
|
||||
$ yum fs documentation
|
||||
```
|
||||
|
||||
对文件系统采取行动(防止在最小系统上安装 doc 或语言文件)非常有用!
|
||||
|
||||
### 使用 YUM 管理语言包
|
||||
|
||||
#### langavailable
|
||||
|
||||
列出已安装的语言 *
|
||||
|
||||
#### langinfo
|
||||
|
||||
```bash
|
||||
# 列出与西班牙语相关的软件包
|
||||
$ yum langinfo es
|
||||
```
|
||||
|
||||
#### langinstall
|
||||
|
||||
```bash
|
||||
# 安装与西班牙语相关的软件包
|
||||
$ yum langinstall es
|
||||
```
|
||||
|
||||
#### langlist
|
||||
|
||||
列出已安装的语言 *
|
||||
|
||||
#### langremove
|
||||
|
||||
```bash
|
||||
# 删除与西班牙语相关的软件包
|
||||
$ yum langremove es
|
||||
```
|
||||
|
||||
### 使用 YUM 安装、删除和升级软件包
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
#### install
|
||||
|
||||
```bash
|
||||
# 安装 vsftpd 包
|
||||
$ yum install vsftpd
|
||||
```
|
||||
|
||||
#### update
|
||||
|
||||
```bash
|
||||
# 使用可用更新更新所有软件包
|
||||
$ yum update
|
||||
# 更新 httpd 包(如果可用)
|
||||
$ yum update httpd
|
||||
# 应用与安全相关的包更新
|
||||
$ yum update --security
|
||||
```
|
||||
|
||||
#### update-to
|
||||
|
||||
将一个或所有软件包更新到特定版本
|
||||
|
||||
#### upgrade
|
||||
|
||||
```bash
|
||||
$ yum -y upgrade
|
||||
```
|
||||
|
||||
更新包考虑过时,只升级所有包,不升级软件和系统内核
|
||||
|
||||
#### localinstall
|
||||
|
||||
```bash
|
||||
# 从本地文件、http 或 ftp 安装包
|
||||
$ yum localinstall abc-1-1.i686.rpm
|
||||
# 从本地目录安装 abc 包
|
||||
$ yum localinstall http://myrepo/abc-1-1.i686.rpm
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
从 FTP 站点安装 abc
|
||||
|
||||
#### downgrade
|
||||
|
||||
将软件包降级到早期版本
|
||||
|
||||
```bash
|
||||
$ yum downgrade abc
|
||||
```
|
||||
|
||||
将 abc 包降级到早期版本
|
||||
|
||||
#### reinstall
|
||||
|
||||
```bash
|
||||
# 重新安装 util-linux(以替换任何已删除的文件)
|
||||
$ yum reinstall util-linux
|
||||
```
|
||||
|
||||
#### swap
|
||||
|
||||
```bash
|
||||
# 删除 ftp 包并安装 lftp 包
|
||||
$ yum swap ftp lftp
|
||||
```
|
||||
|
||||
#### erase/remove
|
||||
|
||||
```bash
|
||||
# 删除 vsftpd 包和依赖
|
||||
$ yum remove vsftpd
|
||||
```
|
||||
|
||||
#### autoremove
|
||||
|
||||
```bash
|
||||
# 删除 httpd 和其他不需要的包
|
||||
$ yum autoremove httpd
|
||||
```
|
||||
|
||||
#### groupinstall
|
||||
|
||||
```bash
|
||||
# 安装 Web 服务器包
|
||||
$ yum groupinstall "Web server"
|
||||
```
|
||||
|
||||
### 更多 YUM 相关命令(安装 yum-utils 软件包)
|
||||
|
||||
#### find-repos-of-install
|
||||
|
||||
查找包来自哪个存储库
|
||||
|
||||
#### needs-restarting
|
||||
|
||||
查找已更新且需要重启的进程
|
||||
|
||||
#### repoclosure
|
||||
|
||||
从存储库中获取未满足的依赖项列表
|
||||
|
||||
#### repoquery
|
||||
|
||||
查询远程仓库和本地 `RPM` 数据库
|
||||
|
||||
```bash
|
||||
# 显示依赖包
|
||||
$ repoquery --requires --resolve bash
|
||||
```
|
||||
|
||||
#### reposync
|
||||
|
||||
将 `yum` 存储库同步到本地目录
|
||||
|
||||
```bash
|
||||
# 从 repo 获取包
|
||||
$ reposync -r rhel-atomic-host-beta-rpms
|
||||
```
|
||||
|
||||
#### repotrack
|
||||
|
||||
下载一个包及其所有依赖项
|
||||
|
||||
#### show-installed
|
||||
|
||||
列出已安装的 RPM 包和统计信息
|
||||
|
||||
#### verifytree
|
||||
|
||||
检查本地 yum 存储库的一致性
|
||||
|
||||
#### yum-complete-transaction
|
||||
|
||||
尝试完成未完成的 yum 交易
|
||||
|
||||
#### yumdb
|
||||
|
||||
检查或更改 yum 数据库
|
||||
|
||||
#### yumdownloader
|
||||
|
||||
```bash
|
||||
# 使用本地源离线安装 net-tools 工具包
|
||||
$ yumdownloader net-tools.x86_64
|
||||
# 使用 –destdir 参数设置下载的目标目录
|
||||
$ yumdownloader net-tools.x86_64 --destdir=/usr/local/bin/
|
||||
# 使用 –resolve 参数解决依赖关系并下载所需的安装包
|
||||
$ yumdownloader net-tools.x86_64 --resolve --destdir=/usr/local/bin/
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
从 repo 下载一个包到当前目录
|
||||
|
||||
### 不同 YUM 命令的常用选项
|
||||
|
||||
```bash
|
||||
yum --disableplugin=langpacks info vsftpd
|
||||
# 显示与正在运行的进程相关的包
|
||||
yum --enableplugin=ps ps
|
||||
yum install docker \
|
||||
--enablerepo=rhel-7-server-extras-rpm
|
||||
yum list available --disablerepo=epel
|
||||
# 下载 vsftpd 包到缓存
|
||||
yum install --downloadonly vsftpd
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-y` | 如果出现提示,假设是
|
||||
`--assumeno` | 如果提示,则假设否
|
||||
`-q` | 不产生任何输出
|
||||
`-v` | 产生额外的调试输出
|
||||
`--noplugins` | 运行命令而不加载任何 yum 插件
|
||||
`--disableplugin=` | 禁用单个命令的特定插件
|
||||
`--enableplugin=` | 启用已安装但当前已禁用的插件
|
||||
`--enablerepo=` | 为单个命令启用当前禁用的 repo(通配符可以)
|
||||
`--disablerepo=` | 为单个命令禁用当前启用的 repo(通配符可以)
|
||||
`--downloadonly` | 下载到 `/var/cache/yum/arch/prod/repo/packages/`,但不要安装
|
||||
`--filter-???=` | 代替???与vendors, rpm-groups, arches 和其他人一起过滤输出
|
||||
`--changelog` | 显示包的变更日志信息
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [YUM 官方网站](http://yum.baseurl.org/) _(yum.baseurl.org)_
|
||||
- [YUM 备忘清单(适用于红帽 RedHad 企业 Linux)](https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf) _(access.redhat.com)_
|
||||
- [用 yum 管理软件包](http://prefetch.net/articles/yum.html) _(prefetch.net)_
|
||||
- [Fedora 中的 Yum 文档](https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/ch-yum.html) _(fedoraproject.org)_
|
||||
- [CentOS 中的 Yum 文档](http://wiki.centos.org/PackageManagement/Yum/) _(wiki.centos.org)_
|
||||
- [Scientific Linux 中的 Yum 文档](https://www.scientificlinux.org/documentation/faq/yum.apt.repo) _(scientificlinux.org)_
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.16.0",
|
||||
"version": "1.18.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
|
3
scripts/assets/matlab.svg
Normal file
3
scripts/assets/matlab.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 170 155">
|
||||
<path fill="currentColor" d="M114.011719,0 C114.031753,0 114.051781,9.66838127e-05 114.071803,0.00028991369 L113.950625,0 C114.100589,0 114.249952,0.00491257692 114.398738,0.0147015257 C114.496091,0.0180986001 114.59346,0.0264563127 114.690679,0.0370869506 C114.763187,0.0481571338 114.835494,0.0572318789 114.907669,0.067464417 C114.971991,0.0739091229 115.036007,0.0841522806 115.099959,0.0953775501 C115.24595,0.122450074 115.39156,0.152173631 115.536656,0.18662408 C115.540798,0.188498498 115.544794,0.189486731 115.54879,0.190478791 C119.122197,1.04453486 122.383831,4.76737051 125.66002,10.8263087 C134.504866,26.8199813 143.233527,58.3720491 155.079417,90.6337197 C159.654754,102.628081 164.55935,114.497108 169.788199,126.226944 L169.804687,126.261915 C169.561883,126.036533 169.320725,125.810778 169.080287,125.584766 C157.868517,115.075569 148.22195,104.663526 137.239023,104.2475 C132.658523,104.354002 127.856902,106.798464 122.838279,110.852094 C115.884496,116.808357 108.801576,125.883622 101.371385,134.204547 C98.5874924,137.56095 95.5963582,140.611013 92.6231575,143.258032 C88.7439115,146.854737 84.755953,149.885794 80.6318234,151.86198 C77.8565289,153.320564 75.5138817,154.09239 73.9252344,154.03711 C73.9252344,154.03711 73.6050703,153.13142 73.0221211,151.57669 C72.3047411,149.730047 71.5034539,147.651723 70.6255994,145.430214 C66.7152626,135.747112 59.8767348,120.415838 53.1632895,113.088875 C51.6852935,111.572994 50.1641478,110.359882 48.6081822,109.545946 C44.005418,107.866712 38.8723879,108.38614 34.6886719,110.979493 L0.055,86.396 L48.3332422,66.8904688 L48.6560848,66.4654629 C53.451559,60.1199079 58.8698811,54.2694715 64.8303516,49.0016797 L64.5185432,49.2785154 C64.6217228,49.1857698 64.7250601,49.0931917 64.8285547,49.0007813 C68.8310937,46.8777734 76.3510156,48.0304688 90.1177734,30.9287109 C90.3414762,30.6490748 90.5626216,30.370121 90.781262,30.0919051 C92.8016022,27.5154524 94.6118072,25.0027302 96.2508432,22.5981511 L96.5028669,22.2275882 C105.052639,9.58238289 108.828956,0 113.950625,0 L113.994,0.001 Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
3
scripts/assets/postgres.svg
Normal file
3
scripts/assets/postgres.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.0 KiB |
3
scripts/assets/xcode.svg
Normal file
3
scripts/assets/xcode.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
|
||||
<path d="M19.06 5.333c.452-.194.774-.258 1.097-.194.516.13.774.516.968.71.194.387.903.774 1.226.839.258.064.71-.645 1.033-1.29.322-.582.516-1.356.451-1.55-.064-.193-.968-.58-1.161-.58-.13 0-.388.129-.84.064-.45-.064-.903-.58-1.16-.968-.453-.645-1.098-1.032-1.679-1.355C18.35.686 17.64.493 16.93.364 15.898.105 14.865-.088 13.833.04c-.58.064-1.29.129-1.807.323-.065 0-.194.193-.065.193s.581.065.581.065-.58.129-.58.258c0 .13.064.13.129.13.064 0 1.484-.065 2.065 0 .645.128 1.355.45 1.807 1.225.774 1.42.451 2.775.258 3.227-.968 2.13-8.648 15.23-9.035 16.133-.387.903-.516 1.484.581 2.065s1.678.322 2-.065c.388-.516 7.034-17.165 9.293-18.262zm-3.614 8.711h1.549c1.032 0 1.226.517 1.226.71.065.516-.194 1.162-1.226 1.162h-.968l.774 1.29c.452.775.258 1.162 0 1.42-.387.387-1.226.387-1.677-.452l-.904-1.548c-.645 1.42-1.29 2.968-2.065 4.775h4.001c1.936 0 3.55-1.613 3.55-3.55V6.56c-.065-.13-.194-.065-.259 0-.387.451-1.484 2-4 7.485zm-9.809 8.002h-.322a4.186 4.186 0 0 1-4.195-4.194V7.01a4.186 4.186 0 0 1 4.195-4.195h9.357c-.194-.194-.968-.516-1.742-.452-.323 0-.968.13-1.356-.129-.387-.322-.322-.516-.903-.516H4.928A4.764 4.764 0 0 0 .152 6.494V18.24c0 2.646 2.13 4.775 4.453 4.71.645 0 .839-.516 1.032-.903zm14.778-15.1v10.906a4.186 4.186 0 0 1-4.194 4.194h-4.324s-.387 1.033.839 1.033h3.872a4.764 4.764 0 0 0 4.775-4.776V8.817c.065-.903-.71-1.484-.968-1.871zM1.83 7.01v10.84c0 1.937 1.613 3.55 3.55 3.55h.58c0-.065.774-1.42 2.452-4.26.194-.386.452-.773.71-1.225h-4.71c-.581 0-.904-.387-.969-.71-.129-.516.194-1.162.904-1.162h2.387l3.034-5.291s-.71-1.29-.904-1.613c-.258-.452-.129-.904.13-1.162.386-.387 1.032-.58 1.677.452l.258.387.258-.387c.58-.84.968-.775 1.29-.71.517.129.84.71.388 1.613l-4.001 6.711h1.355c.452-.774.904-1.548 1.355-2.387-.064-.323-.129-.71-.064-1.033.064-.516.323-.968.645-1.355l.387.645c1.227-2.13 2.13-3.936 2.388-4.646.13-.387.323-1.162.13-1.807H5.38a3.54 3.54 0 0 0-3.55 3.55zm2.775 10.776c0-.064.774-1.42.774-1.42 1.227-.322 1.807.452 1.872.517 0 0-.84 1.484-1.097 1.742s-.581.323-.904.258c-.516-.129-.839-.645-.645-1.097z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
@ -671,7 +671,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
}
|
||||
|
||||
.wrap.h3body-exist .wrap-header.h3wrap {
|
||||
flex: initial;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.wrap.h3body-exist > .h3wrap-body {
|
||||
@ -735,6 +735,10 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
border-radius: 0 0 0.5rem 0.5rem;
|
||||
}
|
||||
|
||||
.wrap-header.h3wrap > .wrap-body :not(:first-child):last-child {
|
||||
border-radius: 0 0 0.5rem 0.5rem;
|
||||
}
|
||||
|
||||
.wrap-header.h3wrap > .wrap-body {
|
||||
z-index: 0;
|
||||
display: flex;
|
||||
|
Reference in New Issue
Block a user