Skip to content

Blog

Common `netstat` Parameters

netstat -ntlpa

  • -a: show all sockets. Listening sockets are not shown by default.
  • -t: show TCP sockets only.
  • -u: show UDP sockets only.
  • -n: do not resolve names. Show numeric addresses and ports.
  • -l: show listening services only.
  • -p: show the program name associated with each connection.
  • -r: show routing information and the routing table.
  • -e: show extended information, such as UID.
  • -s: show statistics for each protocol.
  • -c: rerun the command at a fixed interval.

[1]. https://blog.csdn.net/qq_42991025/article/details/83547525

[2]. OSI模型

[3]. Notes-on-Podman-Network

Common `tcpdump` Parameters

sudo tcpdump -n -t -S -i enp0s3 port 80
  • -i: specify the capture interface, such as enp0s3.
  • -n: do not resolve domain names.
  • -nn: do not resolve domain names or ports.
  • -t: do not print timestamps.
  • -S: use absolute sequence numbers. Without -S, relative sequence numbers are used.
  • -A: print packets as ASCII strings.
  • -X: print packets as both hexadecimal and ASCII strings.
  • -w: write packets to a file.
  • port: specify the listening port, such as 80.
  • host: specify the host to capture.

[1]. https://www.cnblogs.com/onesea/p/13053697.html

[2]. https://zhuanlan.zhihu.com/p/482617730

[3]. OSI模型

Introduction to Systemd

Systemd manages Linux system resources through units. A unit can represent a service, target, mount point, timer, socket, or another system resource.

Unit files are usually stored in one of these directories, ordered by priority:

  • /etc/systemd/system: custom system or user configuration.
  • /run/systemd/system: runtime-generated configuration.
  • /usr/lib/systemd/system: unit files installed by the system or third-party software.

Systemd reads many default unit files from /usr/lib/systemd/system/, while /etc/systemd/system/ often contains custom files or symbolic links.

A Unit is the basic object managed by Systemd. A Target is a group of units, similar to a SysV-init runlevel.

Common service unit sections:

  • [Unit]: description and dependency metadata.
  • [Service]: service lifecycle and runtime behavior.
  • [Install]: how the unit is enabled and attached to a target.

Example service unit:

[Unit]
Description=Hello World
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill busybox1
ExecStartPre=-/usr/bin/docker rm busybox1
ExecStartPre=/usr/bin/docker pull busybox
ExecStart=/usr/bin/docker run --name busybox1 busybox /bin/sh -c
ExecStop="/usr/bin/docker stop busybox1"
ExecStopPost="/usr/bin/docker rm busybox1"
[Install]
WantedBy=multi-user.target
systemctl list-units
systemctl list-units --all
systemctl list-units --failed
systemctl list-units --type=service
systemctl status bluetooth.service
sudo systemctl start apache.service
sudo systemctl stop apache.service
sudo systemctl restart apache.service
sudo systemctl daemon-reload
systemctl list-dependencies nginx.service
systemctl list-unit-files --type=target
systemctl list-dependencies multi-user.target
systemctl get-default
sudo systemctl set-default multi-user.target
sudo systemctl isolate multi-user.target

Systemd uses Journald for logs. Use journalctl to inspect system and service logs.

[1]. https://cloud.tencent.com/developer/article/1516125

[2]. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/chap-managing_services_with_systemd

[3]. Execute-Scripts-on-Period-with-Systemd

[4]. Manage-Podman-Container-With-Systemd

Hexo Installation and Upgrade

Older Hexo versions may have module compatibility issues, so they should be upgraded to the latest version.

Hexo installation has already been described in detail in the previous article.

Install npm-check and npm-upgrade separately:

npm install npm-check -g
npm install npm-upgrade -g

Run npm-check and npm-update in sequence:

npm-check
npm update -g
  • -g means global installation.

[1]. https://www.jianshu.com/p/802182c01b59

[2]. Ubuntu安装hexo环境