sudoers

echo $USER ALL=NOPASSWD: ALL | sudo tee /etc/sudoers.d/$USER

directory

LANG=C xdg-user-dirs-gtk-update

Windowsの時間が9時間ずれる

sudo timedatectl set-local-rtc true

sshd port

Ubuntu 22.10 あたりから / Debian bookworm なども

# ssh.socket のドロップインファイルを作成
sudo SYSTEMD_EDITOR=tee systemctl edit ssh.socket <<'...'
[Socket]
ListenStream=50022
...

sudo systemctl daemon-reload

# 順序よく restart
sudo systemctl stop ssh.socket
sudo systemctl stop ssh.service
sudo systemctl start ssh.socket
sudo systemctl start ssh.service

いにしえの作法

printf 'Port 22\nPort 50022\n' | sudo tee /etc/ssh/sshd_config.d/90-port-50022.conf && sudo systemctl restart ssh

NTP client

systemd-timesyncd

conf=/etc/systemd/timesyncd.conf
sudo sed -i 's/^NTP/#&/' "$conf"
echo 'NTP=server ntp.nict.jp server ntp.jst.mfeed.ad.jp server ntp.ring.gr.jp' | sudo tee -a "$conf"
unset conf
sudo systemctl restart systemd-timesyncd
sleep 10; systemctl status systemd-timesyncd  # 確認

chrony

if [ -d /etc/chrony/sources.d ]; then
  conf=/etc/chrony/sources.d/japan.sources
else
  conf=/etc/chrony/chrony.conf
fi

  sudo tee -a "$conf" <<'...'
server ntp.nict.jp iburst
server ntp.jst.mfeed.ad.jp iburst
server ntp.ring.gr.jp iburst
...

unset conf
sudo systemctl restart chrony
sleep 5
chronyc sources

ノートPCを閉じてもsuspendさせないっ!

2つやる

その1

Ubuntu server 20.04, Debian など

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

その2

sudo tee -a /etc/systemd/logind.conf <<...
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
...
sudo systemctl restart systemd-logind

AntiX

# /etc/elogind/logind.conf
HandleLidSwitch=ignore

systemd で電源管理をしているもの(Arch Linux, etc.)

# /etc/systemd/logind.conf
HandleLidSwitch=ignore

CLIだっ

sudo systemctl set-default multi-user
sudo reboot

podman 入れたあと

conf_user="$HOME/.config/containers/registries.conf"
[ -d "${conf_user%/*}" ] || mkdir -p "${conf_user%/*}"
cat <<'...' >"$conf_user"
unqualified-search-registries = ["docker.io"]
...

プロンプト改行

# シンプル版
PS1="${PS1%\\\$*}\\n\\$ "

# 既に改行が含まれているときは何もしない版
printf %s "$PS1" | grep -qF '\n' || PS1="${PS1%\\\$*}\\n\\$ "

ssh

ssh-keygen -t rsa -C "$(hostname -s)-$(date +%Y%m%d-%H%M)" -N '' -f ~/.ssh/id_rsa
New-NetFirewallRule -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
%LOCALAPPDATA%\_git-sdk-64\usr\bin\ssh.exe -fND 51080 -p 50022 -i %userprofile%\.ssh\id_rsa user@host

minttyrc

Cygwin/MINGW など

echo 'AllowSetSelection=yes' | tee -a ~/.minttyrc

wsltty

tee -a "$(wslpath "$APPDATA\wsltty\config")" <<'...'
AllowSetSelection=yes
...

virtualbox

魴鮄のブログ - VirtualBoxのホストオンリーアダプタの設定方法が変わっていた

[ -d /etc/vbox ] || sudo mkdir -p /etc/vbox
sudo tee /etc/vbox/networks.conf <<'...'
* 10.0.0.0/8 192.168.0.0/16 172.16.0.0/16
...

#11988 (Unable to turn off logging) – Oracle VM VirtualBox

for conf in /etc/environment /etc/default/virtualbox; do
  sudo tee -a "$conf" <<'...'
VBOX_RELEASE_LOG_DEST=nofile
VBOXSVC_RELEASE_LOG_DEST=nofile
VBOX_GUI_SELECTORWINDOW_RELEASE_LOG_DEST=nofile
...
done

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-04-18 (木) 10:50:01