LoginSignup
10
14

More than 3 years have passed since last update.

Ubuntu18.04 インストール後の初期設定メモ

Last updated at Posted at 2019-05-16

はじめに

このドキュメントは Ubuntu Server 18.04 をインストールしたあとに、まずはじめに実施する初期設定をまとめたものです。

おことわり

  • 作業は root で実行してます。
  • 個人的な好みであることをご承知おきください。

環境

~#
~# uname -a
Linux ubuntu1804 4.15.0-23-generic #25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
~#
~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:        18.04
Codename:       bionic
~#

パッケージ関連

アップデート

リポジトリを確認

~#
~# vi /etc/apt/sources.list
deb http://jp.archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://jp.archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb http://jp.archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
~#
~#
~# apt update
~# apt upgrade -y 
~# apt autoremove -y
~#
~# reboot
~#
~#
~# apt update && apt upgrade -y && apt autoremove -y
~#
~# reboot
~#

不要なカーネルファイルを削除

~#
~# dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs apt -y purge
~#

こちらのQiita記事を参考にさせていただきました。

追加パッケージ

~#
~# apt install -y aptitude
~# apt install -y curl dnsutils lsof
~# apt install -y zip unzip
~# apt install -y lsb-release
~# apt install -y tree
~# apt install -y man
~#
~#
~# apt install -y aptitude curl dnsutils lsof zip unzip lsb-release tree man 
~#

設定変更

ipv6無効化

GRUBの設定変更で対応する。
sysctl.conf で設定しても無効化できないようです。

~#
~# vi /etc/default/grub
 :
GRUB_CMDLINE_LINUX="ipv6.disable=1"
 :
~# 
~# update-grub
~# 
~# reboot
~# 

cf. Ubuntu18.04に移行 SSHと静的IPアドレス、IPv6無効化、タイムゾーン設定

起動時の待ち時間をなくす

OS起動途中で A start job is running for wait for network to be configured. という表示が出て数分待たされるのを回避する
systemctl disable ~ を実行しただけではだめで、systemctl mask ~ も実行する。

~#
~# systemctl disable systemd-networkd-wait-online.service
~# systemctl mask systemd-networkd-wait-online.service
~#

cf. ubuntu がネットワーク待ちで起動が遅い・・・

リソース監視をするためにsarコマンドを使えるようにする

~#
~# apt install -y sysstat
~#
~# vi /etc/default/sysstat
 :
ENABLED="false"
 ↓
ENABLED="true"
 :
~#

NTPサーバー(systemd-tymesyncd)

~#
~# vi /etc/systemd/timesyncd.conf
 :
[Time]
NTP=ntp.nict.jp ntp.jst.mfeed.ad.jp
 :
~#
~# systemctl start systemd-timesyncd
~#
~# systemctl enable systemd-timesyncd
~#

timezone変更

~#
~# unlink /etc/localtime
~# ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
~# date
2017年 10月 13日 金曜日 00:29:30 JST
~#

locale変更

~#
~# apt install -y language-pack-ja
~# update-locale LANG=ja_JP.UTF-8
~# . /etc/default/locale
~#
~# vi /etc/bash.bashrc
 :
# set LANG
if [ -f /etc/default/locale ]; then
    . /etc/default/locale
fi
 :
~#

デフォルトエディタを変更

~# 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    10        manual mode

Press <enter> 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
~#

変更履歴

2020/3/4

  • アップデート:aptコマンドのオプションを精査しました
  • timezoneの変更:変更方法を修正しました
  • ネットワーク設定削除
  • 再起動が必要な箇所に reboot を追記
  • apt-get を apt に統一
10
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
14