https://www.gravatar.com/avatar/5f48da38e786436afece6f2e46196202?s=240&d=mp

Linux Shell

iterm2 批量修改 profiles

https://statics.lshell.com/logo/iterm2-logo.jpg

mac 下, 作为运维,使用频率最高的除了浏览器,就是 iTerm2 了;有时候想更换个主题啥的,以前 Profile 少,一直手动修改,后面增加到上百个 Profile, 查了一下怎么批量修改;记录一下。

创建 MySQL 最小权限的备份用户

https://statics.lshell.com/logo/mysql-logo.png

在使用 Shell 脚本备份 MySQL 数据库的过程中,不可避免的会把账号密码明文写在脚本中, 除了严格给脚本设置读取权限外,还需要从根本上限制备份用户的权限。下面我们说一说,如何创建一个最小权限用户。

sed 替换匹配的最后一个

https://statics.lshell.com/sed.jpg

今天遇到这个需求,在 stackoverflow 找到了答案,收藏一下。
原答案:https://stackoverflow.com/a/46970532
直接上例子:```

$ # replacing last occurrence
$ # can also use sed -E ’s/:([^:])$/-1/’
$ echo ‘foo:123:bar:baz’ | sed -E ’s/(.
):/1-/’
foo:123:bar-baz
$ echo ‘456:foo:123:bar:789:baz’ | sed -E ’s/(.):/1-/’
456:foo:123:bar:789-baz
$ echo ‘foo and bar and baz land good’ | sed -E ’s/(.
)and/1XYZ/’
foo and bar and baz lXYZ good
$ # use word boundaries as necessary - GNU sed
$ echo ‘foo and bar and baz land good’ | sed -E ’s/(.*)bandb/1XYZ/’
foo and bar XYZ baz land good

Docker pull 加速

https://statics.lshell.com/logo/docker-logo.png

Docker pull 经常因为网络原因导致下载很慢,如果镜像源是 Docker Hub 则很好解决,因为 Docker 官方就提供加速镜像。但是遇到第三方镜像就不好解决了,本文主要解决第三方镜像 docker pull 的速度问题, 比如说 elk 的 docker 镜像。

CentOS 常用yum源

https://statics.lshell.com/logo/centos-logo.png

如果要稳定建议使用系统自带的源,测试环境中有时候会使用到比较新软件版,这时候就需要用到第三方源了。收藏几个靠谱的第三方源,分为为:EPel、REMI、Webtatic、RPMForge。