踩坑小笔记 第一期

Clayton Ryan Lv2

本篇主要记录本人在折腾路上碰到的一些小问题以及简要的解决方案,希望能帮到有需要的各位。

一. Linux篇

1.1 为虚拟显示器设置自定义分辨率

set custom resolution for virtual displays

1
2
3
4
cvt 1366 768
xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
xrandr --addmode DP-1 1368x768_60.00
xrandr --output DP-1 --mode 1368x768_60.00 && sleep 15 && xrandr --output DP-1 --mode 1920x1080_60.00

(cvt is used to detect proper Modeline for specified resolution, like a calculator, and its output can be used in following xrandr commands.)

1.2 设置systemd日志文件最大大小

set maximum size of systemd journal

1
2
3
4
vi /etc/systemd/journald.conf
systemctl restart systemd-journald.service
journalctl --vacuum-time=2d
journalctl --vacuum-size=50M

Inside journald.conf, set your desired limit, like SystemMaxUse=50M, then run sudo systemctl restart systemd-journald.service to apply changes.

1.3 修复系统中文支持异常问题,如无法显示中文路径

fix Chinese support in Linux

1
2
3
locale -a
vi /etc/locale.gen
sudo locale-gen

In locale.gen, uncomment zh_CN.UTF-8 UTF-8 and zh_CN GB2312.

1.4 在bash中使用sudo重新执行上一条指令

1
sudo !!

1.5 让系统多使用物理内存,少使用交换空间

make system use more physical memory and less swap space

1
2
3
sudo vi /etc/sysctl.conf
# add this line
# vm.swappiness=10

1.6 为apt设置https代理

set https proxy for apt

Temporary proxy: add this parameter in your apt command:

1
-o Acquire::http::proxy="http://127.0.0.1:1080"

二. Windows篇

2.1 移除‘此电脑’中不需要的库文件夹

remove unnecessary folders in ‘This PC’, like ‘3D Objects’

1
2
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace
- Delete {0DB7E03F-FC29-4DC6-9020-FF41B59E513A}

(Or use a third-party software to do this visually, like ‘Windows11 Manager’.)

2.2 修改系统RDP端口

change RDP port for major Windows versions

1
2
3
4
5
(Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" -Name PortNumber).PortNumber

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" -Name PortNumber -Value 6543
# test with command below:
Get-NetTCPConnection -LocalPort 6543; Get-NetUDPEndpoint -LocalPort 6543

(Also see Microsoft official link)

三. Miscellaneous

3.1 修复代码文件在不同系统间移动时因行分隔符不同而导致的无效git操作

fix line endings in git

1
git config --global core.autocrlf input

3.2 为Git配置https代理

set https proxy for git

1
git config --global https.proxy http://127.0.0.1:1080

(effective for repos whose remote is in https protocol, check with git remote -v)

3.3 为ssh配置socks5代理

set socks5 proxy for ssh in user config file

Add following line in your .ssh/config file:

1
2
3
4
5
Host github.com
User git
IdentityFile ~/.ssh/id_rsa
# ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p # if `nc` is installed
ProxyCommand connect -S 127.0.0.1:1080 %h %p # for git bash on windows

And remind that ‘connect’ maybe not in your PATH so cannot be executed directly, you can find it in your git installation directory, like C:\Program Files\Git\mingw64\bin\connect.exe, and use that path to replace the single connect in above commands.

  • Title: 踩坑小笔记 第一期
  • Author: Clayton Ryan
  • Created at : 2024-01-24 10:41:00
  • Updated at : 2024-01-24 12:13:02
  • Link: https://blog.eddy.moe/2024/01/24/GeneralNote-1/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments