Ubuntu 22 初期設定 のバックアップ(No.3)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- Ubuntu 22 初期設定 へ行く。
- 1 (2023-02-04 (土) 16:51:22)
- 2 (2023-02-06 (月) 14:40:09)
- 3 (2024-04-14 (日) 11:53:44)
OS関連
目次
概要 †
Ubuntu / Ubuntu server 22の初期設定
ユーザ監視 †
ユーザ登録 †
一般的なuseraddではなく、adduserコマンドを使用する。
- 書式
# adduser [USERNAME]
- 例
# adduser osm Adding user `osm' ... Adding new group `osm' (1001) ... Adding new user `osm' (1001) with group `osm' ... Creating home directory `/home/osm' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully Changing the user information for osm Enter the new value, or press ENTER for the default Full Name []: osm Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y
sudo権限付与 †
visudoを用いて権限の付与を行う。
デフォルトのエディタはviではないため、保存や終了は[Ctrl]+[キー]にて制御する。
- 書式
# visudo /etc/sudoersが専用のモードで起動する
- 追記内容(全権限を付与する例)
[USERNAME] ALL=(ALL:ALL) ALL
動作設定 †
ネットワーク設定 †
Ubuntu 22のネットワーク設定はnetplanを用いて行う。
設定ファイルは/etc/netplanに格納されている。
インストール直後には
推奨される手順としては、00-installer-config.yamlが生成されているが、これを元に固有設定を作ることが推奨されている。
- 設定ファイルの作成
cd /etc/netplan cp 00-installer-config.yaml 99_config.yaml mv 00-installer-config.yaml 00-installer-config.bak
- 設定の反映
netplan apply
- エラー対応
- Error in network definition: expected mapping (check indentation)
上記のエラーは設定ファイルのインデントが誤っている場合に発生するため、設定ファイルを見直す。
- Error in network definition: expected mapping (check indentation)
IPアドレスの変更 †
/etc/netplanにある設定ファイルを修正する。
- /etc/netplan/99_config.yaml
network: ethernets: ens160: addresses: - 192.168.103.131/16 routes: - to: default via: 10.10.0.1 nameservers: addresses: - 192.168.0.139 search: [] ens192: addresses: - 192.168.131.202/24 nameservers: addresses: [] search: [] version: 2
以下のコマンドで変更を反映する。
netplan apply
時刻設定 †
- 現在の時刻
# date Sat Feb 4 07:48:37 AM UTC 2023
- タイムゾーンの設定確認
# timedatectl Local time: Sat 2023-02-04 07:49:02 UTC Universal time: Sat 2023-02-04 07:49:02 UTC RTC time: Sat 2023-02-04 07:49:02 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: no NTP service: active RTC in local TZ: no
- タイムゾーンの変更
# timedatectl set-timezone Asia/Tokyo
- 変更結果の確認
# timedatectl Local time: Sat 2023-02-04 16:49:18 JST Universal time: Sat 2023-02-04 07:49:18 UTC RTC time: Sat 2023-02-04 07:49:18 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: no NTP service: active RTC in local TZ: no
# date Sat Feb 4 04:49:21 PM JST 2023