Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save minazou67/fc7ee985ca17eb618d5926565ad6ee78 to your computer and use it in GitHub Desktop.
Save minazou67/fc7ee985ca17eb618d5926565ad6ee78 to your computer and use it in GitHub Desktop.
Settings Note after debian-netinst installation

Settings Note after debian-netinst installation

Debian をネットワークインストールした直後に設定する最低限の項目の設定メモです。

Environment

Network install (debian-8.5.0-amd64-netinst.iso)

Settings of installation

  • 言語(Japanese)
  • 地域(日本)
  • キーボードレイアウト(日本語)
  • ホスト名(Any)
  • ドメイン名(Any)
  • rootのパスワード(Any)
  • ユーザアカウント(非管理者権限)のフルネーム(Any)
  • ユーザアカウントのユーザ名(Any)
  • ユーザアカウントのパスワード(Any)
  • ディスクのパーティショニング方法(Any)
  • Debianアーカイブミラーの国(日本)
  • Debianアーカイブミラー(ftp.jp.debian.org)
  • HTTP プロキシ(Any)
  • Debianパッケージ利用調査に参加しますか(Any)
  • インストールするソフトウェアの選択(SSHサーバ、標準システムユーティリティ)
  • GRUB ブートローダをインストールしますか(はい)
  • ブートローダをインストールするデバイス(/dev/sda)

First of all

パッケージのアップグレード

スーパーユーザー(root)に切り替え、パッケージを最新にアップグレード。

$ su
$ apt update
$ apt upgrade -y

追加パッケージのインストール

最低限必要となるパッケージを追加でインストール。
bash-completion はインストールされているはず。

$ apt install -y git unzip curl fontconfig samba libnss-winbind build-essential alien

vim のインストール

必要に応じて高機能版の vim をインストール。
インストールされている vim を確認。

$ dpkg -l | grep -i vim
ii  vim-common                     2:7.4.488-7                 amd64        Vi IMproved - Common files
ii  vim-tiny                       2:7.4.488-7                 amd64        Vi IMproved - enhanced vi editor - compact version

vim-nox (スクリプティングサポートあり/GUI なし)をインストール。

$ apt install -y vim-nox
ii  vim-common                     2:7.4.488-7                 amd64        Vi IMproved - Common files
ii  vim-nox                        2:7.4.488-7                 amd64        Vi IMproved - enhanced vi editor - with scripting languages support
ii  vim-runtime                    2:7.4.488-7                 all          Vi IMproved - Runtime files
ii  vim-tiny                       2:7.4.488-7                 amd64        Vi IMproved - enhanced vi editor - compact version

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

デフォルトエディタを vim-nox に変更。

$ update-alternatives --config editor
alternative editor (/usr/bin/editor を提供) には 3 個の選択肢があります。

  選択肢    パス             優先度  状態
------------------------------------------------------------
* 0            /bin/nano           40        自動モード
  1            /bin/nano           40        手動モード
  2            /usr/bin/vim.nox    40        手動モード
  3            /usr/bin/vim.tiny   10        手動モード

現在の選択 [*] を保持するには Enter、さもなければ選択肢の番号のキーを押してください: 2
update-alternatives: /usr/bin/editor (editor) を提供するためにマニュアルモードで /usr/bin/vim.nox を使います

sudo コマンドのインストールと設定

sudo コマンドをインストール。

$ apt install -y sudo

コマンド実行可能なユーザーを追加。

$ visudo
# User privilege specification
root    ALL=(ALL:ALL) ALL
hoge    ALL=(ALL:ALL) ALL

NTP サーバーのインストールと設定

ハードウェアクロックの設定を確認。

$ cat /etc/adjtime
-0.001801 1466072190 0.000000
1466072190
UTC

現在の日時を確認。

$ date
2016年  6月 28日 火曜日 10:40:15 JST
$ date --u
2016年  6月 28日 火曜日 01:40:19 UTC
$ hwclock --show
2016年06月28日 10時40分26秒  -0.707770 seconds
$ hwclock --show --utc
2016年06月28日 10時40分35秒  -0.660861 seconds
$ hwclock --show --localtime
2016年06月28日 01時40分39秒  -0.379610 seconds

NTP サーバーをインストール。

$ apt install -y ntp

同期するサーバーを追加。

$ vi /etc/ntp.conf
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
server ntp.nict.jp
server ntp.nict.jp
server ntp.nict.jp

NTP サーバーを再起動。

$ /etc/init.d/ntp restart
[ ok ] Restarting ntp (via systemctl): ntp.service.

NTP サーバーの動作状況を確認。
同期サーバーが反映されるのには、少し時間が掛かります。

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp-b2.nict.go. .NICT.           1 u   18   64    1    9.741   -3.431   0.000
 ntp-a3.nict.go. .NICT.           1 u   17   64    1    9.337   -3.567   0.000
 ntp-a2.nict.go. .NICT.           1 u   16   64    1    9.612   -2.822   0.000
