<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.7">Jekyll</generator><link href="https://springzfx.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://springzfx.github.io/" rel="alternate" type="text/html" /><updated>2020-07-26T08:13:39+00:00</updated><id>https://springzfx.github.io/feed.xml</id><title type="html">Fancy</title><subtitle></subtitle><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><entry><title type="html">Bpf</title><link href="https://springzfx.github.io/blog/bpf.html" rel="alternate" type="text/html" title="Bpf" /><published>2020-07-20T00:00:00+00:00</published><updated>2020-07-20T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/bpf</id><content type="html" xml:base="https://springzfx.github.io/blog/bpf.html">&lt;h1 id=&quot;bpf&quot;&gt;BPF&lt;/h1&gt;

&lt;h2 id=&quot;bpf-1&quot;&gt;bpf&lt;/h2&gt;
&lt;p&gt;image from http://www.brendangregg.com/ebpf.html&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://www.brendangregg.com/eBPF/linux_ebpf_internals.png&quot; alt=&quot;img&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;kprobes
    &lt;ul&gt;
      &lt;li&gt;kprobes can trace arbitrary functions, but may easily break from one Linux version to the next&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;tracepoints
    &lt;ul&gt;
      &lt;li&gt;tracepoints are more stable, they remain mostly the same&lt;/li&gt;
      &lt;li&gt;and documented in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/sys/kernel/debug/tracing&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;can list with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo perf list&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;perf
    &lt;ul&gt;
      &lt;li&gt;http://www.brendangregg.com/perf.html&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;refer:&lt;/p&gt;

&lt;p&gt;https://stackoverflow.com/questions/45618274/are-tracepoints-redundant-in-linux-kernel-after-kprobes-support-for-ftrace&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://www.brendangregg.com/eBPF/linux_ebpf_support.png&quot; alt=&quot;img&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;projectstoolsexamples&quot;&gt;Projects/Tools/Examples&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;bcc&lt;/li&gt;
  &lt;li&gt;bpftrace&lt;/li&gt;
  &lt;li&gt;libbpf&lt;/li&gt;
  &lt;li&gt;libbpf-tools&lt;/li&gt;
  &lt;li&gt;bpftool&lt;/li&gt;
  &lt;li&gt;sampes/bpf/ in kernel tree&lt;/li&gt;
  &lt;li&gt;perf, ftrace&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;cgroup&lt;/li&gt;
  &lt;li&gt;systemd service&lt;/li&gt;
  &lt;li&gt;tc-bpf&lt;/li&gt;
  &lt;li&gt;iptables bpf&lt;/li&gt;
  &lt;li&gt;socket bpf&lt;/li&gt;
  &lt;li&gt;ip-route bpf&lt;/li&gt;
  &lt;li&gt;sockmap&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;build-kernel-samples&quot;&gt;Build kernel samples&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# kernel config&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;gunzip&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; /proc/config.gz &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; .config
make oldconfig &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; make prepare
&lt;span class=&quot;c&quot;&gt;# install headers&lt;/span&gt;
make headers_install &lt;span class=&quot;nt&quot;&gt;-j8&lt;/span&gt; 
&lt;span class=&quot;c&quot;&gt;# build bpf&lt;/span&gt;
make &lt;span class=&quot;nv&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;samples/bpf &lt;span class=&quot;nt&quot;&gt;-j8&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# run&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;ulimit&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; unlimited
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; ./sockex1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;must-read&quot;&gt;Must Read&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bpf.h&lt;/code&gt; in kernel tree&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo bpftool feature probe&lt;/code&gt; output&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.kernel.org/doc/Documentation/networking/filter.txt&quot;&gt;Linux Socket Filtering aka Berkeley Packet Filter (BPF)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Notes on bpf series&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/linux/notes-on-bpf-1&quot;&gt;BPF program types&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/linux/notes-on-bpf-2&quot;&gt;BPF helper functions for those programs&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/linux/notes-on-bpf-3&quot;&gt;BPF userspace communication&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/linux/notes-on-bpf-4&quot;&gt;BPF program build environment&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/linux/notes-on-bpf-5&quot;&gt;BPF bytecodes and verifier&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/linux/notes-on-bpf-6&quot;&gt;BPF Packet Transformation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://blogs.oracle.com/linux/notes-on-bpf-7&quot;&gt;BPF, tc and Generic Segmentation Offload&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://lwn.net/Articles/826390/&quot;&gt;Run a BPF program on socket lookup&lt;/a&gt;&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://linuxplumbersconf.org/event/4/contributions/487/attachments/238/417/Programmable_socket_lookup_LPC_19.pdf&quot;&gt;presentation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;inet_lookup&lt;/li&gt;
      &lt;li&gt;BPF_PROG_TYPE_SK_LOOKUP&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://blog.cloudflare.com/sockmap-tcp-splicing-of-the-future/&quot;&gt;SOCKMAP - TCP splicing of the future&lt;/a&gt;&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;two bpf prog attached to one sockmap&lt;/li&gt;
      &lt;li&gt;BPF_MAP_TYPE_SOCKMAP&lt;/li&gt;
      &lt;li&gt;BPF_SK_SKB_STREAM_PARSER, BPF_SK_SKB_STREAM_VERDICT&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;typenot-complete&quot;&gt;TYPE（not complete）&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;socket: for iptables –bpf, setsockopt
    &lt;ul&gt;
      &lt;li&gt;BPF_PROG_TYPE_SOCKET_FILTER&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;cgroup/sock:
    &lt;ul&gt;
      &lt;li&gt;BPF_PROG_TYPE_CGROUP_SOCK&lt;/li&gt;
      &lt;li&gt;BPF_CGROUP_INET_SOCK_CREATE&lt;/li&gt;
      &lt;li&gt;parameters:  see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bpf_ctx_convert&lt;/code&gt; in  vmlinux.h
        &lt;ul&gt;
          &lt;li&gt;bpf_sock  or __sk_buff&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;cgroup_skb/egress:  for systemd cgroup
    &lt;ul&gt;
      &lt;li&gt;BPF_PROG_TYPE_CGROUP_SKB&lt;/li&gt;
      &lt;li&gt;BPF_CGROUP_INET_EGRESS&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bpf_sec_def&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libbpf.c&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;see samples in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;linux/samples/bpf/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">BPF</summary></entry><entry><title type="html">Transparent_proxy</title><link href="https://springzfx.github.io/blog/transparent_proxy.html" rel="alternate" type="text/html" title="Transparent_proxy" /><published>2020-04-17T00:00:00+00:00</published><updated>2020-04-17T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/transparent_proxy</id><content type="html" xml:base="https://springzfx.github.io/blog/transparent_proxy.html">&lt;h1 id=&quot;透明代理技术总结linux&quot;&gt;透明代理技术总结–Linux&lt;/h1&gt;

