vim编辑器配置

个人使用的vim编辑器配置文件带说明

系统环境:

虚拟机:Parallels Desktop 16 for Mac  .Version 16.1.2(49151)
操作系统:CentOS Linux release 8.4.2105

CentOS8-neofetch

配置文件:

" Configuration file for vim
set modelines=0         " CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible        " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start
set backspace=2         " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup nobackup

" 语法高亮显示
syntax on
set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
set fileencoding=utf-8
set termencoding=utf-8
set fileformat=unix
set encoding=utf-8

" 显示行号      同 set number
set nu!
filetype on

" 历史记录条数
set history=1000

" set background=dark

" 启用自动对齐功能,把上一行的对齐格式应用到下一行
set autoindent

" 根据上面的格式,只能的选择对齐方式,对于类似C语言编写很有用处
set smartindent

" vim禁用自动备份
set nobackup
set nowritebackup
set noswapfile

" 用空格代替tab
set expandtab
" 不用空格代替tab
" set noexpandtab
" 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4
set tabstop=4
"统一缩进为4,方便在开启了et后使用退格(backspace)键,每次退格将删除X个空格
set softtabstop=4
" 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度
set shiftwidth=4

" 设置帮助文件为中文(需要安装vimcdoc文档)
set helplang=cn

" 显示匹配的括号
set showmatch

" 文件缩进及tab个数
au FileType html,python,vim,javascript setl shiftwidth=4
au FileType html,python,vim,javascript setl tabstop=4
au FileType java,php setl shiftwidth=4
au FileType java,php setl tabstop=4

" 高亮搜索的字符串
set hlsearch

" 检测文件的类型
filetype off
filetype plugin on
filetype indent on

" C风格缩进
set cindent
set completeopt=longest,menu

" 功能设置

" 去掉输入错误提示声音
set noeb
" 自动保存
" set autowrite
" 突出显示当前行 
set cursorline

" set ai!
set showmatch

" 显示标尺
set ruler

" 输入的命令显示出来,看的清楚些
set showcmd

" 状态行显示的内容
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}

" 启动显示状态行1,总是显示状态行2
set laststatus=2

" 配色方案
" colorscheme desert

" 指定配色方案是256色
set t_Co=256

set wildmenu

" 设置光标样式为竖线vertical bar
" Change cursor shape between insert and normal mode in iTerm2.app
" if $TERM_PROGRAM =~ "iTerm"
" let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
" let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
" endif
" 共享剪贴板
set clipboard+=unnamed
" 文件被改动时自动载入
set autoread
" 顶部底部保持3行距离
set scrolloff=3

docker清理命令prune

Docker使用中会产生很多冗余的镜像、容器和数据卷,那么怎么来清理这些冗余呢?

系统环境:

虚拟机:Parallels Desktop 16 for Mac  .Version 16.1.2(49151)
操作系统:CentOS Linux release 8.4.2105
Docker:20.10.7, build f0df350

CentOS8-neofetch

常用清理命令参考:

清理所有未使用的镜像、容器和数据卷(不懂该命令请慎用):

docker system prune

查看所有悬挂状态的镜像:

docker image ls -f dangling=true

清理所有悬挂状态的镜像:

docker image prune

OR

docker image rm $(docker image ls -f dangling=true -q)

删除所有停止状态的容器:

docker container prune

删除所有容器(你的所有容器会被清空,慎用)

docker rm -f $(docker ps -aq)

OR

docker container rm -f $(docker container ls -aq)

删除不再使用的数据卷

docker volume rm $(docker volume ls -q)

OR

docker volume prune

删除构建缓存

docker builder prune

Docker运行mysql设置密码问题

Docker运行mysql时,必须提供一个初始化密码,但是有的开发者是本地测试使用,所以不想加密码该如何操作呢?

系统环境:

虚拟机:Parallels Desktop 16 for Mac  .Version 16.1.2(49151)
操作系统:CentOS Linux release 8.4.2105
Docker:20.10.7, build f0df350
MySQL:5.7

CentOS8-neofetch

解决方案:

执行以下命令即可,连接mysql不需要填写密码便能连接上

docker run --name mysql57 \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-p 3306:3306 \
-d mysql:5.7

参数参考:

运行容器时设置root密码为:123456

docker run --name mysql57 \
-e MYSQL_ROOT_PASSWORD=123456 \
-p 3306:3306 \
-d mysql:5.7

运行容器时创建一个新的用户,并将root密码设置为随机,一般使用场景为单个项目数据库使用唯一的账号密码来管理:

docker run --name=mysqlBlog \
-e MYSQL_DATABASE=blog \
-e MYSQL_USER=blog \
-e MYSQL_PASSWORD=blog \
-e MYSQL_RANDOM_ROOT_PASSWORD=yes \
-p 3306:3306 \
-d mysql:5.7

Docker容器中如何使用vi或者vim编辑器

Docker容器没有安装vi或者vim编辑器,导致提示:command not found

系统环境:

虚拟机:Parallels Desktop 16 for Mac  .Version 16.1.2(49151)
操作系统:CentOS Linux release 8.4.2105
Docker:20.10.7, build f0df350

CentOS8-neofetch

解决方案:

依次执行以下命令即可

apt-get update
apt-get install vim -y

CentOS8安装Docker

在CentOS8系统上安装Docker环境步骤