*y.ns.gin.ntt.ne 249.224.99.213   2 u    5   64    1    8.875   -7.365   0.047
 next.kkyy.me    133.243.238.244  2 u    4   64    1    8.786   -2.959   0.051
 bd.90.caa1.ip4. 133.243.238.244  2 u    3   64    1    9.126   -3.598   0.156
 balthasar.gimas 5.125.62.87      3 u    2   64    1    9.164   -2.909   0.162

システムクロックとハードウェアクロックを定期的に同期するために cron を設定。

$ crontab -e
0 4 * * * root /sbin/hwclock -w > /dev/null 2>&1

ネットワークの設定

必要に応じて IP アドレスを変更し、DNS サーバを追加。

$ vi /etc/network/interfaces
# The primary network interface
allow-hotplug eth0
iface eth0 inet static
 address 192.168.100.123
 netmask 255.255.255.0
 network 192.168.100.0
 broadcast 192.168.100.255
 gateway 192.168.100.2
 dns-nameservers 192.168.1.11
$ vi /etc/hosts
127.0.0.1 localhost
192.168.100.123 hoge.example.com hoge

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

ネットワークを再起動。

$ /etc/init.d/networking restart

ルーティングテーブルの確認。

$ ip route
default via 192.168.100.2 dev eth0
192.168.100.0/24 dev eth0  proto kernel  scope link  src 192.168.100.123

ホスト名の変更

ホスト名を変更したい場合は下記のファイルを変更し、ネットワークを再起動。

$ vi /etc/hostname
$ vi /etc/hosts
$ /etc/init.d/networking restart

Samba の設定

必要に応じて Samba の Wins Server を設定。

$ vi /etc/samba/smb.conf
# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
   wins server = 192.168.1.15

Samba を再起動。

$ /etc/init.d/samba restart

名前解決の参照先を追加

nsswitch.confhostswins を追加します。

$ vi /etc/nsswitch.conf
hosts:          files dns wins

日本語フォントのインストール

必要に応じて日本語フォントをインストール。
/usr/share/fonts/truetype/ 配下にディレクトリを作成し、TTFフォントファイルを格納。
フォントキャッシュを更新。

$ fc-cache -fv
/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/X11: caching, new cache contents: 0 fonts, 3 dirs
/usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/misc: caching, new cache contents: 3 fonts, 0 dirs
/usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 3 dirs
/usr/share/fonts/truetype/IPAfont00303: caching, new cache contents: 4 fonts, 0 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/truetype/unifont: caching, new cache contents: 5 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/dev/.local/share/fonts: skipping, no such directory
/home/dev/.fonts: skipping, no such directory
/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/dev/.local/share/fonts: skipping, no such directory
/home/dev/.fonts: skipping, no such directory
/var/cache/fontconfig: not cleaning unwritable cache directory
/home/dev/.cache/fontconfig: cleaning cache directory
/home/dev/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded

使用可能なフォントを確認。

$ fc-list
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
/usr/share/fonts/truetype/unifont/unifont.ttf: Unifont:style=Medium
/usr/share/fonts/truetype/unifont/unifont_upper.ttf: Unifont Upper:style=Medium
/usr/share/fonts/truetype/IPAfont00303/ipagp.ttf: IPA Pゴシック,IPAPGothic:style=Regular
/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
/usr/share/fonts/truetype/IPAfont00303/ipamp.ttf: IPA P明朝,IPAPMincho:style=Regular
/usr/share/fonts/truetype/unifont/unifont_csur.ttf: Unifont CSUR:style=Medium
/usr/share/fonts/truetype/IPAfont00303/ipag.ttf: IPAゴシック,IPAGothic:style=Regular
/usr/share/fonts/truetype/IPAfont00303/ipam.ttf: IPA明朝,IPAMincho:style=Regular
/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf: DejaVu Serif:style=Book
/usr/share/fonts/truetype/unifont/unifont_upper_csur.ttf: Unifont Upper CSUR:style=Medium

cron のログ出力設定を変更

必要に応じて cron のログが出力されるように変更。
cron ログのコメントアウトを解除。

$ vi /etc/rsyslog.conf
cron.* /var/log/cron.log

cron を再起動。

$ /etc/init.d/cron restart

Mail Delivery Agent (MDA) の設定

必要に応じて Debian 標準の MDA (Exim4) を設定。
メールを外部へ送信する場合は、「インターネットサイト」を選択。

$ sudo dpkg-reconfigure exim4-config
$ sudo /etc/init.d/exim4 restart
  • メール設定の一般的なタイプ
    • インターネットサイト; メールは SMTP を使って直接送受信される
  • システムメール名
    • ホスト名
  • 入力側 SMTP 接続をリスンする IP アドレス
    • 127.0.0.1 ; ::1(デフォルト値のまま)
  • メールを受け取るその他の宛先
    • Blank
  • メールをリレーするドメイン
    • Blank
  • メールをリレーするマシン
    • Blank
  • DNS クエリの数を最小限に留めますか
    • いいえ
  • ローカルメールの配送方式
    • /var/mail/ 内の mbox 形式
  • 設定を小さなファイルに分割しますか
    • いいえ

メールの送信テストを実施。

$ mail -s "メールタイトル" 送信先メールアドレス
本文
.
Cc:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment