{{tag>ubuntu linux}} # ubuntu いろいろ ちょっと lightsail 上に ubuntu を setup しながら色々とメモ書きを。 ## 16.04 → 18.04 ``` # do-release-upgrade ``` あとは `/etc` 下の conflict を適当に解決((gentoo で言うところの `dispatch-conf` みたいな。))していく。 ## デフォルトのエディター `visudo` とかすると nano 起動しちゃうのを vi に変更する。 ``` # update-alternatives --config editor There are 4 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ * 0 /bin/nano 40 auto mode 1 /bin/ed -100 manual mode 2 /bin/nano 40 manual mode 3 /usr/bin/vim.basic 30 manual mode 4 /usr/bin/vim.tiny 15 manual mode Press to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor ) in manual mode ``` `$EDOTIR` とかでなく `/usr/bin/editor` なる symlink があるのね…… ## iptables ufw よくわからん。 ``` # apt install iptables-persistent ``` lightsail だと基本なにやっても ssh 接続で、所謂コンソールが取れない(取れる?)ので、iptables の設定は失敗するとヤバい。ので、snapshot 取るなりなんなりしてから作業。 INPUT のデフォルトポリシーを DROP にした時点で死んでしまう気がしたので `/etc/iptables/rules.v4` とか `/etc/iptables/rules.v6` とかをいじってリブートした。 ## タイムゾーンと時刻同期 ### タイムゾーン ……雑に `ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime` とかやってはイカンのか(別にそれでも動くんだろうけど……) ``` # ls -l /etc/localtime lrwxrwxrwx 1 root root 27 Sep 17 01:13 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC # timedatectl set-timezone Asia/Tokyo # ls -l /etc/localtime lrwxrwxrwx 1 root root 32 Sep 17 12:00 /etc/localtime -> ../usr/share/zoneinfo/Asia/Tokyo # date Mon Sep 17 12:00:28 JST 2018 ``` ### 時刻同期 /etc/systemd/timesync.conf で同期先を設定できる模様 ``` NTP=ip.addr.of.ntp ``` ``` # systemctl restart systemd-timesyncd # journalctl -e : : Nov 18 12:13:12 ubuntu systemd[1]: Stopping Network Time Synchronization... Nov 18 12:13:12 ubuntu systemd[1]: Stopped Network Time Synchronization. Nov 18 12:13:12 ubuntu systemd[1]: Starting Network Time Synchronization... Nov 18 12:13:12 ubuntu systemd[1]: Started Network Time Synchronization. Nov 18 12:13:12 ubuntu systemd-timesyncd[2174]: Synchronized to time server ip.addr.of.ntp:123 (ip.addr.of.ntp). ``` ## swapfile 別に必須じゃないけれど、今回使ってる lightsail インスタンスが mem:512 なので、この後ちょっとなんかしようとするとすぐメモリ不足で落ちるので…… ``` # dd if=/dev/zero of=/swapfile bs=1024 count=1048576 # chmod 600 /swapfile # mkswap -L swap01 /swapfile # swapon /swapfile # free -m total used free shared buff/cache available Mem: 479 93 322 0 64 369 Swap: 1023 0 1023 ```