LibreOffice 命令行使用

文档格式转换 转换为文本格式 libreoffice --headless --convert-to txt document.docx 参数说明: --headless: 无界面模式运行 --convert-to: 指定转换的目标格式 txt: 输出为纯文本格式 其他常用转换格式 # 转换为 PDF libreoffice --headless --convert-to pdf document.docx # 转换为 HTML libreoffice --headless --convert-to html document.docx # 指定输出目录 libreoffice --headless --convert-to txt --outdir /path/to/output document.docx

2025-11-21 · 1 min · 40 words · -

curl command

curl command curl [kɜrl] options --version, print version -s, --silent, 不显示下载进度, 不显示 error message -S, --show-error 在使用 -s 时, 打印 curl error message -C, --continue-at, 断点续传 -o, --output <file>, write output to <file> instead of stdout --connect-timeout <fractional seconds>, 建连接超时, 比如 tcp 三次握手 -m, --max-time <fractional seconds>, 单位: 秒, 可以用小数 0.5 代表 500ms, 传输超时, 比如 http 请求发送之后长时间没有响应, tcp 的 ack 收到了, 但是长时间没收到 http response. -G/--get 以 get 的方式来发送数据 -i, --include 输出时包括 protocol 头信息, 显示 response header, 例如: HTTP/1.0 200, Content-Type: text/plain -v, verbos -N, Disables the buffering of the output stream -I, --head 只返回头信息, 比如 FTP 服务器只返回文件大小. -H, --header LINE Custom header to pass to server (H) -d, --data # DATA HTTP POST data, 如果使用 -d 命令,curl 会以 application/x-www-url-encoded 格式上传参数。 从文件中读取数据 -d @/path/to/foo.json -b, --cookie <data|filename>, 发送请求时附带 cookie。可以直接传入 cookie 字符串,或从文件中读取 cookie --retry, 重试次数 -F curl 会以 multipart/form-data 的方式发送 POST 请求。-F 以 key=value 的形式指定要上传的参数,如果是文件,则需要使用 key=@file 的形式。 -k, --insecure flag to skip certificate validation. -L, --location: 追踪重定向, 如果服务器报告请求的页面已移动到其他位置(用 location: header 和 3xx 响应代码),此选项将使 curl 在新位置上重新执行请求。 -x, 参数指定 HTTP 请求的代理 -X, --request <method> Specify request method to use, -X POST, -X PUT -w, 完成请求传输后,使 curl 在 stdout 上显示自定义信息 --cacert, curl 用来验证对端的 CA 证书 -E, --cert, 客户端证书 --key, 客户端私钥 --pass, 客户端私钥的密码 --trace-ascii /tmp/curl.log, 把交互的数据打印到日志里, https 协议也能把明文打在日志里 -tlsv1.x 这个参数并不是说客户端按你指定的tls版本去跟服务端匹配,不是==的关系,是在≥的关系里面desc降序匹配, 比如支持tls1.0/1.1/1.2的Server,客户端分别以--sslv3、--tlsv1.0、--tlsv1.1、--tlsv1.2这些参数去请求,最终的结果都是以--tlsv1.2去建联,这就是我说的“在≥的关系里面desc降序匹配” --tls-max 1.x 这个参数则是限定死了,最大按哪个来, 比如说服务端最大支持到tlsv1.2,客户端限定最大按tlsv1.3来,那最终肯定就是以tlsv1.2建联了;如果服务端不变,我指定客户端以--tls-max 1.1请求,那最终肯定是以tlsv1.1建联了 -f, --fail 快速失败, 在服务器出错时不显示HTTP错误信息, 直接返回 error 22 -w -w 的作用 完成请求传输后,使 curl 在 stdout 上显示自定义信息 格式是一个字符串,可以包含纯文本和任意数量的变量 ...

2025-11-20 · 6 min · 1210 words · -

Inotify

