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] yvisudoを用いて権限の付与を行う。
デフォルトのエディタはviではないため、保存や終了は[Ctrl]+[キー]にて制御する。
# visudo /etc/sudoersが専用のモードで起動する
[USERNAME] ALL=(ALL:ALL) ALL
以下のコマンドにて変更を行う。
# hostnamectl set-hostname [HOSTNAME]
$ sudo timedatectl set-timezone Asia/Tokyo
$ sudo timedatectl
Local time: Sun 2024-04-14 20:18:15 JST
Universal time: Sun 2024-04-14 11:18:15 UTC
RTC time: Sun 2024-04-14 11:18:15
Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: no
NTP service: active
RTC in local TZ: no$ sudo timedatectl list-timezones
# apt -y install language-pack-ja-base language-pack-ja # localectl set-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
# localectl status
System Locale: LANG=ja_JP.UTF-8
LANGUAGE=ja_JP:ja
VC Keymap: jp106
X11 Layout: jp
X11 Model: jp106
X11 Options: terminate:ctrl_alt_bkspUbuntu 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
/etc/netplanにある設定ファイルを修正する。
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