西维蜀黍

【Linux】SSH 配置文件(.ssh/config)

Records

  • user’s configuration file (~/.ssh/config)
  • sstem-wide configuration file (/etc/ssh/ssh_config)

参数含义

  • %L 本地主机名的第一个组件
  • %l 本地主机名(包括域名)
  • %h 远程主机名(命令行输入)
  • %n 远程原始主机名
  • %p 远程主机端口
  • %r 远程登录用户名
  • %u 本地 ssh 正在使用的用户名
  • %i 本地 ssh 正在使用 uid
  • %C 值为 %l%h%p%r 的 hash

通配符

  • * - Matches zero or more characters. For example, Host * matches all hosts, while 192.168.0.* matches hosts in the 192.168.0.0/24 subnet.
  • ? - Matches exactly one character. The pattern, Host 10.10.0.? matches all hosts in 10.10.0.[0-9] range.
  • ! - When used at the start of a pattern, it negates the match. For example, Host 10.10.0.* !10.10.0.5 matches any host in the 10.10.0.0/24 subnet except 10.10.0.5.
  ...


【Linux】命令 - ssh

通过 SSH 执行命令

查看远程主机是否运行进程httpd:

$ ssh user@host 'ps ax | grep [h]ttpd'

Demo

-p - 指定连接端口

Port to connect to on the remote host. This can be specified on a per-host basis in the configuration file.

Example

SSH默认端口是22。大多现代的Linux系统22端口是开放的。如果你运行ssh程序而没有指定端口号,它直接就是通过22端口发送请求。

一些系统管理员会改变SSH的默认端口号。让我们试试,现在端口号是1234。要连上主机,就要使用**-p**选项,后面再加上SSH端口

$ ssh 192.168.1.1 -p 1234

要改变端口号,我们需要修改/etc/ssh/ssh_config文件,找到此行:

Port 22

把它换成其他端口号,比如上面的1234.然后重启SSH服务。

  ...


【Network】Speedtest CLI 测速

macOS

brew tap teamookla/speedtest
brew update
brew install speedtest --force

Ubuntu

sudo apt-get install gnupg1 apt-transport-https dirmngr
export INSTALL_KEY=379CE192D401AB61
# Ubuntu versions supported: xenial, bionic
# Debian versions supported: jessie, stretch, buster
export DEB_DISTRO=$(lsb_release -sc)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
echo "deb https://ookla.bintray.com/debian ${DEB_DISTRO} main" | sudo tee  /etc/apt/sources.list.d/speedtest.list
sudo apt-get update
# Other non-official binaries will conflict with Speedtest CLI
# Example how to remove using apt-get
# sudo apt-get remove speedtest-cli
sudo apt-get install speedtest
  ...


【MySQL】EXPLAIN 使用

EXPLAIN

The EXPLAIN statement provides information about how MySQL executes statements. EXPLAIN works with SELECT, DELETE, INSERT, REPLACE, and UPDATE statements.

EXPLAIN returns a row of information for each table used in the SELECT statement. It lists the tables in the output in the order that MySQL would read them while processing the statement. MySQL resolves all joins using a nested-loop join method. This means that MySQL reads a row from the first table, and then finds a matching row in the second table, the third table, and so on. When all tables are processed, MySQL outputs the selected columns and backtracks through the table list until a table is found for which there are more matching rows. The next row is read from this table and the process continues with the next table.

  ...


【MySQL】查询结果顺序问题

Answer

In the SQL world, order is not an inherent property of a set of data. Thus, you get no guarantees from your RDBMS that your data will come back in a certain order – or even in a consistent order – unless you query your data with an ORDER BY clause.

  ...