&lt;h2 id=&quot;1-iptables-redirecttproxy&quot;&gt;1. iptables REDIRECT/TPROXY&lt;/h2&gt;

&lt;p&gt;在linux网络堆栈上实现透明代理，功能上最强大，最完美。具体可以有以下三种方式：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;global， 即全局透明代理&lt;/li&gt;
  &lt;li&gt;network namespace，在网络命名空间中透明代理，主机网络相当于中间路由器，具体实现参考 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/Scripts/ns-proxy.sh&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;net_cls, only in cgroup v1，对特定cgroup进行透明代理， 参考 &lt;a href=&quot;https://github.com/heiher/hev-socks5-tproxy#per-app-mode&quot;&gt;example&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;iptables cgroup2 path match&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;监听REDIRECT/TPROXY端口的技术实现：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;redsocks &lt;a href=&quot;https://github.com/darkk/redsocks&quot;&gt;link&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;v2ray dokodemo-door  &lt;a href=&quot;https://www.v2ray.com/chapter_02/protocols/dokodemo.html&quot;&gt;link&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;gost -L red://:12345  &lt;a href=&quot;https://docs.ginuerzh.xyz/gost/redirect/&quot;&gt;link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;未来会出现基于bpf技术，以最小的footprint，实现透明代理&lt;/p&gt;

  &lt;p&gt;linux内核的bpf技术正在快速发展&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;2-proxychains-ng&quot;&gt;2. &lt;a href=&quot;https://github.com/rofl0r/proxychains-ng&quot;&gt;proxychains-ng&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;原理是利用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LD_PRELOAD&lt;/code&gt;，挂钩(hook)网络相关的libc函数，因此只对动态链接的程序有用，例如不支持go程序（静态编译），不支持脚本等。只支持tcp。&lt;/p&gt;

&lt;p&gt;配置和使用相当的简单。&lt;/p&gt;

&lt;h2 id=&quot;3-cgproxy&quot;&gt;3. &lt;a href=&quot;https://github.com/springzfx/cgproxy&quot;&gt;cgproxy&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;基于cgroup2和TPROXY的透明代理，支持cgroup级别、进程级别的控制。&lt;/p&gt;

&lt;p&gt;支持tcp和udp。&lt;/p&gt;

&lt;p&gt;可以代理任何程序，可全局代理、网关代理。&lt;/p&gt;

&lt;h2 id=&quot;4-graftcp&quot;&gt;4. graftcp&lt;/h2&gt;

&lt;p&gt;可以通过ptrace跟踪或修改任何给定程序的网络连接，因此它可用于任何程序。&lt;/p&gt;

&lt;p&gt;只支持tcp，暂不支持ipv6，&lt;a href=&quot;https://github.com/hmgle/graftcp/issues/10&quot;&gt;issue&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;some tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;see  &lt;a href=&quot;https://www.v2ray.com/chapter_02/protocols/dokodemo.html&quot;&gt;Dokodemo-door&lt;/a&gt; and  &lt;a href=&quot;https://www.v2ray.com/chapter_02/05_transport.html&quot;&gt;v2ray tproxy config&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;note &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v2ray redirect&lt;/code&gt; only work in ipv4&lt;/p&gt;