Inotify 概述 Inotify 是 Linux 内核提供的一个文件系统事件监控机制,从 Linux 2.6.13 版本开始引入。它允许应用程序监控文件系统的变化,如文件的创建、修改、删除、移动等操作。 核心特性 实时监控:基于事件驱动,当文件系统发生变化时立即通知应用程序 高效性:相比轮询方式,inotify 不需要不断检查文件状态,大大降低了系统开销 灵活性:可以监控单个文件或整个目录树 多事件支持:支持多种文件系统事件类型 工作原理 初始化:应用程序创建一个 inotify 实例(通过 inotify_init() 系统调用),返回一个文件描述符(fd) 添加监控:为需要监控的文件或目录添加 watch(通过 inotify_add_watch()),将 watch 与 inotify 实例关联 事件通知:当被 watch 的文件系统发生变化时,内核会将事件放入该 inotify 实例的事件队列 读取事件:应用程序从 inotify 文件描述符读取事件信息(通过 read() 系统调用) 简单来说: inotify 实例就像一个"邮箱"(用文件描述符标识) 添加 watch 就是告诉内核:“这些文件有变化就往我的邮箱里放消息” 文件变化时,内核自动把事件"投递"到这个邮箱 应用程序通过读取这个文件描述符来"收取邮件"(获取事件) 代码示例: #include <sys/inotify.h> #include <unistd.h> #include <stdio.h> int main() { // 1. 创建 inotify 实例,得到文件描述符 int fd = inotify_init(); // 2. 添加 watch,监控文件的修改事件 int wd = inotify_add_watch(fd, "/path/to/file", IN_MODIFY); // 3. 当文件被修改时,内核会把事件放入 fd 对应的队列 // 4. 应用程序从 fd 读取事件 char buffer[1024]; int length = read(fd, buffer, sizeof(buffer)); // 阻塞等待事件 // 5. 处理事件... struct inotify_event *event = (struct inotify_event *)buffer; printf("文件被修改了!\n"); // 清理 close(fd); return 0; } 关键点: ...

2025-11-19 · 6 min · 1066 words · -

linux 目录

linux 目录, Filesystem Hierarchy Standard (FHS) / 根目录,一般根目录下只存放目录,不要存放文件,/etc、/bin、/dev、/lib、/sbin 应该和根目录放置在一个分区中 /bin In Arch Linux the /bin is a symlink to /usr/bin /mnt 这个目录一般是用于存放挂载储存设备的挂载目录的,比如有 cdrom 等目录。可以参看 /etc/fstab 的定义。有时我们可以把让系统开机自动挂载文件系统,把挂载点放在这里也是可以的。主要看/etc/fstab中怎么定义了;比如光驱可以挂载到/mnt/cdrom 。 /opt /opt 目录的主要用途是 存放第三方应用软件包(optional software packages),也就是那些不是由系统默认的包管理器(如 apt, yum, pacman 等)安装的程序。 /opt 的设计目的: “Optional” 的缩写:/opt = optional,表示这些软件是“可选”的,不属于系统核心组件。 保持系统整洁:与系统自带的程序(一般安装在 /usr/bin, /usr/lib 等)分开,避免混淆。 便于管理与卸载:每个软件通常会在 /opt 下有一个独立的子目录,比如 /opt/google, /opt/kong,便于手动安装与清理。 表示的是可选择的意思,有些软件包也会被安装在这里,也就是自定义软件包,比如在 Fedora Core 5.0 中,OpenOffice 就是安装在这里。有些我们自己编译的软件包,就可以安装在这个目录中; 通过源码包安装的软件,可以通过 ./configure -prefix=/opt/目录 。 /opt 目录用来安装附加软件包,是用户级的程序目录,可以理解为 D:/Software。安装到 /opt 目录下的程序,它所有的数据、库文件等等都是放在同个目录下面。opt 有可选的意思,这里可以用于放置第三方大型软件(或游戏),当你不需要时,直接 rm -rf 掉即可。在硬盘容量不够时,也可将 /opt 单独挂载到其他磁盘上使用。 ...

2025-07-31 · 3 min · 433 words · -

stat command

