Misc Records
-
connect to another tty
# Print the file name of the terminal connected to standard input. tty # connect to it script -f /dev/tty1
-
tar
# sudo to keep permission # pack sudo tar -cvf mysql.tar mysql # unpack sudo tar -xvf www.tar -C .
-
manually update zsh completion cache
rehash
-
zsh completion
rm ~/.zcompdump; compinit
-
Generate random password
# use package pwgen pwgen 8 # generate with length 8
-
find file in a certain day
# more to see option `-newerXY` in `man find` sudo find /var -type d -newermt 2019-08-30 ! -newermt 2019-08-31 -print 2>/dev/null
-
find dhcp server
sudo nmap --script broadcast-dhcp-discover -e eth0 # for dhcpv6 sudo nmap -6 --script broadcast-dhcp6-discover -e eth0
-
find out the MAC of a given IP
sudo arping -I enp4s0 -c1 172.24.68.179
-
find hostname by IP
# netbios names nmblookup -A <ip> # from dns server nslookup <ip>
-
Using the KDE Wallet to store ssh key passphrases
ssh-add
-
zip文件名乱码
unzip -O cp936 filename
-
run as root in Gui
# in .desktop # see https://wiki.archlinux.org/index.php/Sudo#kdesu X-KDE-SubstituteUID=true
-
visudo导致sudo无法使用时
# 前提是你已经安装相应的 policykit-1-gnome 或者 polkit-kde-agent /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 & pkexec visudo # 否则就只能重启进入recovery或者livecd修复
-
Clean journal
journalctl --rotate --vacuum-time=1d
-
rsync with root
rsync -avPpr -e "ssh" --rsync-path="sudo rsync" fancy@172.24.71.53:/opt/cudnn/cudnn-10.1-linux-x64-v7.5.0.56 /opt/cudnn/
-
runtime path
# refer https://en.wikipedia.org/wiki/Rpath # see RPATH or RUNPATH readelf -d binary-or-library # see `man chrpath` chrpath -l binary-or-library
-
iptables LOG in netns
sysctl -w net.netfilter.nf_log_all_netns=1
Server
-
List human users
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1
-
disable or enable users
# disable chage -E 0 <user> # enable chage -E -1 <user>
Video related
-
# bilibili, 下载 you-get <url> # bilibili, 批量下载 you-get --playlist <url>
-
video info
ffprobe -hide_banner <video>
-
show videos codec
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name <url> find . -type f -print -exec sh -c "ffprobe -v error -select_streams v:0 -show_entries stream=codec_name '{}' |grep codec|sed -e 's/codec_name=//'" \;
-
flv to mp4 with loss
# single ffmpeg -i input.flv -codec copy output.mp4 # loop way for f in *.flv do ffmpeg -i "$f" -codec copy "${f/.flv/.mp4}" done
NeoVIM
显示行号,显示空白字符
:set nu # show line number
:set list # show space
:noh # turn off highlighting until the next search
Vim < 8.1.1365, Neovim < 0.3.6 中存在漏洞,modeline 在root情况下默认关闭
/etc/xdg/nvim/sysinit.vim
-------------------------------
set modeline
ZSH
^left
^right
Backward or forward one word
^u
Clear whole line
^k
Clear to end of line
^w
Delete one word backward
^l
Clear screen
^x u
Undo last change
^y
Yank
pacman
-
Remove orphan package, repeat the cmd multi times
sudo pacman -Ru $(pacman -Qdtq)
cgroup
systemd-cgls
systemd-cgtop
journal
journalctl -f -u <service>
journalctl -b <boot_number>
Exit stuck sessions
ssh
includes the escape character ~
by default. The command ~.
closes an open connection and brings you back to the terminal.