西维蜀黍

【Git】Git - Log

Git Log

Shows the commit logs.

List commits that are reachable by following the parent links from the given commit(s), but exclude commits that are reachable from the one(s) given with a ^ in front of them. The output is given in reverse chronological order by default.

  ...


【MySQL】MySQL Client - mycli

Install

If you already know how to install python packages, then you can install it via pip:

You might need sudo on linux.

$ pip install -U mycli

or

$ brew update && brew install mycli  # Only on macOS

or

$ sudo apt-get install mycli # Only on debian or ubuntu
  ...


【Docker】Troubleshooting

Got permission denied while trying to connect to the Docker daemon socket

$ docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Solve by

$ sudo chmod 666 /var/run/docker.sock
  ...


【Docker】Docker Daemon

Start

# init docker daemon
$ sudo vim /etc/docker/daemon.json
{
  "debug": true,
  "tls": false,
  "hosts":["tcp://0.0.0.0:2375","unix:///var/run/docker.sock"]
}
$ sudo dockerd

Refer to https://docs.docker.com/engine/reference/commandline/dockerd/

Setup Docker Daemon for Remote Connection

By default, Docker runs through a non-networked UNIX socket. It can also optionally communicate using SSH or a TLS (HTTPS) socket.

# how to find the path of daemon.json
$  ps auxww | grep docker
root         921  0.0  2.0 1570256 82092 ?       Ssl  17:06   0:07 dockerd --group docker --exec-root=/run/snap.docker --data-root=/var/snap/docker/common/var-lib-docker --pidfile=/run/snap.docker/docker.pid --config-file=/var/snap/docker/1767/config/daemon.json

$ sudo vim /var/snap/docker/1767/config/daemon.json
{
    "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}

# restart the Dokcer Daemon
$ sudo snap restart docker.dockerd
# or
$ sudo systemctl restart docker

# test your daemon's port
$ netstat -an | grep LISTEN  | grep 2375
# or
$ docker --debug  --host tcp://localhost:2375

# view logs
$ sudo snap logs docker.dockerd

Default Path of Config File

To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon.json on Linux systems, or C:\ProgramData\docker\config\daemon.json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced.

The default location of the configuration file on Linux is /etc/docker/daemon.json. The --config-file flag can be used to specify a non-default location.

  ...


【Linux】记录所有 DNS 查询

[Recommend] Via DNS Sniffer

# If ubuntu
$ sudo apt-get install python3-scapy; 
# If OpenWrt
$ opkg install scapy
# If macOS
$ brew install libpcap; sudo pip3 install scapy -i https://pypi.python.org/simple

$ git clone git@github.com:Oros42/DNS_sniffer.git; cd DNS_sniffer

# For a specific interface
$ sudo python3 dns_sniffer.py -i eth0

# Write to a DB
$ sudo python3 dns_sniffer.py -i en0 -d db.sqlite

Demo

在一个 session运行

$ dig google.com

...

这次 DNS query即可被捕捉到

$ sudo python3 dns_sniffer.py -i tun0
IP source       | DNS server      | Count DNS request | Query
10.22.56.25
                  8.8.8.8
                                    1                   google.com.

Ref

  ...


【Linux】搭建 DNS Server

  ...


【MySQL】MySQL Exporter

Download

$ curl -LO https://github.com/prometheus/mysqld_exporter/releases/download/v0.14.0/mysqld_exporter-0.14.0.linux-amd64.tar.gz

$ tar xf mysqld_exporter-0.14.0.linux-amd64.tar.gz
  ...


【Linux】snap

Service Management

List

# Display basic information about installed snap software
$ snap list

# Check for recent snap changes in the system
$ snap changes

Install

# Search for a package
$ snap find package_name

# Install a package
$ snap install package_name

Update

# Update a package
$ snap refresh package_name

# Update a package to another channel (track, risk, or branch)
$ snap refresh package_name --channel=channel

# Update all packages
$ snap refresh

Uninstall

# Uninstall a package
$ snap remove package_name
  ...


【Network】V2Ray

Install

Server

Refer to https://www.v2fly.org/guide/install.html#macos-%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F

Linux

安装和更新 V2Ray

// 安装可执行文件和 .dat 数据文件
# sudo bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

$ sudo systemctl enable v2ray; sudo systemctl start v2ray

Refer to https://github.com/v2fly/fhs-install-v2ray/blob/master/README.zh-Hans-CN.md

  ...


【Linux】获取 CPU 温度

Procedure for monitoring CPU temperatures on Ubuntu

$ sudo apt install lm-sensors

Install lm-sensors

sudo apt-get install lm-sensors 
  ...