Linux 视频
2022-04-04
快捷键
Left
/Right
:快进, 快退
Up
/Down
:快进, 快退
[
/]
:倍速 x0.9, x1.1
{
/}
:倍速 x0.5, x2
Space
(p
):暂停/播放
,
/.
: 暂停,然后逐帧前进,逐帧后退
9
/0
: 音量
s
: 截图
q
: 退出
v
: 字幕开关
j
: 切换字幕
o
: 显示进度
f
: 全屏开关
i
: 显示视频信息
#
: 切换音轨
l
: 设置循环 A-B 点, 循环播放,清除循环
配置
系统配置:/etc/mpv/mpv.conf
cat /etc/mpv/mpv.conf
hwdec=vaapi
用户配置 (需要自己创建):
~/.config/mpv/mpv.conf
~/.config/mpv/input.conf
~/.config/mpv/fonts.conf
~/.config/mpv/script-opts/osc.conf
no-border
idle=yes
osd-font-size=24
save-position-on-quit
hwdec=auto
screenshot-directory=~/Pictures/Screenshots
screenshot-format=png
screenshot-template="%tY%tm%td-%tH%tM%tS-mpv-%F-%wH%wM%wS%wT"
mkdir -p ~/.config/mpv/scripts ~/.config/mpv/script-opts
find ~/.config/mpv/ -ls
GH=https://raw.githubusercontent.com
wget $GH/jonniek/mpv-menu/master/menu.lua -P ~/.config/mpv/scripts/
wget $GH/jonniek/mpv-playlistmanager/master/playlistmanager.lua -P ~/.config/mpv/scripts/
wget $GH/jonniek/mpv-playlistmanager/master/playlistmanager.conf -P ~/.config/mpv/script-opts/
wget $GH/jonniek/mpv-playlistmanager/master/menu.json -P ~/.config/mpv/script-opts/
Linux HTTP
2022-02-25
今天发现一个奇怪的现象,相同的代码在 CentOS 7 服务器上发起 HTTP 请求 3 秒之后超时,报 “TimeoutError: [Errno 110] Connection timed out”。
在我本地就按我们的定义的超时时间 5 秒超时,报 “tornado.simple_httpclient.HTTPTimeoutError: Timeout while connecting”。
Linux
2022-02-08
set file capabilities, 设置文件权限
setcap
usage: setcap [-q] [-v] [-n <rootid>] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ]
Note <filename> must be a regular (non-symlink) file.
路由器 操作系统 Linux
2022-01-31
历史
Linksys WRT54G 系列路由器(2002 年 12 月首次发布)的操作系统是基于 Linux 内核开发。
2003 年,思科旗下的 Linksys 公司面对各方面压力,开源了 WRT54G 源代码。
PS: Linksys 是美国加州的台湾移民创建, 2003 年被思科收购, 2013 年又被 Belkin 收购。2018 年 Belkin 被台湾的富士康收购。
- 2002 年,开发者基于 WRT54G 开发了 Alchemy 项目,成为相关领域最热门的项目。
- 2004 年,OpenWrt 项目启动。
- 2005 年,由于 Alchemy 开发者急于商业化,社区分叉出了 DD-WRT 项目。
现在依然是一个积极开发中的项目:https://svn.dd-wrt.com/ GitHub
最后一个稳定版本 24 发布于 2008 年,之后十几年高频度发布 beta 版本:
https://download1.dd-wrt.com/dd-wrtv2/downloads/betas/
- 2006 年,Jonathan Zarate 创建 Tomato 项目。
之前有一个 HyperWRT 项目(2004 - 2006),维护 WRT54G 代码,并支持 Linksys WRT54GS 无线路由器。
Tomato 项目就是在 HyperWRT 的基础之上继续开发和维护。
比较独创的是开发了一个 Web 管理界面。
2014 年之后就没有继续更新,但是有很多子项目,包括现在仍在开发中的 FreshTomato 和 Asuswrt。
- 2011 年 Asuswrt 项目启动,至今还在积极开发中。
- 2013 年,Asuswrt-merlin(梅林固件)启动。
https://www.asuswrt-merlin.net/
https://github.com/RMerl/asuswrt-merlin
https://github.com/RMerl/asuswrt-merlin.ng
- 2016 年,俄罗斯开发者 Padavan 基于华硕固件(Asuswrt)开发 rt-n56u 项目,目标是寻求对华硕路由器设备硬件的绝对控制。
人们用开发者的名字来当做项目名字 Padavan,俗称“老毛子”。
和梅林固件专注的是华硕高端机型(封闭的博通芯片)不同,老毛子主要针对的是华硕低端设备(联发科芯片),资源要求低。
- 2016 年,因为内部分歧,部分核心开发者出走,新起 LEDE 项目(Linux 嵌入式开发环境)。
两年之后,双方和解,两个项目又合并到一起,采用 LEDE 的制度,继续使用 OpenWrt 品牌。
- PandoraBox,国内项目,基于 OpenWrt,早期叫做 DreamBox。
已经很久没有听到相关声音了。
LibreCMC
2014 年,作为 Linux 嵌入式发行版发行。
2015 年,与 LibreWRT 项目(研究项目)合并。
2017 年,基于 LEDE 17。
2020 年,基于 OpenWrt 19。
爱快
iKuai / iKuic (海外)
北京丰台一家网络设备厂商的闭源路由器系统,有商业版和免费版。
https://www.ikuai8.com/component/download
附:List of router firmware projects
- Linux-based
- entirely free
- Endian
- Floppyfw
- IPFire
- LEDE
- libreCMC
- OpenWrt
- VyOS
- Zeroshell
- partly proprietary
- AirOS & EdgeOS
- Alliedware Plus
- DD-WRT
- ExtremeXOS
- FRITZ!Box
- RouterOS
- SmoothWall
- Tomato
- Vyatta
- FreeBSD-based
- entirely free
- m0n0wall
- pfSense
- OPNsense:pfSense 分叉
- partly proprietary
- proprietary
- Cisco IOS
- ExtremeWare
- NX-OS
- TiMOS
- VRP
参考资料与拓展阅读
Linux 工具
2022-01-16
常规的系统自带工具就不提了。
htop
代替 top
jq
JSON
bat
代替 cat
dog
DNS 查询
tldr
替代 man 文档
ack
ag 代替 grep
fzf
fuck
mtr
代替 traceroute
httppie
代替 wget 和 curl
ncdu
代替 du
duf
代替 df
pydf
代替 df
fd
代替 find
eva
代替 ls
neovim
代替 vim
lftp
代替 ftp
aria2
nnn
参考资料与拓展阅读
Linux Curl dig 开发工具 DNS
2021-12-17
:) 本文正在编辑中,暂时不提供浏览...
Linux 命令行
2021-12-15
Fedora 36 将采用 plocate 替代 mlocate 成为默认的查找索引,据说更快。
而且 Debian 也早采纳了 plocate。
安装
apt show plocate
# Package: plocate
# Version: 1.1.8-2
# Priority: optional
# Section: universe/utils
# Origin: Ubuntu
# Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
# Original-Maintainer: Steinar H. Gunderson <sesse@debian.org>
# Bugs: https://bugs.launchpad.net/ubuntu/+filebug
# Installed-Size: 510 kB
# Depends: libc6 (>= 2.33), libgcc-s1 (>= 3.3.1), libstdc++6 (>= 6), liburing1 (>= 0.7), libzstd1 (>= 1.4.0)
# Suggests: systemd-sysv | powermgmt-base, systemd-sysv | nocache
# Breaks: mlocate
# Replaces: mlocate
# Homepage: https://plocate.sesse.net/
# Task: xubuntu-desktop, ubuntu-budgie-desktop, ubuntu-budgie-desktop-raspi
# Download-Size: 119 kB
# APT-Manual-Installed: yes
# APT-Sources: https://mirrors.cloud.tencent.com/ubuntu impish/universe amd64 Packages
# Description: much faster locate
# plocate is a locate(1) based on posting lists, giving much faster searches
# on a much smaller index. It is a drop-in replacement for mlocate in nearly
# all aspects, and is fast on SSDs and non-SSDs alike.
sudo apt install -y plocate
使用
根据 apt show 信息,plocate 会 break mlocate。
updatedb 命令会改由 plocate 提供。
ll /usr/bin/locate /usr/bin/updatedb /etc/alternatives/locate /etc/alternatives/updatedb
lrwxrwxrwx 1 root root 16 2021-12-15 11:51:56 /etc/alternatives/locate -> /usr/bin/plocate
lrwxrwxrwx 1 root root 26 2021-12-15 11:51:56 /etc/alternatives/updatedb -> /usr/sbin/updatedb.plocate
lrwxrwxrwx 1 root root 24 2021-12-15 11:51:56 /usr/bin/locate -> /etc/alternatives/locate
lrwxrwxrwx 1 root root 26 2021-12-15 11:51:56 /usr/bin/updatedb -> /etc/alternatives/updatedb
根据官网提供的演示数据,其 DB 只有 mlocate 的 40%,查询时间只有 mlocate 的万分之四。
其具体操作和 mlocate 类似:
sudo updatedb
locate go.mod
有没有 2500 倍的提升我不知道,但是感觉好像确实快。挺好!
参考资料与拓展阅读
Linux
2021-12-12
stat /tmp/edge_shutdown_crash.txt
文件:/tmp/edge_shutdown_crash.txt
大小:2 块:8 IO 块:4096 普通文件
设备:801h/2049d Inode:9306564 硬链接:1
权限:(0664/-rw-rw-r--) Uid:( 1000/ markjour) Gid:( 1000/ markjour)
最近访问:2021-12-12 10:24:17.318846619 +0800
最近更改:2021-12-12 10:42:27.982887293 +0800
最近改动:2021-12-12 10:42:27.982887293 +0800
创建时间:2021-12-12 10:24:17.318846619 +0800
# %w time of file birth, human-readable; - if unknown
# %W time of file birth, seconds since Epoch; 0 if unknown
# %x time of last access, human-readable
# %X time of last access, seconds since Epoch
# %y time of last data modification, human-readable
# %Y time of last data modification, seconds since Epoch
# %z time of last status change, human-readable
# %Z time of last status change, seconds since Epoch
stat -c "%w" /tmp/edge_shutdown_crash.txt
2021-12-12 10:24:17.318846619 +0800
sudo debugfs -R 'stat /tmp/edge_shutdown_crash.txt' /dev/sda1 | cat
debugfs 1.46.3 (27-Jul-2021)
Inode: 9306564 Type: regular Mode: 0664 Flags: 0x80000
Generation: 3654863154 Version: 0x00000000:00000001
User: 1000 Group: 1000 Project: 0 Size: 2
File ACL: 0
Links: 1 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x61b56193:ea56adf4 -- Sun Dec 12 10:42:27 2021
atime: 0x61b55d51:4c04da6c -- Sun Dec 12 10:24:17 2021
mtime: 0x61b56193:ea56adf4 -- Sun Dec 12 10:42:27 2021
crtime: 0x61b55d51:4c04da6c -- Sun Dec 12 10:24:17 2021
Size of extra inode fields: 32
Inode checksum: 0xd223c644
EXTENTS:
(0):39635628
Linux
2021-10-29
内核需要和硬件打交道,中间少不了硬件厂商的支持,可是有些厂商不愿提供相关的资料,只提供了一些二进制文件,无法审查,无法修改。
Linux 内核中一直包含着很多这样的二进制 blob。
Linux Shell Zsh
2021-09-09
我定义了一个 gitg 的快捷方式:
function _new_gitg () {
# alias g='gitg --all >/dev/null 2>&1 &' # 覆盖 g=git
if [ -z "$1" ]; then
nohup gitg --all >/dev/null 2>&1 &!
else
nohup gitg -s $1 >/dev/null 2>&1 &!
fi
}
alias g='_new_gitg'
但是每次退出 shell 会有提示:zsh: you have running jobs.
我就加上 nohup,以为不会有提示,但提示依旧(不过强制退出也不会关闭 gitg 就是了)。
在 SO 上搜到相同问题,这个答复就可以很好的解决我的问题:
If you want to not see that message, simply pass the job id to disown, like so:
> disown %1
> ```
>
> Or, start the job with &! (zsh-specific trick):
>
> ```sh
> nohup ./my_script.sh &!
> ```
```sh
function _new_gitg () {
if [ -z "$1" ]; then
nohup gitg --all >/dev/null 2>&1 &!
else
nohup gitg -s $1 >/dev/null 2>&1 &!
fi
}
alias g='_new_gitg'
经过测试,这个技巧在 bash 5.1.4 下也有效。