stat command stat 命令,查看某个文件的 inode 信息, 除了文件名以外的所有文件信息,都存在inode之中。 stat, linux 查看文件创建时间, 修改时间 stat file_0.txt atime, mtime, ctime 简名 全名 中文名 含义 atime access time 访问时间 文件中的数据库最后被访问的时间 mtime modify time 修改时间 文件内容被修改的最后时间 ctime change time 变化时间 文件的元数据发生变化。比如权限,所有者等 另外一种格式 Access: 2021-07-05 19:47:15.5638661078 +0800 Modify: 2021-07-04 19:29:15.563861472 +0800 Change: 2021-07-04 19:29:15.563861468 +0800 Birth: 2021-07-04 19:29:15.563861472 +0800 Access: 最近一次读取文件内容的时间, 不一定意味着文件被修改,仅表示被读取过,例如用 cat file_0.txt。 Modify: 最近一次修改文件内容的时间, 如使用 echo something » file_0.txt 会更新这个时间。 Change: 最近一次修改文件inode 元数据(如权限、所有者)最后一次被更改的时间, 如使用 chmod 755 file_0.txt 会更新这个时间。只修改文件内容可能也会更新, 比如更新 inode(block分配等)。 Birth: 文件创建时间, 不是所有文件系统都支持这个字段。系统返回了它,说明使用的文件系统支持(如 btrfs, ext4(带特定挂载选项)或 xfs 带 crtime 补丁等)。 本示例的创建时间可能不是真的, 有可能底层文件系统不支持. # 输出创建时间(epoch 格式,-1 表示不支持) # -c:自定义输出格式(即只显示我们想看的字段)。 # '%W':表示输出文件的 创建时间(Birth time) # 如果 文件系统不支持创建时间,则输出:-1 stat -c '%W' file_0.txt 在windows下,一个文件有: 创建时间、修改时间、访问时间。 ...

2025-07-09 · 2 min · 323 words · -

wsl native docker windows vscode hack

wsl native docker windows vscode hack wsl archlinux install containerd nerdctl nerdctl 和 containerd 使用 Unix socket一般在 /run/containerd/containerd.sock 在 WSL 里启动 socat 监听 containerd.socket,转发到 Windows 命名管道 sudo mkdir -p /mnt/wsl/shared-containerd sudo ln -sf /run/containerd/containerd.sock /mnt/wsl/shared-containerd/containerd.sock socat UNIX-LISTEN:/mnt/wsl/shared-containerd/containerd.sock,fork EXEC:"/mnt/c/workspace/apps/npiperelay.exe -ei -ep -s //./pipe/containerd_engine"

2025-06-26 · 1 min · 42 words · -

ldd 查看程序依赖 动态链接库

ldd 查看程序依赖 动态链接库 ldd(List Dynamic Dependencies) 命令可以用于分析可执行文件所依赖的共享库(动态链接库) # 检测 动态链接 # 查看 libcups 是否真的链接到了 avahi ldd /usr/lib/libcups.so | grep avahi ldd /proc/737543/exe # 输出 libavahi-common.so.3 => /usr/lib/libavahi-common.so.3 (0x00007f4d777c4000) libavahi-client.so.3 => /usr/lib/libavahi-client.so.3 (0x00007f4d777b2000) 我们使用 file 命令来分析一个可执行文件的时候,有时候可以看到输出中有 dynamically linked 这样的字眼。这个是啥意思呢? 大部分程序,都会使用到第三方库,这样就可以不用重复造轮子,节约大量时间。最简单的,我们写C程序代码的话,肯定会使用到 libc 或者 glibc 库。当然,除此之外,还可能使用其它的库。 那我们在什么情况下需要分析程序的依赖库呢?有一个场景大家肯定经历过。你去你同事那边拷备他写好的程序放到自己的环境下运行,有时候可能会跑不起来。当然跑不起来的原因可能很多,但其中一个原因可能就是缺少对应的依赖库。 这时候,ldd 就派上用场了。它可以分析程序需要一些什么依赖库,你只要把对应的库放在对应的位置就可以了。 ldd /bin/pwd linux-vdso.so.1 => (0x00007ffeb73e5000) libc.so.6 => /lib64/libc.so.6 (0x00007f908b321000) /lib64/ld-linux-x86-64.so.2 (0x00007f908b6ef000) 作用: 用来查看程式运行所需的共享库,常用来解决程式因缺少某个库文件而不能运行的一些问题。 示例: 查看test程序运行所依赖的库: /opt/app/todeav1/test$ldd test libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000039a7e00000) libm.so.6 => /lib64/libm.so.6 (0x0000003996400000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000039a5600000) ...

