Ubuntu 24.04.2 LTSをクリーンインストールしたので,その際に行った初期設定もろもろを覚書。
パッケージの更新
$ sudo apt-get update
$ sudo apt-get upgrade
パッケージの自動アップデートの設定
unattended-upgradesのインストール
$ sudo apt-get install unattended-upgrades
有効化
$ sudo dpkg-reconfigure -plow unattended-upgrades
<Yes>を選択
updatesのコメントアウトを外す
// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
- // "${distro_id}:${distro_codename}-updates";
+ "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};
日本語入力
mozcをインストール
$ sudo apt install -y ibus-mozc
$ sudo apt install -y mozc-utils-gui
sudo reboot
した後Settingsを開き,Keyboard
> Input Sources
にJapanese (Mozc)
およびJapanese (OADG 109A)
を追加。
キーボードの設定
$ sudo dpkg-reconfigure keyboard-configuration
Generic 104-key PC with L-shaped Enter key
> Japanese
> Japanese - Japanese (OADG 109A)
> The default for the keyboard layout
> No compose key
> Yes
Caps Lockを日本語/英語入力切り替えに割り当てる
キーの割り当ての変更
Caps_Lock
とZenkaku_Hankaku
を入れ替え
xmodmap
でキー割り当てを確認
remove lock = Eisu_toggle
add lock = Zankaku_Hankaku
~$ xmodmap .Xmodmap
~/.bashrc
の最後尾に以下を追記
xmodmap ~/.Xmodmap
日本語/英語入力切替(IME切り替え)のショートカットの設定
Settings
> Keyboard
> Keyboard Shortcuts
> View and Customize Shortcuts
> Typing
> Switch to next input source
をEisu toggle
に
良く使うソフトのインストール
gedit
$ sudo apt install gedit
VSCode
$ sudo apt install curl
$ curl -L https://go.microsoft.com/fwlink/?LinkID=760868 -o vscode.deb
$ sudo apt install ./vscode.deb
Google Chrome
$ curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$ sudo apt install ./google-chrome-stable_current_amd64.deb
ClamAV(ウイルス対策ソフト)
$ sudo apt install clamav clamav-daemon
$ sudo systemctl start clamav-daemon
$ sudo systemctl status clamav-daemon
確認してもactiveになっていなかったので再起動したら直った。
$ sudo systemctl restart clamav-freshclam
$ sudo systemctl restart clamav-daemon
スキャン
$ sudo clamdscan --fdpass /path/to/scan/target
リモートデスクトップの設定(ローカル)
Desktop Sharingの有効化
Settingsを開き,System
> Remote Desktop
> Desktop Sharing
とRemote Control
のトグルをオン。microsoftのRDPを使用している。xrdpなどの面倒な設定は不要。
ローカルのWindowsクライアントから接続
Windows + R
でプログラム名mstsc
を指定してリモートデスクトップ接続を開き,Ubuntuのホスト名に.local
を付与したものを入力。
Login Detailsで設定されたユーザー名とパスワードでログイン。
リモートデスクトップの設定(LANの外から)
Desktop Sharingを使用して接続してもいいのだが,ポート開放が必要だしセキュリティリスクも上昇する。VPN対応ルーターを導入してもいいがコストがかかる。
そこでchromeリモートデスクトップを使用する。
SSH経由でセットアップする
- ホスト側のUbuntuからChromeで上のリンクにアクセス
- リンク先のソフトをインストール
- 指示に従ってコマンドを実行
- Ubuntuをログアウト
ログアウトしないと接続できないので注意 - クライアント側のChromeで上のリンクにアクセス
リモートのデバイスに表示されたコンピュータ名をクリックで接続できる
XSession, Ubuntu (Wayland), Ubuntu on Xorgのどれかを選択
下記の設定のためUbuntu on Xorgを選択
Ubuntuの自動スリープを無効にする
スリープ等してしまうと接続できなくなってしまうので,自動スリープを無効にする
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
戻すときは次のようにする
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
Ubuntu側でログインしている画面をリモートで操作できるようにする
同一アカウントでの同時ログインはできないので、Ubuntu側でログインしている画面を参照できるようにChromeリモートデスクトップの設定を変更する。
Chromeリモートデスクトップの停止
$ /opt/google/chrome-remote-desktop/chrome-remote-desktop --stop
設定ファイルの編集
$ sudo gedit /opt/google/chrome-remote-desktop/chrome-remote-desktop
- FIRST_X_DISPLAY_NUMBERの変更
X Window Systemにおいてアプリケーションをどのディスプレイに表示させるかを設定するDISPLAY環境変数を確認ここで表示されたディスプレイ番号を設定$ echo $DISPLAY :1 // 出力結果 (ホスト):(ディスプレイ).(スクリーン)
/opt/google/chrome-remote-desktop/chrome-remote-desktop- FIRST_X_DISPLAY_NUMBER = 20 + FIRST_X_DISPLAY_NUMBER = 1 //ここにディスプレイ番号を設定
- launch_session()の修正
使用するディスプレイを明示/opt/google/chrome-remote-desktop/chrome-remote-desktopdef launch_session(self, server_args, backoff_time): """Launches process required for session and records the backoff time for inhibitors so that process restarts are not attempted again until that time has passed.""" logging.info("Setting up and launching session") self._setup_gnubby() - self._launch_server(server_args) + # self._launch_server(server_args) - if not self._launch_pre_session(): - # If there was no pre-session script, launch the session immediately. - self.launch_desktop_session() + # if not self._launch_pre_session(): + # If there was no pre-session script, launch the session immediately. + # self.launch_desktop_session() + display = self.get_unused_display_number() + self.child_env["DISPLAY"] = ":%d" % display self.server_inhibitor.record_started(MINIMUM_PROCESS_LIFETIME, backoff_time) self.session_inhibitor.record_started(MINIMUM_PROCESS_LIFETIME, backoff_time)
chromeリモートデスクトップの起動
$ /opt/google/chrome-remote-desktop/chrome-remote-desktop --start
session already runningでログインできないとき
chromeリモートデスクトップを削除して再インストール
- セッションの停止
Ctr+Alt+F2
でCUI環境に変更し、エラーが発生しているユーザーでログイン。セッションの停止。$ sudo pkill -KILL -u <username>
- chromeリモートデスクトップのアンインストール
$ sudo apt-get remove --purge chrome-remote-desktop
- 関連ファイルの削除
$ sudo rm -rf ~/.config/chrome-remote-desktop
- 再起動
$ sudo shutdown -r now
- 再インストールと再設定
WindowsからchromeリモートデスクトップでUbuntuに接続すると右シフトキーが反応しない問題
xevでイベント検出もされない。chromeリモートデスクトップの右側の設定でキーマッピングを変更しても解決しなかった。そこでPowerToysのKeyboard Managerを使ってShift(Right)をShift(Left)に再マップした。