&lt;p&gt;experiments result following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;v2ray tproxy + no root
    &lt;ul&gt;
      &lt;li&gt;tcp REDIRECT  ✓&lt;/li&gt;
      &lt;li&gt;tcp TPROXY  ✗&lt;/li&gt;
      &lt;li&gt;udp TPROXY ✗&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;v2ray redirect + no root
    &lt;ul&gt;
      &lt;li&gt;tcp REDIRECT  ✓&lt;/li&gt;
      &lt;li&gt;tcp TPROXY  ✗&lt;/li&gt;
      &lt;li&gt;udp TPROXY ✗&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;v2ray tproxy + root ✓&lt;/li&gt;
  &lt;li&gt;v2ray redirect + root ✓&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;结论：&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;REDIRECT总是可用, 而TPROXY需要root才能使用&lt;/li&gt;
  &lt;li&gt;在not root下只能代理透明代理tcp&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;一些代理软件&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;gost&lt;/li&gt;
  &lt;li&gt;clash&lt;/li&gt;
  &lt;li&gt;v2ray&lt;/li&gt;
  &lt;li&gt;trojan&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">透明代理技术总结–Linux</summary></entry><entry><title type="html">Mpv_shooter_subtitles_plugin</title><link href="https://springzfx.github.io/blog/mpv_shooter_subtitles_plugin.html" rel="alternate" type="text/html" title="Mpv_shooter_subtitles_plugin" /><published>2020-01-01T00:00:00+00:00</published><updated>2020-01-01T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/mpv_shooter_subtitles_plugin</id><content type="html" xml:base="https://springzfx.github.io/blog/mpv_shooter_subtitles_plugin.html">&lt;h1 id=&quot;mpv-射手影音字幕插件&quot;&gt;MPV-射手影音字幕插件&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;put &lt;strong&gt;&lt;a href=&quot;https://gist.github.com/springzfx/cfa5fde3dbd3c6717ab3ed5936407f24#file-splayersub-py&quot;&gt;SPlayerSub.py&lt;/a&gt;&lt;/strong&gt; and &lt;a href=&quot;https://gist.github.com/springzfx/cfa5fde3dbd3c6717ab3ed5936407f24#file-download_subtitles_using_splayer_api-js&quot;&gt;download_subtitles_using_SPlayer_API.js&lt;/a&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.config/mpv/scripts/&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;put &lt;a href=&quot;https://gist.github.com/springzfx/cfa5fde3dbd3c6717ab3ed5936407f24#file-mpv-conf&quot;&gt;mpv.conf&lt;/a&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.config/mpv/&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;打开视频后，按&lt;kbd&gt;a&lt;/kbd&gt; 开始下载字幕，字幕会下载到视频&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.cache/mpv/&lt;/code&gt;目录，并自动加载&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;refer:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://github.com/mpv-player/mpv/wiki/Scripting-language-bindings&quot;&gt;Scripting language bindings&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://docs.google.com/document/d/1ufdzy6jbornkXxsD-OGl3kgWa4P9WO5NZb6_QYZiGI0/preview#heading=h.n2qid0t4grzp&quot;&gt;射手影音智能字幕查询API&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">MPV-射手影音字幕插件</summary></entry><entry><title type="html">Openvpn</title><link href="https://springzfx.github.io/blog/openvpn.html" rel="alternate" type="text/html" title="Openvpn" /><published>2019-10-07T00:00:00+00:00</published><updated>2019-10-07T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/openvpn</id><content type="html" xml:base="https://springzfx.github.io/blog/openvpn.html">&lt;h1 id=&quot;openvpn&quot;&gt;openvpn&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/angristan/openvpn-install&quot;&gt;OpenVPN installer&lt;/a&gt; for Debian, Ubuntu, Fedora, CentOS and Arch Linux.&lt;/p&gt;

&lt;h2 id=&quot;遇到的问题&quot;&gt;遇到的问题&lt;/h2&gt;

&lt;p&gt;主机有多个IP的情况下，使用UDP会存在地址绑定不一致的情况，即：&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;./images/openvpn_udp.png&quot; alt=&quot;openvpn_udp&quot; style=&quot;zoom:50%;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;解决方案有二：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;选择使用TCP，我的选择&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-multihome&lt;/code&gt;编译，扩展sock API，具体参见&lt;a href=&quot;https://openvpn.net/community-resources/reference-manual-for-openvpn-2-4/&quot;&gt;OPENVPN文档&lt;/a&gt;&lt;/p&gt;

    &lt;blockquote&gt;
      &lt;p&gt;&lt;strong&gt;–multihome&lt;/strong&gt;&lt;/p&gt;

      &lt;p&gt;Configure a multi-homed UDP server. This option needs to be used when a server has more than one IP address (e.g. multiple interfaces, or secondary IP addresses), and is not using &lt;strong&gt;–local&lt;/strong&gt;&lt;/p&gt;

      &lt;p&gt;Note 2: if you do an IPv6+IPv4 dual-stack bind on a Linux machine with multiple IPv4 address, connections to IPv4 addresses will not work right on kernels before 3.15, due to missing kernel support for the IPv4-mapped case (some distributions have ported this to earlier kernel versions, though).&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;手动安装配置&quot;&gt;手动安装配置&lt;/h2&gt;

&lt;p&gt;OpenVPN installer 的脚本已经一团麻的，处理的方式我不是很满意，所以最终选择自己配置。&lt;/p&gt;

&lt;p&gt;主要参考https://wiki.archlinux.org/index.php/OpenVPN&lt;/p&gt;

&lt;p&gt;Archwiki建议证书在另一个主机上生成CA（证书颁发机构），这里将会在同一个主机上进行。&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# CA&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /etc/easy-rsa
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;EASYRSA&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
easyrsa init-pki
easyrsa build-ca
&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /etc/easy-rsa/pki/ca.crt /etc/openvpn/server/