2025-06-16 · 1 min · 98 words · -

加密分区缩容, LVM on LUKS

加密分区缩容, LVM on LUKS https://linux-blog.anracom.com/2018/11/09/shrinking-an-encrypted-partition-with-lvm-on-luks/ https://wiki.archlinux.org/title/Resizing_LVM-on-LUKS https://wiki.archlinux.org/title/LVM#Resizing_the_logical_volume_and_file_system_in_one_go https://starbeamrainbowlabs.com/blog/article.php?article=posts%2F441-resize-luks-lvm.html Step 1: Get an overview over your block devices lsblk 加密分区在 /dev/nvme0n1p3 上 Step 2: Open the encrypted partition cryptsetup open /dev/nvme0n1p3 cr-ext # 打开过程中会要求输入密码 # 检查一下设备映射 ls -la /dev/mapper 能看到 PV: /dev/mapper/cr-ext 还有 LVM-volumes: /dev/mapper/ubuntu–vg-ubuntu–lv Step 3: Get an overview on LVM structure pvdisplay vgdisplay lvdisplay # 查看 lv 是否激活 lvs -o lv_name,lv_attr 输出 # 第五位 a 表示 LV 是 active(已激活) LV Attr ubuntu-lv -wi-ao---- 一般情况打开 luks 加密的设备之后 lvm 的 vg, lv 会自动 激活 如果没有激活的话, 手动激活 vg ...

2025-05-20 · 2 min · 376 words · -

dual boot windows and ubuntu

dual boot windows and ubuntu https://askubuntu.com/questions/1506694/dual-boot-with-windows-11-and-bitlocker/1514161#1514161 Ubuntu 版本: 22.04 用 clonezill 备份硬盘 在硬盘上准备一块空闲的空间, 用 windows 的磁盘管理工具调整现有的分区 用 balenaEtcher 制作 ubuntu 安装盘 (U盘) 在 BIOS 里确认 Secure Boot 已经开启 用分区工具在 U 盘或移动硬盘上准备一个大于 100MB 的 FAT32 分区 从 U 盘引导, 安装 ubuntu, 选择 Try or install Ubuntu Select Language: English Install> Install Ubuntu Keyboard: English(US)> English(US) Wireless What apps would you like to install to start with: Minimal installation 勾选 Install third-party software for graphics and wi-fi hardware and additional media formats 勾选 Configure Secure Boot, 设置 Secure boot 密码 备份 windows 的 EFI 分区 到 U 盘 (/dev/sda2) open a terminal with ctrl+alt+t ...

2024-05-19 · 6 min · 1242 words · -

pacman command

pacman command 参数, options -Sy # 仅同步源 -Syy # 两个 y 代表强制更新 database 文件, 即使文件看起来是最新的, 回退到旧版本的时候会用到 -Syyuu # 降级软件包的时候用 -Q # 查询 本地 pacman 数据库, 比如查询某一个已经安装的包的版本 pacman -Q openssl -Qd, -d, --deps # list packages installed as dependencies [filter] -Qt, -t, --unrequired # list packages not (optionally) required by any package (-tt to ignore optdepends) [filter] -Qh, -Q -h, print help -Ql <boost-libs> #D isplay file list provided by local package -Qk # Check the local package database -Qo /path/to/file # Check if the file is owned by any package, 查看某个文件属于哪个包 -Qq, -q, --quiet show less information for query and search, 省略版本号 -Qs 关键字: 搜索已安装的软件包。 -Qi 软件名: 查看某个软件包信息,显示软件简介,构架, 依赖,大小等详细信息。 -Qu: 列出所有可升级的软件包 -Qdtq 显示了不必要的依赖关系列表 -Qqe 列出所有显式安装(-e,explicitly显式安装;-n忽略外部包AUR) -Qqd 列出自动安装的包(-d,depends 作为依赖项) -Qqdt 列出孤立的包(-t 不再被依赖的 "作为依赖项安装的包") -F 查询远程仓库里的软件包 -Fl 比如在安装软件包之前查询一下远程仓库, 看看会有哪些文件安装到本地 --needed 已经是最新版本的包,不会再重新安装 -R 删除软件包 -b 指定 database 路径, 默认 /var/lib/pacman -r 指定安装软件包的 root 路径, 默认 / -Rdd 要删除软件包,但是不删除依赖这个软件包的其他程序, pacman -Rdd package_name -Qqo '/path/to/dir' 查看文件关联的包 -Rsn -Rs, -s, --recursive remove unnecessary dependencies, 同时删除本机上只有该软件依赖的软件。有其他包可选依赖这个包的话 pacman 会警告你,有其他包依赖这个包的话 pacman 会阻止你 -Ru 软件名: 删除软件,同时删除不再被任何软件所需要的依赖。 -Sg 软件包组: 查看某软件包组所包含的所有软件包。 -Sc:清理未安装的包文件,包文件位于 /var/cache/pacman/pkg/ 目录。 -Scc:清理所有的缓存文件。 commands # 查看安装了多少个包 pacman -Qq|wc -l 查看软件包依赖, pactree # pactree 由 pacman-contrib 包提供 pacman -S pacman-contrib # 查看 package_0 依赖了哪些软件包 pactree package_0 # 查看 package_0 被哪些软件包依赖了 # 查看哪些包依赖 package_0 pactree -r package_0 把 openssl 包安装到指定的目录 pacman -Sy openssl -b /var/lib/pacman -r 2022-11-04 在仓库里搜索有关 foo 的包 pacman -Ss foo # pacman 的 help pacman -h # -Q 的 help pacman -Q -h pacman -Q # 列出已经安装的软件包 pacman -Q boost-libs # Display version pacman -Ql boost-libs # Display file list provided by local package # 查看文件/命令属于哪个包, Check if the file is owned by any package, 查看命令由哪个包提供. pacman -Qo /etc/profile # 检查包对应的文件有没有缺失, #Check the local package database pacman -Qk filesystem # 打印详细信息,比如 文件 是否有修改 修改时间, 大小 , md5 pacman -Qkk filesystem # 安装下载的 gvim 包,或新编译的 gvim 包 pacman -U /var/cache/pacman/pkg/gvim-8.2.4106-1-x86_64.pkg.tar.zst downgrade 降级软件包 去 archive 时手动下载 https://archive.archlinux.org/packages/, 然后 pacman -U 安装 ...

2024-02-06 · 5 min · 1021 words · -

scp

scp scp 可以在两个 linux 主机间复制文件; # 复制目录 -r scp -r local_folder remote_username@remote_ip:remote_folder ash: /usr/libexec/sftp-server: not found This is a consequence(结果/后果) of your client machine using a very recent OpenSSH release (9.0 - check https://www.openssh.com/txt/release-9.0 62 for more info), which changes the scp program to use the SFTP protocol under the hood, which vanilla OpenWrt/dropbear installations do not support. To work around the problem on the client side, use the new -O (that is an uppercase letter “o”) switch when invoking scp, which will cause it to fall back to the legacy behavior. ...

2023-01-08 · 1 min · 205 words · -

nfs0