系统环境:

虚拟机:Parallels Desktop 16 for Mac  .Version 16.1.2(49151)
操作系统:CentOS Linux release 8.4.2105
Docker:20.10.7, build f0df350

CentOS8-neofetch

安装过程

error.先发个错误:podman已经安装导致的报错,执行以下命令删除podman后继续执行后续安装步骤即可,如果你不知道podman是什么,建议直接先执行以下解决方案给出的命令

解决方案:
yum -y erase podman buildah
错误参考:(只要看到 installed package podman… 基本就是这个问题)
Error: 
 Problem 1: problem with installed package podman-3.0.1-7.module_el8.4.0+830+8027e1c4.x86_64
  - package podman-3.0.1-7.module_el8.4.0+830+8027e1c4.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
  - package podman-3.0.1-6.module_el8.4.0+781+acf4c33b.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
  - package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - cannot install the best candidate for the job
  - package runc-1.0.0-64.rc10.module_el8.4.0+522+66908d0c.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-65.rc10.module_el8.4.0+819+4afbd1d6.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-70.rc92.module_el8.4.0+786+4668b267.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-71.rc92.module_el8.4.0+833+9763146c.x86_64 is filtered out by modular filtering
 Problem 2: package podman-3.0.1-6.module_el8.4.0+781+acf4c33b.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
  - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package docker-ce-3:20.10.7-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
  - package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package podman-catatonit-3.0.1-6.module_el8.4.0+781+acf4c33b.x86_64 requires podman = 3.0.1-6.module_el8.4.0+781+acf4c33b, but none of the providers can be installed
  - problem with installed package podman-catatonit-3.0.1-7.module_el8.4.0+830+8027e1c4.x86_64
  - package podman-catatonit-3.0.1-7.module_el8.4.0+830+8027e1c4.x86_64 requires podman = 3.0.1-7.module_el8.4.0+830+8027e1c4, but none of the providers can be installed
  - package podman-3.0.1-7.module_el8.4.0+830+8027e1c4.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
  - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
  - cannot install the best candidate for the job
  - package runc-1.0.0-64.rc10.module_el8.4.0+522+66908d0c.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-65.rc10.module_el8.4.0+819+4afbd1d6.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-70.rc92.module_el8.4.0+786+4668b267.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-71.rc92.module_el8.4.0+833+9763146c.x86_64 is filtered out by modular filtering
  - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
  - package containerd.io-1.4.6-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.4.0+673+eabfc99d.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

1.安装yum-utils

sudo yum install -y yum-utils

2.添加仓库

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

3.安装 docker-ce docker-ce-cli

sudo yum -y  install docker-ce  docker-ce-cli containerd.io

4.启动 docker 服务

systemctl start docker

5.查看 docker 相关信息

① 查看 docker 版本号:
  docker -v
② 查看 docker 详细信息:
  docker version

6.设置 docker 服务为开机启动

systemctl enable --now docker

Docker命令参考

1. 查看本地已有镜像列表:
  docker images
2. 搜索镜像
  docker search openresty
3. 拉取镜像:
  docker pull openresty/openresty 
4. 删除镜像:
  docker rmi openresty/openresty

5. 查看已有容器列表:
  docker ps
6. 运行容器:
  docker run -d -p 10080:80 --name openresty openresty/openresty
  -d:加了这个参数不会进入容器,想要进入容器需要使用指令 docker exec
7. 停止容器:
  docker stop openresty
8. 重启容器:
  docker restart openresty
9. 进入容器:
  docker exec it openresty /bin/bash
  exit退出容器后不会导致容器停止运行。(推荐该命令连接)
  docker attach openresty
  exit退出容器后会使容器停止运行。
10. 容器和本地之间交换文件:
  docker cp fromPath(被拷贝文件) toPath(要放置被拷贝文件的地方)
  容器外部拷贝文件到容器内部操作
    docker cp ~/Program/hugo/blog/public openresty:openresty:/usr/local/openresty/nginx/html/blog
  容器内部部拷贝文件到容器外部操作
    docker cp openresty:openresty:/usr/local/openresty/nginx/html/blog ~/Program/hugo/blog/public
11. 删除容器:
  docker rm -f openresty
12. 清理所有处于终止状态的容器:
  docker container prune

系统提供的命令

  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Invictus

INVICTUS–不可征服

Out of the night that covers me,

夜幕低垂将我笼罩


Black as the Pit from pole to pole.

两极犹如漆黑地窖


I thank whatever gods may be,

我感谢未知的上帝


For my unconquerable soul.

赋予我不败的心灵


In the fell clutch of circumstance,

即使环境险恶危急


I have not winced nor cried aloud.

我不会退缩或哭嚎


Under the bludgeonings of chance,

立於时机的胁迫下


My head is bloody, but unbowed.

血流满面我不屈服


Beyond this place of wrath and tears,

超越这般悲愤交集


Looms but the Horror of the shade,

恐怖阴霾独步逼近


And yet the menace of the years,

岁月威胁挥之不去


Finds and shall find me unafraid.

我终究会无所畏惧


It matters not how strait the gate,

纵然通道多麼险狭


How charged with punishments the scroll.

尽管严惩绵延不尽


I am the master of my fate,

我是我命运的主人


I am the captain of my soul.

我是我心灵的统帅