Linux Systemd
2019-12-21
apt-file list systemd | grep bin/
systemd: /bin/journalctl
systemd: /bin/loginctl
systemd: /bin/networkctl
systemd: /bin/systemctl
systemd: /bin/systemd
systemd: /bin/systemd-ask-password
systemd: /bin/systemd-escape
systemd: /bin/systemd-inhibit
systemd: /bin/systemd-machine-id-setup
systemd: /bin/systemd-notify
systemd: /bin/systemd-sysext
systemd: /bin/systemd-sysusers
systemd: /bin/systemd-tmpfiles
systemd: /bin/systemd-tty-ask-password-agent
systemd: /usr/bin/bootctl
systemd: /usr/bin/busctl
systemd: /usr/bin/hostnamectl
systemd: /usr/bin/kernel-install
systemd: /usr/bin/localectl
systemd: /usr/bin/resolvectl
systemd: /usr/bin/systemd-analyze
systemd: /usr/bin/systemd-cat
systemd: /usr/bin/systemd-cgls
systemd: /usr/bin/systemd-cgtop
systemd: /usr/bin/systemd-cryptenroll
systemd: /usr/bin/systemd-delta
systemd: /usr/bin/systemd-detect-virt
systemd: /usr/bin/systemd-id128
systemd: /usr/bin/systemd-mount
systemd: /usr/bin/systemd-path
systemd: /usr/bin/systemd-resolve
systemd: /usr/bin/systemd-run
systemd: /usr/bin/systemd-socket-activate
systemd: /usr/bin/systemd-stdio-bridge
systemd: /usr/bin/systemd-umount
systemd: /usr/bin/timedatectl
journalctl
loginctl
networkctl
systemctl
systemd
systemd-ask-password
systemd-escape
systemd-inhibit
systemd-machine-id-setup
systemd-notify
systemd-sysext
systemd-sysusers
systemd-tmpfiles
systemd-tty-ask-password-agent
bootctl
busctl
hostnamectl
kernel-install
localectl
resolvectl
systemd-analyze
systemd-cat
systemd-cgls
systemd-cgtop
systemd-cryptenroll
systemd-delta
systemd-detect-virt
systemd-id128
systemd-mount
systemd-path
systemd-resolve
systemd-run
systemd-socket-activate
systemd-stdio-bridge
systemd-umount
timedatectl
ps -ef | grep -E "systemd|systemd|dns|dhcp|udevd" | grep -Fv grep
root 333 1 0 10:00 ? 00:00:05 /lib/systemd/systemd-journald
root 419 1 0 10:00 ? 00:00:01 /lib/systemd/systemd-udevd
systemd+ 546 1 0 10:00 ? 00:00:07 /lib/systemd/systemd-oomd
systemd+ 547 1 0 10:00 ? 00:00:00 /lib/systemd/systemd-resolved
systemd+ 548 1 0 10:00 ? 00:00:00 /lib/systemd/systemd-timesyncd
message+ 573 1 0 10:00 ? 00:00:04 @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root 680 1 0 10:00 ? 00:00:00 /lib/systemd/systemd-logind
root 682 1 0 10:00 ? 00:00:00 /usr/sbin/thermald --systemd --dbus-enable --adaptive
markjour 2508 1 0 10:05 ? 00:00:01 /lib/systemd/systemd --user
markjour 2523 2508 0 10:05 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
markjour 5461 2508 0 10:11 ? 00:00:00 /usr/libexec/gnome-session-binary --systemd-service --session=ubuntu
root 6630 1 0 10:15 ? 00:00:00 systemd-tty-ask-password-agent --wall
Linux Systemd
2019-12-21
Unit Commands:
list-units [PATTERN...] List units currently in memory
list-sockets [PATTERN...] List socket units currently in memory,
ordered by address
list-timers [PATTERN...] List timer units currently in memory,
ordered by next elapse
is-active PATTERN... Check whether units are active
is-failed PATTERN... Check whether units are failed
status [PATTERN...|PID...] Show runtime status of one or more units
show [PATTERN...|JOB...] Show properties of one or more
units/jobs or the manager
cat PATTERN... Show files and drop-ins of specified units
help PATTERN...|PID... Show manual for one or more units
list-dependencies [UNIT...] Recursively show units which are required
or wanted by the units or by which those
units are required or wanted
start UNIT... Start (activate) one or more units
stop UNIT... Stop (deactivate) one or more units
reload UNIT... Reload one or more units
restart UNIT... Start or restart one or more units
try-restart UNIT... Restart one or more units if active
reload-or-restart UNIT... Reload one or more units if possible,
otherwise start or restart
try-reload-or-restart UNIT... If active, reload one or more units,
if supported, otherwise restart
isolate UNIT Start one unit and stop all others
kill UNIT... Send signal to processes of a unit
clean UNIT... Clean runtime, cache, state, logs or
configuration of unit
freeze PATTERN... Freeze execution of unit processes
thaw PATTERN... Resume execution of a frozen unit
set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit
bind UNIT PATH [PATH] Bind-mount a path from the host into a
unit's namespace
mount-image UNIT PATH [PATH [OPTS]] Mount an image from the host into a
unit's namespace
service-log-level SERVICE [LEVEL] Get/set logging threshold for service
service-log-target SERVICE [TARGET] Get/set logging target for service
reset-failed [PATTERN...] Reset failed state for all, one, or more
units
Unit File Commands:
list-unit-files [PATTERN...] List installed unit files
enable [UNIT...|PATH...] Enable one or more unit files
disable UNIT... Disable one or more unit files
reenable UNIT... Reenable one or more unit files
preset UNIT... Enable/disable one or more unit files
based on preset configuration
preset-all Enable/disable all unit files based on
preset configuration
is-enabled UNIT... Check whether unit files are enabled
mask UNIT... Mask one or more units
unmask UNIT... Unmask one or more units
link PATH... Link one or more units files into
the search path
revert UNIT... Revert one or more unit files to vendor
version
add-wants TARGET UNIT... Add 'Wants' dependency for the target
on specified one or more units
add-requires TARGET UNIT... Add 'Requires' dependency for the target
on specified one or more units
edit UNIT... Edit one or more unit files
get-default Get the name of the default target
set-default TARGET Set the default target
Machine Commands:
list-machines [PATTERN...] List local containers and host
Job Commands:
list-jobs [PATTERN...] List jobs
cancel [JOB...] Cancel all, one, or more jobs
Environment Commands:
show-environment Dump environment
set-environment VARIABLE=VALUE... Set one or more environment variables
unset-environment VARIABLE... Unset one or more environment variables
import-environment VARIABLE... Import all or some environment variables
Manager State Commands:
daemon-reload Reload systemd manager configuration
daemon-reexec Reexecute systemd manager
log-level [LEVEL] Get/set logging threshold for manager
log-target [TARGET] Get/set logging target for manager
service-watchdogs [BOOL] Get/set service watchdog state
System Commands:
is-system-running Check whether system is fully running
default Enter system default mode
rescue Enter system rescue mode
emergency Enter system emergency mode
halt Shut down and halt the system
poweroff Shut down and power-off the system
reboot Shut down and reboot the system
kexec Shut down and reboot the system with kexec
exit [EXIT_CODE] Request user instance or container exit
switch-root ROOT [INIT] Change to a different root file system
suspend Suspend the system
hibernate Hibernate the system
hybrid-sleep Hibernate and suspend the system
suspend-then-hibernate Suspend the system, wake after a period of
time, and hibernate
Linux Systemd
2019-12-20
开源中国上看到 Debian 正在投票是否支持非 systemd 初始化系统。
- 2014 年素来混乱的 Debian 社区,经过了一番激烈争论之后(甚至是生命安全威胁),终于决定支持 systemd。
PS: 这场争议导致部分核心人员离开,主要是对 Debian 社区的管理机制(混乱 “民主”)产生质疑。
- 2015 年 5 月发布的 Debian 8.0 (Jessie) 开始使用 Systemd 当默认的初始化系统。
但是关于 Systemd 的争论从未停止,甚至有部分开发者独自维护了一个拒绝 Systemd 的分叉:Devuan。
Systemd 真是闹出好大争议,和 GNOME3 一样。也正是有 GNOME3 的例子(社区总体来说,或者说大多数人,最后还是拥抱了变化,接纳 GNOME3),而且我只是一个实用主义的使用者,我觉得 Systemd 挺好的,能提升性能、使用又方便,为什么不呢。
武汉 个人
2019-12-14
我不知道具体是怎么规定的,或者别的公司是怎么实施的,这里只是以我司(SendCloud)作为参考。
主要是我根据资料和自己的理解,结合实际数据,自己臆断的,不一定是真的,哈。
阅读 历史 古文
2019-11-26
范蠡遂去,自齐遗大夫种书曰:“蜚鸟尽,良弓藏;狡兔死,走狗烹。越王为人长颈鸟喙,可与共患难,不可与共乐。子何不去?” 种见书,称病不朝。人或谗种且作乱,越王乃赐种剑曰:“子教寡人伐吴七术,寡人用其三而败吴,其四在子,子为我从先王试之。” 种遂自杀。
《史记 越王勾践世家》
上令武士缚信,载后车。信曰:“果若人言,‘狡兔死,良狗亨;高鸟尽,良弓藏;敌国破,谋臣亡。’天下已定,我固当亨!” 上曰:“人告公反。” 遂械系信。至雒阳,赦信罪,以为淮阴侯。
《史记 淮阴侯列传》
DB MySQL
2019-11-25
一次数据库表结构调整,引起了我对 MySQL 字段类型 TEXT
和 VARCHAR
的思考。
汽车 乙醇汽油
2019-11-24
看到关于乙醇汽油使用推广的消息,就查了以下相关资料,这是看到的一篇老资讯了。
开发者 架构 阮一峰
2019-11-19
阮一峰的博文(容错,高可用和灾备)中说:
- 容错:发生故障时,如何让系统继续运行。
飞机的四个引擎坏了一个还能继续飞行,汽车的四个轮子坏了一个也能将就驾驶。
- 高可用:系统中断时,如何尽快恢复。
汽车的备胎,用于快速恢复正常驾驶(允许短暂的业务中断)。
- 灾备:系统毁灭时,如何抢救数据。
飞机的弹射装置,保证最核心的“资产” —— 驾驶员能够存活。
开发者
2019-11-18
Linux
- https://linuxopsys.com/topics/linux-commands-cheat-sheet
- grep
- awk
Bash & ShellScripting
- https://oit.ua.edu/wp-content/uploads/2020/12/Linux_bash_cheat_sheet-1.pdf
- http://www.cheat-sheets.org/saved-copy/shellscripcheatsheet.pdf
Linux Network
- https://opensource.com/downloads/cheat-sheet-networking
- https://opensource.com/sites/default/files/gated-content/osdc_cheatsheet-networking-2021.4.8.pdf
- Hacking Tools Cheat Sheet
Windows
cmd
- http://www1.cs.columbia.edu/~sedwards/classes/2017/1102-spring/Command%20Prompt%20Cheatsheet.pdf
- https://phoenixnap.com/kb/wp-content/uploads/2023/01/windows-cmd-commands-cheat-sheet-pdf.pdf
PowerShell
- http://ramblingcookiemonster.github.io/images/Cheat-Sheets/powershell-basic-cheat-sheet2.pdf
Vim
- https://phoenixnap.com/kb/vim-commands-cheat-sheet
- https://www.cs.cmu.edu/~15131/f17/topics/vim/vim-cheatsheet.pdf
- https://github.com/dennyzhang/cheatsheet-vim-A4
- https://github.com/dennyzhang/cheatsheet-vim-A4/blob/master/cheatsheet-vim-A4.pdf
- https://gitee.com/chloneda/vim-cheatsheet
Python
- https://hackr.io/blog/python-cheat-sheet
- https://www.pythoncheatsheet.org/
- https://static.realpython.com/python-cheat-sheet.pdf
- https://static.realpython.com/python_cheat_sheet_v1.pdf
- https://courses.cs.washington.edu/courses/cse163/22wi/resources/python-cheat-sheet.pdf
Django
- http://cheat-sheets.org/saved-copy/django_reference_sheet.pdf
- https://cheatography.com/ogr/cheat-sheets/django/
- https://edu.anarcho-copy.org/Programming%20Languages/Python/Python%20CheatSheet/beginners_python_cheat_sheet_pcc_django.pdf
- https://www.riptutorial.com/Download/django-rest-framework.pdf
- https://books.agiliq.com/_/downloads/django-api-polls-tutorial/en/latest/pdf/
NumPy
- http://www.cheat-sheets.org/saved-copy/numpy-cheat-sheet.20210604.pdf
Golang
- http://www.cheat-sheets.org/saved-copy/go-lang-cheat-sheet-master.20181212/golang_refcard.pdf
- https://golang.sk/images/blog/cheatsheets/go-cheat-sheet.pdf
- https://github.com/fedir/go-tooling-cheat-sheet
- https://raw.githubusercontent.com/fedir/go-tooling-cheat-sheet/master/go-tooling-cheat-sheet.pdf
C/C++
- http://dcjtech.info/wp-content/uploads/2017/09/C-Programming.pdf
- https://cheatography.com/ashlyn-black/cheat-sheets/c-reference/
- https://opensource.com/sites/default/files/gated-content/cheat_sheet_c.pdf
- https://courses.cs.washington.edu/courses/cse351/14sp/sections/1/Cheatsheet-c.pdf
- https://web.pa.msu.edu/people/duxbury/courses/phy480/Cpp_refcard.pdf
- https://cheatography.com/technecure/cheat-sheets/c-cheatsheet/
- https://cppcheatsheet.readthedocs.io/_/downloads/en/latest/pdf/
- https://cheatography.com/benjy/cheat-sheets/c/
Java
- https://computinglearner.com/wp-content/uploads/2021/09/Java-Cheat-Sheet.pdf
PHP
- https://websitesetup.org/wp-content/uploads/2020/09/PHP-Cheat-Sheet.pdf
Web
HTML
- https://html.com/wp-content/uploads/html-cheat-sheet.pdf
CSS
- https://websitesetup.org/wp-content/uploads/2019/11/wsu-css-cheat-sheet-gdocs.pdf
JavaScript
- https://websitesetup.org/wp-content/uploads/2020/09/Javascript-Cheat-Sheet.pdf
jQuery
- https://websitesetup.org/wp-content/uploads/2017/01/wsu-jquery-cheat-sheet.pdf
- https://cheat-sheets.org/saved-copy/wsu-jquery-cheat-sheet.pdf
Vue
- https://learnvue.co/LearnVue-Vue-3-Cheatsheet.pdf
- https://vuejs-tips.github.io/cheatsheet/vuejs-cheatsheet.pdf
Redis
- http://stephendavies.org/cpsc350/redisCheatSheet.pdf
MySQL
- https://phoenixnap.com/kb/wp-content/uploads/2021/04/MySQL-Commands-Cheat-Sheet-by-PhoenixNAP.pdf
MongoDB
- https://cheatography.com/isaeus/cheat-sheets/mongodb/
- http://stephendavies.org/cpsc350/mongoCheatSheet.pdf
- https://www.goalkicker.com/MongoDBBook/MongoDBNotesForProfessionals.pdf
RabbitMQ
- https://pika.readthedocs.io/_/downloads/en/stable/pdf/
工具
Git
- https://education.github.com/git-cheat-sheet-education.pdf
Excel
- https://download.microsoft.com/download/5/4/c/54cd97c1-0213-46a7-b659-95f1c9145f42/Excel_shortcuts_cheat_sheet.pdf
PyTorch
- https://www.mad.tf.fau.de/files/2019/07/pytorch-cheatsheet-en.pdf
Python
2019-11-06
在学习 subprocess 模块的时候看到代码中有一行:
sys.audit("subprocess.Popen", executable, args, cwd, env)
才了解到 Python 3.8 中新加了这样一个审计功能。
作用
提供一种机制,对 Python 程序执行过程中的部分关键操作进行干预,比如记录事件、引发异常、中止操作或完全终止进程。
部分关键操作发生的时候,Python 会调用我们定义的钩子方法。
注意:官方提示,恶意代码可以轻易绕过这些钩子,不要指望审计钩子能用来创建一个安全的 sandbox。
注意:sys.addaudithook
方法的调用会触发一个同名的事件。如果现有的钩子方法抛出 Runtime 异常,则不会添加这个钩子。
支持的审计事件
CPython 定义了一些事件:Audit events table,比如:
import
exec
compile
os.exec
os.listdir
os.rmdir
os.spawn
os.walk
os.system
subprocess.Popen
使用
sys.audit
方法是官方定义和执行的,Python 运行时负责抛出审计事件,我们程序只管使用系统方法 sys.addaudithook(hook) 来添加审计钩子处理这些事件。
import sys
def hook(event, args):
print('%s: %r' % (event, args))
sys.addaudithook(hook)
import math
num = math.ceil(100 / 3)
print(num)