nfs # archlinux nfs-utils 包含客户端和服务端实现 sudo pacman -S nfs-utils # ubuntu, nfs client sudo apt install nfs-common nfs server nfs 依赖时钟, 需要 ntp 服务 archlinux enabled ntp by default https://blog.wiloon.com/ntp mkdir -p /data/nfs /mnt/nfs mount --bind /mnt/nfs /data/nfs vim /etc/fstab /mnt/nfs /data/nfs none bind 0 0 # NFS 服务的主配置文件 # 格式:[共享的目录] [主机名或IP(参数,参数)] vim /etc/exports /data/nfs *(rw,async,no_root_squash) # reload nfs config exportfs -arv # 查看 export dir exportfs -v sudo systemctl restart nfs-server sudo systemctl enable nfs-server showmount -e 127.0.0.1 nfs client linux client showmount -e servername mount server:/ /mountpoint/on/client windows client # 挂载之前先改注册表 需要读写权限的需要修改注册表 通过修改注册表将windows访问NFS时的UID和GID改成0即可,步骤如下 1. 在运行中输入regedit,打开注册表编辑器; 2. 进入HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default条目; 3. Create two DWORD values namely AnonymousUid and AnonymousGid,十进制值跟nfs服务端文件 所属用户 的用户 id一致。 # 重启windows的NFS client service C:\Windows\system32>hostname DESKTOP-AE0D2H0 C:\Windows\System32>nfsadmin client DESKTOP-AE0D2H0 config casesensitive=yes The settings were successfully updated. C:\Windows\system32>nfsadmin client DESKTOP-AE0D2H0 stop The service was stopped successfully. C:\Windows\system32>nfsadmin client DESKTOP-AE0D2H0 start The service was started successfully. C:\Windows\system32> #win10 mount nfs 打开控制面板 > 程序 > 启用或关闭 Windows 功能,找到NFS服务打开子目录勾选NFS客户端与管理工具。 showmount -e [server] 显示 NFS 服务器导出的所有共享。 showmount -a [server] 列出客户端主机名或 IP 地址,以及使用"主机:目录"格式显示的安装目录。 showmount -d [server] 显示 NFS 服务器上当前由某些 NFS 客户端安装的目录。 # 挂载nfs mount -o anon \\192.168.50.220\data\nfs\data Z:\ #卸载 umount z: https://wiki.archlinux.org/index.php/NFS#Installation ...

2023-01-08 · 2 min · 271 words · -

ls command

ls command ls 默认列出当前目录的内容, ls 是 list 的缩写 ls 命令默认会按照文件名字母序排序 find $PWD | xargs ls -ld ls -lrth # -l 默认按文件名排序 ls -l # 只列出目录 ls -d foo* ls -dl foo* ls -l | grep ^d # 子目录所有文件 ls -lR|grep ^- ls -lR|grep ^-|awk '{print $9}' # 列出重复的行 ls -lR|grep ^-|awk '{print $9}'|sort|uniq -d 参数 -l 除文件名称外,亦将文件型态、权限、拥有者、文件大小等资讯详细列出 -t 选项,将首先按照文件的最后修改时间排序 (时间越新越靠前) ,之后再按字母顺序排 -i 打印出文件的 inode -R 列出所有子目录 -L 当文件是软链接时, 直接显示被链接的文件的信息 -T 结合 -l 可将时间显示为 hh:mi:ss 的形式,但不会按时间排序,因而不会影响默认字母排序 -S 按文件大小排序,越大越靠前 -u 结合 -l 选项可以看到每个文件最后被访问的时间,并且也会按该时间排序 以上影响排序的选项如果结合 -r 选项一起使用,则按相反顺序排列 ...

2022-11-17 · 1 min · 87 words · -

ssh command, openssh

ssh command, openssh 端口转发 ssh 不登陆直接执行命令 openssh 9.0 sftp-server options, 参数 -T: 禁止分配伪终端, Disable pseudo-terminal allocation -t 或 -tt: 强制分配伪终端, Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu servi ces. Multiple -t options force tty allocation, even if ssh has no local tty -f:后台执行ssh指令 -N:不执行远程指令 -L listen-port:host:port 指派本地的 port 到达端机器地址上的 port, 建立本地SSH隧道(本地客户端建立监听端口), 将本地机(客户机)的某个端口转发到远端指定机器的指定端口. -v: verbose -vv: verbose -o: 指定配置选项, 具体参数看 “配置选项” 配置选项 StrictHostKeyChecking=no 忽略主机密钥验证 ssh -vv -T -oKexAlgorithms=ecdh-sha2-nistp521 git@foo.com KexAlgorithms: key exchange algorithm commands # 指定 shell 可以解决 This account is currently not available. sudo -u username -s /bin/bash ssh 不登陆直接执行命令 ssh root@192.168.50.31 "whoami" # 也可以用单引号 ssh root@192.168.50.31 'whoami' 指定私钥, 指定密钥 ssh -i /path/to/id_rsa 测试 ssh -T git@github.com ssh 强制使用密码登录, force ssh client to use only password auth ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no 192.168.50.1 -l root #debian sudo apt-get install openssh-server #archlinux sudo pacman -S openssh sudo /etc/init.d/ssh start|stop|restart ssh IP ssh IP -p 1234 -l root # ssh version ssh -V ubuntu sudo apt install openssh-server sudo systemctl start sshd -A option enables forwarding of the authentication agent connection There is a shortcut to archive this, if we don’t want to create a config file, we have another option, using -A flag with the ssh command. ...