&lt;span class=&quot;c&quot;&gt;# server&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;servername&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;server&quot;&lt;/span&gt;
openssl dhparam &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; /etc/openvpn/server/dh2048.pem 2048
openvpn &lt;span class=&quot;nt&quot;&gt;--genkey&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--secret&lt;/span&gt; /etc/openvpn/server/ta.key
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /etc/easy-rsa
easyrsa gen-req &lt;span class=&quot;nv&quot;&gt;$servername&lt;/span&gt; nopass
&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /etc/easy-rsa/pki/private/&lt;span class=&quot;nv&quot;&gt;$servername&lt;/span&gt;.key /etc/openvpn/server/
easyrsa sign-req server &lt;span class=&quot;nv&quot;&gt;$servername&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /etc/easy-rsa/pki/issued/&lt;span class=&quot;nv&quot;&gt;$servername&lt;/span&gt;.crt /etc/openvpn/server/

&lt;span class=&quot;c&quot;&gt;# config server to use tcp,port,dns,gateway,etc&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /usr/share/openvpn/examples/server.conf /etc/openvpn/server/server.conf
vi /etc/openvpn/server/server.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# for P20 client&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /etc/easy-rsa/pki/signed
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;client_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;P20&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /etc/easy-rsa
easyrsa gen-req &lt;span class=&quot;nv&quot;&gt;$client_name&lt;/span&gt; nopass
easyrsa sign-req client &lt;span class=&quot;nv&quot;&gt;$client_name&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /etc/easy-rsa/pki/issued/&lt;span class=&quot;nv&quot;&gt;$client_name&lt;/span&gt;.crt /etc/easy-rsa/pki/signed

&lt;span class=&quot;c&quot;&gt;# generate client ovpn&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;client_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;P20&quot;&lt;/span&gt;
ovpngen 172.24.68.231 /etc/openvpn/server/ca.crt /etc/easy-rsa/pki/signed/&lt;span class=&quot;nv&quot;&gt;$client_name&lt;/span&gt;.crt /etc/easy-rsa/pki/private/&lt;span class=&quot;nv&quot;&gt;$client_name&lt;/span&gt;.key /etc/openvpn/server/ta.key 1194 tcp &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$client_name&lt;/span&gt;.ovpn
&lt;span class=&quot;c&quot;&gt;# change cipher to match server config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;启动&quot;&gt;启动&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo systemctl enable openvpn-server@server
sudo systemctl start openvpn-server@server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;配置iptables&quot;&gt;配置Iptables&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -A INPUT -p tcp -i enp4s0 --dport 1194 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j MASQUERADE
sudo iptables -A INPUT -i tun+ -j ACCEPT
sudo iptables -A FORWARD -i tun+ -j ACCEPT
sudo iptables -A FORWARD -o tun+ -j ACCEPT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;systemd的service文件是可以友好的overide的，参考&lt;a href=&quot;https://wiki.archlinux.org/index.php/Systemd#Drop-in_files&quot;&gt;systemd-drop in files&lt;/a&gt;，因此我们通过 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl edit openvpn-server@server&lt;/code&gt; 的方式来自动处理&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/systemd/system/openvpn-server@server.service.d/override.conf
-------------------------------------------------
[Service]
ExecStartPost=/etc/iptables/add-openvpn-rules.sh
ExecStopPost=/etc/iptables/rm-openvpn-rules.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/iptables/add-openvpn-rules.sh
-------------------------------------------------
!/bin/sh
iptables -A INPUT -p tcp -i enp4s0 --dport 1194 -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j MASQUERADE
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A FORWARD -o tun+ -j ACCEPT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/iptables/rm-openvpn-rules.sh
-------------------------------------------------
!/bin/sh
iptables -D INPUT -p tcp -i enp4s0 --dport 1194 -j ACCEPT
iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -j MASQUERADE
iptables -D INPUT -i tun+ -j ACCEPT
iptables -D FORWARD -i tun+ -j ACCEPT
iptables -D FORWARD -o tun+ -j ACCEPT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;配置nftables&quot;&gt;配置nftables&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/nftables.conf
-------------------------------------------------
#!/usr/bin/nft -f
# ipv4/ipv6 Simple &amp;amp; Safe Firewall
# you can find examples in /usr/share/nftables/

table inet filter {
  chain input {
    type filter hook input priority 0; policy drop;

    # allow established/related connections
    ct state {established, related} accept

    # early drop of invalid connections
    ct state invalid drop

    # allow from loopback
    iifname lo accept

    # allow icmp
    ip protocol icmp accept
    ip6 nexthdr icmpv6 accept

    # allow ssh
    tcp dport ssh accept

    # allow transmission
    tcp dport 51413 accept

    # dhcp
    #ip protocol udp udp dport 68 accept
    #ip6 nexthdr udp udp dport 546 accept
    udp dport 68 accept
    udp dport 546 accept
		
    # vpn
    jump vpn_input

    # everything else
    reject with icmpx type port-unreachable
  }
  chain forward {
    type filter hook forward priority 0; policy drop;
		jump vpn_forward;
  }
  chain output {
    type filter hook output priority 0;
  }
	chain nat {
		type nat hook postrouting priority 100;
		jump vpn_nat
	}
	
	chain vpn_input {
		tcp dport 1194 accept
	}
	chain vpn_forward {
		meta iifname tun0 accept
		meta oifname tun0 accept
	}
	chain vpn_nat {
		ip saddr 10.8.0.0/24 masquerade
	}
}


# vim:set ts=2 sw=2 et:
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">openvpn</summary></entry><entry><title type="html">Application_i_use_in_linux</title><link href="https://springzfx.github.io/blog/application_I_use_in_linux.html" rel="alternate" type="text/html" title="Application_i_use_in_linux" /><published>2019-09-11T00:00:00+00:00</published><updated>2019-09-11T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/application_I_use_in_linux</id><content type="html" xml:base="https://springzfx.github.io/blog/application_I_use_in_linux.html">&lt;h1 id=&quot;fancy-applications&quot;&gt;Fancy Applications&lt;/h1&gt;

