初学者在Linux命令窗口(终端)敲命令时,肯定觉得通过输入一串一串的字符的方式来控制计算是效率很低。 但是Linux命令解释器(Shell)是有很多快捷键的,熟练掌握可以极大的提高操作效率。 下面列出最常用的快捷键,这还不是完全版。
- 命令行快捷键:
- 常用:
- Ctrl L :清屏
- 常用:
- Ctrl M :等效于回车
| docker volume create mysql80-data | |
| docker run \ | |
| -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \ | |
| -d --name mysql8 \ | |
| -v mysql8-data:/var/lib/mysql \ | |
| -p 33060:3306 mysql:8.0 |
| docker volume create mysql56-data | |
| docker run \ | |
| -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \ | |
| --privileged=true \ | |
| -d --name mysql56 \ | |
| -v mysql56-data:/var/lib/mysql \ | |
| -p 33061:3306 \ | |
| --ulimit nofile=65536:65536 \ | |
| mysql:5.6 |
| #!/bin/bash | |
| set -e | |
| install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | gpg --dearmor > /etc/apt/keyrings/docker.gpg | |
| chmod a+r /etc/apt/keyrings/docker.gpg | |
| echo \ | |
| "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \ | |
| "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ | |
| tee /etc/apt/sources.list.d/docker.list > /dev/null |
| # read in zsh is different from bash | |
| # https://superuser.com/questions/555874/zsh-read-command-fails-within-bash-function-read1-p-no-coprocess | |
| # in bash, read -p "prompt" var | |
| # but in zsh, read "var?prompt" | |
| function port_forwarding_local() { | |
| echo "port forwarding to remote server" | |
| read "local_host?local_host (default is empty): " | |
| read "local_port?local_port: " | |
| if [[ -z "${local_port}" ]]; then |
| volume="" | |
| err=$(docker volume rm $volume 2>&1) | |
| echo "err: $err" | |
| container_ids=$(echo $err | awk -F'[' '{print $2}' | awk -F']' '{print $1}') | |
| echo "ids: $ids" | |
| IFS=', ' | |
| for container_id in $container_ids; do | |
| echo "delete container: $container_id" |
| { | |
| "fields": [ | |
| "uuid", | |
| "owner_uuid", | |
| "team_uuid", | |
| "project_uuid", | |
| "reference_id", | |
| "reference_type", | |
| "type", | |
| "ext_id", |
| # Hello, and welcome to makefile basics. | |
| # | |
| # You will learn why `make` is so great, and why, despite its "weird" syntax, | |
| # it is actually a highly expressive, efficient, and powerful way to build | |
| # programs. | |
| # | |
| # Once you're done here, go to | |
| # http://www.gnu.org/software/make/manual/make.html | |
| # to learn SOOOO much more. |
| $ ssh -vvv xxx-dev | |
| OpenSSH_9.0p1, LibreSSL 3.3.6 | |
| debug1: Reading configuration data /Users/k8scat/.ssh/config | |
| debug1: /Users/k8scat/.ssh/config line 4: Applying options for * | |
| debug1: /Users/k8scat/.ssh/config line 76: Applying options for xxx-dev | |
| debug1: Reading configuration data /etc/ssh/ssh_config | |
| debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files | |
| debug1: /etc/ssh/ssh_config line 54: Applying options for * | |
| debug2: resolve_canonicalize: hostname 113.13.120.21 is address | |
| debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/k8scat/.ssh/known_hosts' |
| # What to do when mysqldump fails | |
| function report_mysqldump_fail() { | |
| cat $scratch/${filename}_raw.err >> $log | |
| mailx -s "mysqldump failed for DB $db_name on $HOSTNAME!!!" [email protected] < $log | |
| exit 2 | |
| } | |
| # How to report a step along the process | |
| function status_report() { | |
| message=$1 |