2022-10-20 · 4 min · 765 words · -

lsof command

lsof command lsof means ‘List Open Files’ List all open files on the system or open files for specified PID 查看一个进程打开了哪些文件 #PID: 1098 sudo lsof -p 1098 ## 查看进程打开了哪些端口 # 以上命令返回的数据里 有 TCP 字样的就是 socket, 能看到端口号 install lsof # archlinux pacman -Sy lsof # ubuntu apt-get install -y lsof # centos yum install lsof -y 命令参数 -p <进程ID> 列出指定进程ID所打开的文件 -a 列出打开文件存在的进程 -c <进程名> 列出指定进程所打开的文件 -g 列出GID号进程详情 -d <文件号> 列出占用该文件号的进程 +d <目录> 列出目录下被打开的文件 +D <目录> 递归列出目录下被打开的文件 -n <目录> 列出使用NFS的文件 -i <条件> 列出符合条件的进程。4、6、协议、:端口、 @ip . -u 列出UID号进程详情 -h 显示帮助信息 -v 显示版本信息 查看 tcp 连接的建立时间 # 查看 tcp 连接 ss -nt|grep 50.32 # ESTAB 0 0 192.168.50.228:58048 192.168.50.32:2380 # 端口 :58048 lsof -i:58048 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME etcd 975 root 79u IPv4 8267566 0t0 TCP k8s0:58048->k8s2:2380 (ESTABLISHED) ...

2022-10-12 · 5 min · 855 words · -

PVE

PVE # 查看 pve 版本 pveversion macos hdiutil convert proxmox-ve_8.3-1.iso -format UDRW -o proxmox-ve_8.3-1.dmg diskutil list # insert the USB flash drive diskutil list diskutil unmountDisk /dev/diskX # rdiskX, instead of diskX, in the last command is intended. It will increase the write speed. sudo dd if=proxmox-ve_8.3-1.dmg bs=1M of=/dev/rdisk5 创建安装盘 U盘 wiloon.com/ventoy dd bs=1M conv=fdatasync if=./proxmox-ve_*.iso of=/dev/XYZ 去除 Proxmox 企业源 apt update && apt install vim vim /etc/apt/sources.list.d/pve-enterprise.list #deb https://enterprise.proxmox.com/debian/pve buster pve-enterprise 更新源 pve9 # ceph.sources Types: deb URIs: https://mirrors.bfsu.edu.cn/proxmox/debian/ceph-squid Suites: trixie Components: no-subscription Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg # debian.sources Types: deb URIs: https://mirrors.bfsu.edu.cn/debian/ Suites: trixie trixie-updates Components: main contrib non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg Types: deb URIs: https://mirrors.bfsu.edu.cn/debian-security/ Suites: trixie-security Components: main contrib non-free-firmware Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg pve 6.x vi /etc/apt/sources.list ...

2022-09-10 · 3 min · 584 words · -

Archlinux 安装 linux-lts 内核