&lt;p&gt;Packages default included in KDE Plasma won’t list here.&lt;/p&gt;

&lt;p&gt;‘🗸’ means I am using for now in my computer.&lt;/p&gt;

&lt;h2 id=&quot;神器&quot;&gt;神器&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;neovim&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;firejail&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;tmux&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;fzf&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;fd&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;ripgrep&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;the_silver_searcher &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ag&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;earlyoom &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;out of memory handle&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;proxy-or-vpn&quot;&gt;Proxy or VPN&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;cgproxy&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;proxychains-ng&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Qv2ray, v2ray&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;gost&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;wireguard&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;video-downloader&quot;&gt;Video downloader&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;You-Get&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;youtube-dl&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;a href=&quot;https://github.com/iawia002/annie&quot;&gt;anni&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;system&quot;&gt;System&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;oh-my-zsh&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Terminator&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;yakuake&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Catfish &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Versatile file searching tool&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;KSystemLog&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;GParted &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Partition Editor&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Latte Dock&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;VirtualBox&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Vmware&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;fcitx-rime&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;KeePassXC&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;thunderbird&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;internet&quot;&gt;Internet&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Transmission &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BitTorrent Client&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;FileZilla &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FTP client&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Samba&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Syncthing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;continuous file synchronization program&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;write&quot;&gt;Write&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Typora&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Texstudio&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;LyX&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;KLatexFormula&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Mathpix Snipping Tool&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;WPS &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;office suite&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Jabref  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bibtex tool,improved by myself&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;drawio-desktop&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;IntelliJ IDEA&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;PyCharm&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Sublime Text&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Visual Studio Code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;git&quot;&gt;Git&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;a href=&quot;https://github.com/dandavison/delta&quot;&gt;delta&lt;/a&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A syntax-highlighter for git and diff output&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;GitKraken &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git Client&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;SmartGit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git Client&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;multi-media&quot;&gt;Multi media&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;spotify&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;网易云音乐&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;mpv&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Gimp&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;Kolourpaint&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;OBS &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Streaming/Recording Software&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;kdenlive &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;video editor&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Peek &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Animated GIF recorder&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Spectacle &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Screenshot Capture Utility&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;command-line-tool&quot;&gt;Command line tool&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;neofetch&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;ncdu &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Disk usage analyzer with an ncurses interface&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;ss &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dump socket statistics, in iproute2&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;glances&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;socat&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;nmap&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;lrzsz&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;monitor&quot;&gt;Monitor&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;vnstat &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console-based network traffic monitor&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;nethogs &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Net top tool grouping bandwidth per process&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;management&quot;&gt;Management&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;Korganizer&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;KCharSelect&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;archlinux&quot;&gt;Archlinux&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;pamac &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pamac is a Package Manager based on libalpm with AUR and Appstream support&lt;/code&gt;&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;yay &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pacman wrapper and AUR helper written in go.&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;web-server&quot;&gt;Web Server&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;apache&lt;/li&gt;
  &lt;li&gt;caddy 2  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;open source web server with automatic HTTPS written in Go&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;others&quot;&gt;Others&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;crow-translator&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; checked=&quot;checked&quot; /&gt;chezmoi &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dotfile manage and sync&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;projects-impressed&quot;&gt;Projects Impressed&lt;/h2&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;
    &lt;p&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;a href=&quot;https://github.com/adnanh/webhook&quot;&gt;webhook&lt;/a&gt; is a lightweight incoming webhook server to run shell commands&lt;/p&gt;
  &lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;a href=&quot;https://github.com/tiangolo/fastapi&quot;&gt;FastAPI&lt;/a&gt; is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;a href=&quot;https://github.com/jumpserver/jumpserver&quot;&gt;jumpserver&lt;/a&gt; 开源堡垒机&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">Fancy Applications</summary></entry><entry><title type="html">Misc_records</title><link href="https://springzfx.github.io/blog/misc_records.html" rel="alternate" type="text/html" title="Misc_records" /><published>2019-09-11T00:00:00+00:00</published><updated>2019-09-11T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/misc_records</id><content type="html" xml:base="https://springzfx.github.io/blog/misc_records.html">&lt;h1 id=&quot;misc-records&quot;&gt;Misc Records&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;connect to another tty&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Print the file name of the terminal connected  to  standard input.&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;tty&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# connect to it&lt;/span&gt;
