Linux Little Tricks

搜索引擎小技巧

  • cats and dogs Result about cats or dogs
  • "cats and dogs" Result about exact term “cats and dogs”
  • cats -dogs Fewer dogs in result
  • cats +dogs More dogs in result
  • cats filetype:pdf PDFs about cats
    • Supported types: pdf, doc(x), xls(x), ppt(x), html
  • * 模糊
  • .... 范围
  • intitle:标题
  • inurl:网址
  • related:相关类型
  • define:word
  • etymology:"word,"
  • joker site:drive.google.com

Proxy

  • Browser: SwitchyOmega
  • gfwlist: https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
  • Terminal Proxy

CapsLock -> Ctrl

X11

  • xev 展示按下按键的信息
  • pacman -S xorg-xmodmap: xmodmap xmodmap -pke xmodmap -pke > ~/.Xmodmap
  • 使用 remaps 脚本

Wayland

  • dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:ctrl_modifier']"

触控板设置

  • xorg 使用 libinput 配置触控板
  • dwm 默认触控板无法使用单击, 双击等
  • xorg.conf.d 目录下添加 30-touchpad.conf 配置文件, 并添加以下配置
    • 30 表示执行顺序 (10 比 30 先执行)
    • .conf 后缀 arch wiki 说必须加上不可以省略
Section "InputClass"
    Identifier "touchpad"
    Driver "libinput"
    MatchIsTouchpad "on"
    Option "Tapping" "on"
    Option "TappingButtonMap" "lmr"
    Option "NaturalScrolling" "true"
EndSection

多显示器设置

X11 默认多显示器是相同输出, xrandr 可以用来查看显示器输出端口的信息, 可以通过两种方式设置

  1. xrandr --output DP1 --auto --right-of eDP1 可以设置显示器显示不同的内容
  2. 设置配置文件 /etc/X11/xorg.conf.d/40-monitor.conf
Section "Device"
  Identifier "Intel Corporation HD Graphics 630"  # 视频输出的显卡名,可以通过 `lspci -v` 查看
  Option "Monitor-eDP1" "eDP1 screen"
  Option "Monitor-DP1" "DP1 screen"
EndSection

Section "Monitor"
  Identifier "DP1 screen"
  Option "RightOf" "eDP1 screen"
EndSection

Section "Monitor"
  Identifier "eDP1 screen"
EndSection
  • 设置 Xorg 多显示器显示相同的内容
    • xrandr --output DP1 --auto --same-as eDP1
    • --mode 可以设置分辨率

Archlinux install Latex

  • pacman -S texlive-most
    • texlive-most is a package group, includes texlive-core texlive-bin
    • texlive-lang 添加除英文外的其他语言的支持, 不推荐安装
  • pdftex '\empty Hello World!\bye' 查看是否安装成功
  • texdoc 查看帮助文档的命令

NetworkManager

设置 grub 主题

  1. 复制 grub2 主题到 /boot/grub/themes
  2. vim /etc/default/grub 修改 GRUB_THEME=/boot/grub/themes/{theme_name}/theme.txt
  3. grub-mkconfig -o /boot/grub/grub.cfg 重新创建 grub 配置

archlinux using 32位 gcc

首先, 修改 /etc/pacman.conf 文件

[multilib]
Include = /etc/pacman.d/mirrorlist

安装 pacamn -S multilib-devel lib32-glibc lib32-gcc-libs

使用 cronie 设置定时任务

tmux 使用 ssh 连接,断开连接后 tmux session 也会关闭的问题

  • 默认应该是不会发生这种情况的,但如果发生了看下面的解决办法
  • 编辑 /etc/systemd/logind.conf 文件
  • 设置 KillExcludeUsers=root MY_USERNAMEKillUserProcess=no
  • 产生问题的原因应该是 optimus manager 在这个文件中 /usr/lib/systemd/logind.conf.d/*.conf 设置了 KillUserProcess=yes
  • tmux server being killed after logging out

使用 laptop 时关闭合盖后依然保持运行

systemd

file permissions

  • files
    • Read – Can view or copy file contents
    • Write – Can modify file content
    • Execute – Can run the file (if its executable)
  • directories
    • Read – Can list all files and copy the files from directory
    • Write – Can add or delete files into directory (needs execute permission as well)
    • Execute – Can enter the directory

locale problem: not found files

  • Arch: See Installation Guide
  • Fedora: dnf install langpacks-zh_CN
  • Ubuntu:
    • cd /usr/share/locales
    • ./install-language-pack zh_CN.UTF-8
    • dpkg-reconfigure locales

X11 Debug a Window Manager

  • use Xephyr :1 to start a new DISPLAY server
  • use DISPLAY=:1 {gui_command} to start gui_command in the new server

ubuntu using x11 instead of wayland

  • vim /etc/gdm3/custom.conf
  • uncomment this line #WaylandEnable=false

ubuntu disable showing icons in desktop

VirtualBox

Arch Linux Install

  • pacman -S virtualbox
    • 使用virtualbox-host-modules-arch内核依赖
  • 创建虚拟机有问题就重新加载内核执行命令 sudo vboxreload
  • Install extpack
    • download the extension manually
    • sudo VBoxManage extpack install <.vbox-extpack>

VirtualBox in windows 11 are so slow

< << <<< <()

  • input redirections explation

  • gnu redirections

  • <: The input redirection cat < README.md

  • <<: The here document cat > output.txt <<EOF the EOF is an DELIMITER, when stdin recives the DELIMITER, the stdin will close

  • <<<: The here string cat <<< "Demo text" input one line of stings to a script or a command.

  • <(): redirection command output to another command cat <(echo "Demo text")