Archlinux 安装 linux-lts 内核 Archlinux 如果做服务器用的话, 最好安装 LTS 内核, 否则…说不定哪次更新之后, 服务就起不来了, 比如最近遇到的 linux 5.19.1 和 netavark 的兼容问题. 折腾 k8s, 尝试安装 cri-o 的时候习惯性的先执行了 pacman -Syu (操作系统用的 archlinux ),然后再安装 cri-o, pacman -S cri-o, 理论上 cri-o 会默认在 sysctl 里配置 bridge-nf-call-iptables = 1,但是重启后发现 bridge-nf-call-iptables = 1 没生效,手动配置之后也不行,提示 br_netfilter 内核模块没加载, 手动加载 modprobe br_netfilter 又报错说找不到模块,看上去是前面更新系统的时候升级了内核,从 5.16.4.arch1-1 升到了 5.16.5.arch1-1,modprobe 还是到旧内核的目录找 br_netfilter 模块,简单Google了一下看到有人解决 modprobe 的问题建议用 LTS 的内核,又Google了一下 archlinux 换 LTS 内核,然后再 pacman -S cri-o 重启之后 sysctl 的配置果然没有问题了, 更换内核的过程记录如下。 ...

2022-08-21 · 1 min · 192 words · w1100n

xfce

xfce disable taskbar items grouping Right click on the taskbar, select Panel -> Panel Preferences Select the Items tab , select Window Buttons in the list, click the Edit button on the right side Change Window grouping to Never xfce 快捷键 ctrl+F1 #切换工作区 列出已经配置的快捷键 xfconf-query -c xfce4-keyboard-shortcuts -l -v|grep thunar 修改 Applications> Settings> keyboard> application shortcuts passwordless login, xfce 免密码登录 https://wiki.archlinux.org/title/LightDM#Enabling_interactive_passwordless_login https://github.com/sgerrand/xfce4-terminal-colors-solarized /home/user0/.config/xfce4/terminal/terminalrc colorCursor=#93a1a1 ColorForeground=#839496 ColorBackground=#002b36 ColorPalette=#073642;#dc322f;#859900;#b58900;#268bd2;#d33682;#2aa198;#eee8d5;#002b36;#cb4b16;#586e75;#657b83;#839496;#6c71c4;#93a1a1;#fdf6e3 https://ethanschoonover.com/solarized/ https://github.com/altercation/solarized archlinux 登录后启动xfce4 https://wiki.archlinux.org/index.php/xinitrc ...

2022-07-12 · 1 min · 102 words · -

ssh-agent, ssh agent, ssh forward

ssh-agent, ssh agent, ssh forward ssh agent forward A > B > C 主机 A:运行 ssh-agent,并且已经加载私钥 主机 B:跳板机 主机 C: 目标机,已经配置好公钥,并且运行 sshd 检查主机 A ssh-agent 是否已经在运行 ps -ef | grep ssh-agent 主机 A ssh-agent 已经加载了密钥 ssh-add -l 主机 A 允许入站连接上的 SSH 代理转发, 将 AllowAgentForwarding 的值设置为 yes,表示允许进行代理转发, openssh 中 AllowAgentForwarding 默认值即为yes,所以,如果配置没有修改过,保持默认即可。 vim /etc/ssh/sshd_config AllowAgentForwarding yes 主机 A ssh 配置 ForwardAgent yes vim ~/.ssh/config #content host * ForwardAgent yes 主机 B 不需要运行 ssh-agent, 也不需要配置 ssh 的 ForwardAgent yes, 主机 B 在使用 ssh agent forward 连接 主机 C 成功之后,会创建 环境变量 $SSH_AUTH_SOCK ...

2022-06-07 · 4 min · 661 words · -

archlinux packages

archlinux packages aalib: ASCII art graphic library aardvark-dns: Authoritative dns server for A/AAAA container records adwaita-fonts 是一个包含 Adwaita 字体(Adwaita Fonts) 的软件包。提供了一套由 GNOME 项目开发的字体, wechat sudo abseil-cpp: Collection of C++ library code designed to augment the C++ standard librar ansible ansible-core aom: Alliance for Open Media video codec appstream: Provides a standard for creating app stores across distributions at-spi2-core: Protocol definitions and daemon for D-Bus at-spi audit: Userspace components of the audit framework ...

2021-12-30 · 2 min · 364 words · -