script &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /dev/tty1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;tar&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# sudo to keep permission
# pack
sudo tar -cvf mysql.tar mysql
# unpack
sudo tar -xvf www.tar -C .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;manually update zsh completion cache&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rehash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;zsh completion&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt;  ~/.zcompdump&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; compinit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Generate random password&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# use package pwgen&lt;/span&gt;
pwgen 8 &lt;span class=&quot;c&quot;&gt;# generate with length 8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;find file in a certain day&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# more to see option `-newerXY` in `man find`&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find /var &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; d &lt;span class=&quot;nt&quot;&gt;-newermt&lt;/span&gt; 2019-08-30 &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-newermt&lt;/span&gt; 2019-08-31 &lt;span class=&quot;nt&quot;&gt;-print&lt;/span&gt; 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;find dhcp server&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;nmap &lt;span class=&quot;nt&quot;&gt;--script&lt;/span&gt; broadcast-dhcp-discover &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; eth0
&lt;span class=&quot;c&quot;&gt;# for dhcpv6&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;nmap &lt;span class=&quot;nt&quot;&gt;-6&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--script&lt;/span&gt; broadcast-dhcp6-discover &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; eth0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;find out the MAC of a given IP&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;arping &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; enp4s0 &lt;span class=&quot;nt&quot;&gt;-c1&lt;/span&gt; 172.24.68.179
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;find hostname by IP&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# netbios names&lt;/span&gt;
nmblookup &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; &amp;lt;ip&amp;gt;
&lt;span class=&quot;c&quot;&gt;# from dns server&lt;/span&gt;
nslookup &amp;lt;ip&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Using the KDE Wallet to store ssh key passphrases  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-add&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;zip文件名乱码&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;unzip -O cp936 filename
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;run as root in Gui&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# in .desktop
# see https://wiki.archlinux.org/index.php/Sudo#kdesu
X-KDE-SubstituteUID=true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;visudo导致sudo无法使用时&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 前提是你已经安装相应的 policykit-1-gnome 或者 polkit-kde-agent
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 &amp;amp;
pkexec visudo
# 否则就只能重启进入recovery或者livecd修复
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Clean journal&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;journalctl --rotate --vacuum-time=1d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;rsync with root&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rsync -avPpr -e &quot;ssh&quot; --rsync-path=&quot;sudo rsync&quot;  fancy@172.24.71.53:/opt/cudnn/cudnn-10.1-linux-x64-v7.5.0.56   /opt/cudnn/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;runtime path&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# refer https://en.wikipedia.org/wiki/Rpath&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# see RPATH or RUNPATH&lt;/span&gt;
readelf &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; binary-or-library
&lt;span class=&quot;c&quot;&gt;# see `man chrpath`&lt;/span&gt;
chrpath &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; binary-or-library
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;iptables LOG in netns&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sysctl -w net.netfilter.nf_log_all_netns=1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;server&quot;&gt;Server&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;List human users&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;disable or enable users&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# disable&lt;/span&gt;
chage &lt;span class=&quot;nt&quot;&gt;-E&lt;/span&gt; 0 &amp;lt;user&amp;gt;
&lt;span class=&quot;c&quot;&gt;# enable&lt;/span&gt;
chage &lt;span class=&quot;nt&quot;&gt;-E&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-1&lt;/span&gt; &amp;lt;user&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;video-related&quot;&gt;Video related&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://github.com/soimort/you-get&quot;&gt;You-Get&lt;/a&gt;&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# bilibili, 下载  		&lt;/span&gt;
you-get &amp;lt;url&amp;gt;
&lt;span class=&quot;c&quot;&gt;# bilibili, 批量下载  &lt;/span&gt;
you-get &lt;span class=&quot;nt&quot;&gt;--playlist&lt;/span&gt; &amp;lt;url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;video info&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ffprobe &lt;span class=&quot;nt&quot;&gt;-hide_banner&lt;/span&gt; &amp;lt;video&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;show videos codec&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ffprobe &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; error  &lt;span class=&quot;nt&quot;&gt;-select_streams&lt;/span&gt; v:0   &lt;span class=&quot;nt&quot;&gt;-show_entries&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;codec_name &amp;lt;url&amp;gt;
  
find &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-print&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; sh &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ffprobe -v error  -select_streams v:0   -show_entries stream=codec_name '{}' |grep codec|sed -e 's/codec_name=//'&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;flv to mp4 with loss&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# single&lt;/span&gt;
ffmpeg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; input.flv &lt;span class=&quot;nt&quot;&gt;-codec&lt;/span&gt; copy output.mp4
&lt;span class=&quot;c&quot;&gt;# loop way&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;f &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.flv
&lt;span class=&quot;k&quot;&gt;do
&lt;/span&gt;ffmpeg &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$f&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-codec&lt;/span&gt; copy &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;/.flv/.mp4&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;neovim&quot;&gt;NeoVIM&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;显示行号，显示空白字符&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:set nu &lt;span class=&quot;c&quot;&gt;# show line number&lt;/span&gt;
:set list &lt;span class=&quot;c&quot;&gt;# show space&lt;/span&gt;
:noh &lt;span class=&quot;c&quot;&gt;# turn off highlighting until the next search&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;Vim &amp;lt; 8.1.1365， Neovim &amp;lt; 0.3.6 中存在&lt;a href=&quot;https://www.anquanke.com/post/id/180386&quot;&gt;漏洞&lt;/a&gt;，modeline 在root情况下默认关闭&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/xdg/nvim/sysinit.vim
-------------------------------
set modeline
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;zsh&quot;&gt;ZSH&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^left&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^right&lt;/code&gt;  Backward or forward one word&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^u&lt;/code&gt; 	Clear whole line&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^k&lt;/code&gt;  	Clear to end of line&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^w&lt;/code&gt; 	Delete one word backward&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^l&lt;/code&gt;  	Clear screen&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^x u&lt;/code&gt;  Undo last change&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^y&lt;/code&gt; 	 Yank&lt;/p&gt;

&lt;h2 id=&quot;pacman&quot;&gt;pacman&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Remove orphan package, repeat the cmd multi times&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pacman &lt;span class=&quot;nt&quot;&gt;-Ru&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;pacman &lt;span class=&quot;nt&quot;&gt;-Qdtq&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;cgroup&quot;&gt;cgroup&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-cgls&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-cgtop&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;journal&quot;&gt;journal&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;journalctl -f -u &amp;lt;service&amp;gt; &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;journalctl -b &amp;lt;boot_number&amp;gt; &lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;exit-stuck-sessions&quot;&gt;Exit stuck sessions&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; includes the escape character &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~&lt;/code&gt; by default. The command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~.&lt;/code&gt; closes an open connection and brings you back to the terminal.&lt;/p&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">Misc Records</summary></entry><entry><title type="html">Kde_desktop_in_docker</title><link href="https://springzfx.github.io/blog/kde_desktop_in_docker.html" rel="alternate" type="text/html" title="Kde_desktop_in_docker" /><published>2019-09-10T00:00:00+00:00</published><updated>2019-09-10T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/kde_desktop_in_docker</id><content type="html" xml:base="https://springzfx.github.io/blog/kde_desktop_in_docker.html">&lt;h1 id=&quot;kde-desktop-in-docker-container&quot;&gt;kde desktop in docker container&lt;/h1&gt;

&lt;h2 id=&quot;install-docker&quot;&gt;install docker&lt;/h2&gt;

&lt;p&gt;see &lt;a href=&quot;https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/&quot;&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-fsSL&lt;/span&gt; https://download.docker.com/linux/debian/gpg | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-key add -
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;add-apt-repository &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;s2&quot;&gt;&quot;deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;lsb_release &lt;span class=&quot;nt&quot;&gt;-cs&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
   stable&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;docker-ce
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;install-nvidia-docker&quot;&gt;install nvidia-docker&lt;/h2&gt;

&lt;p&gt;see &lt;a href=&quot;https://github.com/NVIDIA/nvidia-docker&quot;&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 添加源&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; https://nvidia.github.io/nvidia-docker/gpgkey | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-key add -
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; https://nvidia.github.io/nvidia-docker/ubuntu18.04/nvidia-docker.list | &lt;span class=&quot;nb&quot;&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/nvidia-docker.list

&lt;span class=&quot;c&quot;&gt;# 安装并重启docker&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt update &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; nvidia-container-toolkit
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl restart docker


&lt;span class=&quot;c&quot;&gt;# 在官方CUDA镜像上测试 nvidia-smi&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;docker run &lt;span class=&quot;nt&quot;&gt;--gpus&lt;/span&gt; all nvidia/cuda:9.0-base nvidia-smi

&lt;span class=&quot;c&quot;&gt;# 启动支持双GPU的容器&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;docker run &lt;span class=&quot;nt&quot;&gt;--gpus&lt;/span&gt; 2 nvidia/cuda:9.0-base nvidia-smi

&lt;span class=&quot;c&quot;&gt;# 指定GPU 1，运行容器&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;docker run &lt;span class=&quot;nt&quot;&gt;--gpus&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0 nvidia/cuda:9.0-base nvidia-smi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;run&quot;&gt;run&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# not work, blackscreen after kde logo, problem still unknown&lt;/span&gt;
Xephyr &lt;span class=&quot;nt&quot;&gt;-screen&lt;/span&gt; 1024x768 :1 &amp;amp;
docker run &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; /tmp/.X11-unix:/tmp/.X11-unix kdeneon/plasma:unstable

&lt;span class=&quot;c&quot;&gt;# however application can run normally&lt;/span&gt;
xhost +
docker run &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; /tmp/.X11-unix:/tmp/.X11-unix &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;DISPLAY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;:0 kdeneon/plasma:unstable okular
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;another-way-that-work&quot;&gt;Another way that work&lt;/h2&gt;

&lt;p&gt;more see &lt;a href=&quot;https://github.com/mviereck/x11docker&quot;&gt;x11-docker&lt;/a&gt;,  &lt;a href=&quot;https://github.com/mviereck/x11docker/issues/183&quot;&gt;Is kde plasma still supported?&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;x11docker --desktop --init=systemd -- kdeneon/plasma:unstable
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">kde desktop in docker container</summary></entry><entry><title type="html">Samba_config</title><link href="https://springzfx.github.io/blog/samba_config.html" rel="alternate" type="text/html" title="Samba_config" /><published>2019-09-10T00:00:00+00:00</published><updated>2019-09-10T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/samba_config</id><content type="html" xml:base="https://springzfx.github.io/blog/samba_config.html">&lt;h3 id=&quot;samba&quot;&gt;Samba&lt;/h3&gt;

&lt;div class=&quot;language-config highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#======================= Global Settings =====================================
&lt;/span&gt;[&lt;span class=&quot;n&quot;&gt;global&lt;/span&gt;]
   &lt;span class=&quot;n&quot;&gt;workgroup&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;WORKGROUP&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;Samba&lt;/span&gt; %&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;standalone&lt;/span&gt;

   &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; = /&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;samba&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;.%&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt; = &lt;span class=&quot;m&quot;&gt;50&lt;/span&gt;

   &lt;span class=&quot;n&quot;&gt;passdb&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;backend&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;tdbsam&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;unix&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;extensions&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;No&lt;/span&gt;
   
   &lt;span class=&quot;n&quot;&gt;security&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;    
   &lt;span class=&quot;n&quot;&gt;usershare&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; = /&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;lib&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;samba&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;usershares&lt;/span&gt;    
   &lt;span class=&quot;n&quot;&gt;usershare&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shares&lt;/span&gt; = &lt;span class=&quot;m&quot;&gt;100&lt;/span&gt;    
   &lt;span class=&quot;n&quot;&gt;usershare&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;allow&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;guests&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;yes&lt;/span&gt;    
   &lt;span class=&quot;n&quot;&gt;usershare&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;owner&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;only&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;yes&lt;/span&gt; 

&lt;span class=&quot;c&quot;&gt;#============================ Share Definitions ==============================
&lt;/span&gt;[&lt;span class=&quot;n&quot;&gt;upload&lt;/span&gt;]
   &lt;span class=&quot;n&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; = &lt;span class=&quot;m&quot;&gt;0644&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; = /&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;fancy&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;upload&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;read&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;only&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;No&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;fancy&lt;/span&gt;

[&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;]
   &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; = /&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;wide&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;links&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;Yes&lt;/span&gt;

[&lt;span class=&quot;n&quot;&gt;ubuntu&lt;/span&gt;]
   &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; = /&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;/&lt;span class=&quot;n&quot;&gt;fancy&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;fancy&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;wide&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;links&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;Yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;obey pam restrictions = no&lt;/code&gt; to avoid  nobody auth log&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;./images/samba_auth_log.png&quot; style=&quot;zoom:50%;margin-left:100px;&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hosts deny = 172.24.68.179&lt;/code&gt; to deny malicious connection/brocast&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">Samba</summary></entry><entry><title type="html">Policykit_config_to_without_password_ask</title><link href="https://springzfx.github.io/blog/policykit_config_to_without_password_ask.html" rel="alternate" type="text/html" title="Policykit_config_to_without_password_ask" /><published>2019-09-09T00:00:00+00:00</published><updated>2019-09-09T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/policykit_config_to_without_password_ask</id><content type="html" xml:base="https://springzfx.github.io/blog/policykit_config_to_without_password_ask.html">&lt;h1 id=&quot;auth-synaptic-and-discover-without-password&quot;&gt;Auth Synaptic and Discover without password&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/etc/polkit-1/localauthority/50-local.d/50-fancy-personal.pkla
--------------------------------------------------------------------
[Synaptic]
Identity=unix-group:sudo
Action=com.ubuntu.pkexec.synaptic
ResultAny=no
ResultInactive=no
ResultActive=yes

[Discover]
Identity=unix-group:sudo
Action=org.freedesktop.packagekit.*
ResultAny=no
ResultInactive=no
ResultActive=yes

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For more, see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man pklocalauthority&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;tips: to be as root login &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo -i&lt;/code&gt;&lt;/p&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">Auth Synaptic and Discover without password</summary></entry><entry><title type="html">Chroot_those_things</title><link href="https://springzfx.github.io/blog/chroot_those_things.html" rel="alternate" type="text/html" title="Chroot_those_things" /><published>2019-09-05T00:00:00+00:00</published><updated>2019-09-05T00:00:00+00:00</updated><id>https://springzfx.github.io/blog/chroot_those_things</id><content type="html" xml:base="https://springzfx.github.io/blog/chroot_those_things.html">&lt;h1 id=&quot;chroot&quot;&gt;chroot&lt;/h1&gt;

&lt;h2 id=&quot;1-mount-some-necessary-resources&quot;&gt;1. Mount some necessary resources&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;ARCH_ROOT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/home/fancy/archlinux-root

&lt;span class=&quot;c&quot;&gt;# mount necessary resources&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;--bind&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; proc 	/proc 	&lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;/proc
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;--rbind&lt;/span&gt; 	/sys 	&lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;/sys
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;--rbind&lt;/span&gt; 	/dev 	&lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;/dev
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;--bind&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; ro /tmp/.X11-unix &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;/tmp/.X11-unix
&lt;span class=&quot;nb&quot;&gt;sudo cp&lt;/span&gt; /etc/resolv.conf &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;/etc/resolv.conf

&lt;span class=&quot;c&quot;&gt;# umount&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;umount &lt;span class=&quot;nt&quot;&gt;--recursive&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#sudo umount $ARCH_ROOT/dev &lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#sudo umount $ARCH_ROOT/proc &lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#sudo umount $ARCH_ROOT/sys &lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#sudo umount $ARCH_ROOT&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#sudo umount $ARCH_ROOT/tmp/.X11-unix&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#sudo chmod 1777 /dev/shm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;2-x-related-to-enable-gui-in-chroot&quot;&gt;2. X related to enable GUI in chroot&lt;/h2&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# in host, authorize clients&lt;/span&gt;
xauth extract &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;/root/.Xauthority :0

&lt;span class=&quot;c&quot;&gt;# chroot to guest&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chroot&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$ARCH_ROOT&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# in guest&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;XAUTHORITY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/root/.Xauthority
&lt;span class=&quot;c&quot;&gt;# test in guest, assume arch&lt;/span&gt;
pacman &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; xorg-eyes  &lt;span class=&quot;c&quot;&gt;#xorg-xauth xorg-server&lt;/span&gt;
xeyes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;3-another-way-to-display-in-current-x-window&quot;&gt;3. Another way to display in current X window&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# in host, need bind /tmp/.X11-unix
# disable access control
xhost +

# in guest
xeyes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Another way to display in a nested X window&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# in host,need bind /tmp/.X11-unix
sudo apt install xserver-xephyr
Xephyr -screen 1024x768 :1 &amp;amp;

# in guest
DISPLAY=:1
xeyes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Fancy Zhang</name><email>springzfx@gmail.com</email></author><summary type="html">chroot</summary></entry></feed>