Ubuntu 18.04 LTS (Bionic Beaver)のインストールと初期設定・環境構築について。

目的と内容
最小インストールを用いてクリーンインストールする
デスクトップPCを開発機兼内向けサーバ機として構成する
本文の構成
§.インストール
ライブUSBを使ってUbuntuを起動し、構成確認・ネットワーク設定・パーティショニングなどの下準備を行ってからインストールを行う
§.設定ファイルの編集
ターミナル・シェルの設定固定IPでのネットワーク設定などを行う
§.ソフトウェアの追加と削除
不要なパッケージの削除使用するパッケージの追加などを行う
§.デスクトップ環境の設定とカスタマイズ
デスクトップアプリの初期設定などを行う
§.開発環境の設定
開発環境や各種サーバーの初期設定を行う

インストール

以下はubuntu-18.04-desktop-amd64.isoを使用した場合の手順。

USBの場合、「ブータブルUSBの作成」(usb-creator-gtk)を起動することでISOイメージからブータブルUSBを作成することができる。

下準備

CD-ROMあるいはUSBにインストールしたディスクイメージを使ってブートする。 試用しつつデバイス類や必要な機能が動作するかどうかの確認、パーティション設定などインストール前の下準備を行う。

【Welcome】

  1. 左の言語一覧から[日本語]を選択
  2. [Ubuntuを試す]をクリック

デスクトップが表示されたら、必要に応じて右上のネットワークアイコンをクリックしてネットワーク設定などを行う。 設定ファイルを編集して設定する必要がある場合は§.ネットワークの設定を参照。

パーティショニング

  1. 左下のShow Applicationsから"gparted"等と入力してGPartedを起動する
  2. LVMパーティションを扱う場合はlvm2、RAIDディスクを扱う場合はmdadmなどをインストールする
  3. インストールに必要なパーティショニングを行う
    1. UEFIモードでインストールする場合、かつ手動でパーティショニングを行う場合は、EFIブートパティションを作成しておく

最小インストールではmdadmがインストールされない。 そのため、mdadmで管理されたRAIDアレイ上のパーティションにマウントポイントを置いた構成でインストールすると、初回起動時にマウントできず起動に失敗する? (検証不十分につき要注意)

構成の確認

  1. LVM・キーボード等その他構成の確認を行っておく
  2. バックアップ等の確認を行っておく

インストール

デスクトップの[Ubuntu 18.04 LTSのインストール]のアイコンからインストールを開始する。

ここで事前にシステムモニタを起動しておくとシステム状態とインストーラの状態(ダウンロード中か、IO処理中か)を把握しやすい。 また、[Settings]→[Power]→[Power Saving]の[Blank screen]をNeverに設定しておくことでインストール中に画面をオフにしない・ロックしないようにしておく。

インストール中、ダイアログが画面をはみ出して読めない・フォーカスできない・ボタンが押せない場合は、ALT+F7を押すことによりウィンドウ端を画面外まで移動させることができるようになる。

【ようこそ】

  1. 左の言語一覧で[日本語]が選択されていることを確認する
  2. [続ける]

【キーボードレイアウト】

  1. 適切なキーボードが選択されていることを確認する
  2. [続ける]

【アップデートと他のソフトウェア】

  1. [最小インストール]を選択する
  2. [その他のオプション]
    1. [インストール中にアップデートをダウンロードする]にチェックを入れる
    2. 必要に応じて[サードパーティーのソフトウェアをインストールする]にチェックを入れる
  3. [続ける]

【インストールの種類】

  1. [それ以外]を選択 (パーティション設定を行う場合)
  2. [続ける]

【パーティション設定】

  1. 使用するデバイス・マウントポイント等を設定する
  2. [インストール]をクリック
  3. ディクスへの変更内容を確認して[続ける]

インストールが開始される。

【どこに住んでいますか?】

  1. 適切なタイムゾーンを選択
  2. [続ける]

【あなたの情報を入力してください】

  1. ユーザー名、コンピューター名、パスワード等を入力
  2. [続ける]

以降、インストールが終了するまで待つ。

【インストールが完了しました】

  1. [今すぐ再起動する]

(CD-ROMの場合はディスクが排出されたら)メディアを取り外して[ENTER]を押して再起動させる

初回ログイン時の設定

初回ログイン時はダイアログが表示されるので、ウィザードに従って必要事項を設定・入力する。

  1. 【Ubuntuの新機能】
    1. [次へ]
  2. 【Livepatch】
    1. 必要に応じて[Livepatchをセットアップ]をクリックする
      1. セットアップする場合、Ubuntu Oneアカウントが要求されるので、アカウントを登録するか既存のアカウントで接続する
  3. 【Ubuntuの改善を支援する】
    1. システム情報を送信するかどうかを選択して[次へ]
  4. 【準備完了】
    1. [完了]

設定ファイルの編集

ターミナル・シェル・ネットワーク・その他システムの設定ファイルなどを初期設定する。

ターミナル・シェル・エディタ周りの設定

ターミナル(Gnome Terminal)の設定

以下の内容で設定ファイルを用意しておく。 あるいはエクスポートしたものを用意しておく。

terminal.dconf
[legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9]
visible-name='default'
palette=['rgb(46,52,54)', 'rgb(204,0,0)', 'rgb(78,154,6)', 'rgb(196,160,0)', 'rgb(52,101,164)', 'rgb(117,80,123)', 'rgb(6,152,154)', 'rgb(211,215,207)', 'rgb(85,87,83)', 'rgb(239,41,41)', 'rgb(138,226,52)', 'rgb(252,233,79)', 'rgb(114,159,207)', 'rgb(173,127,168)', 'rgb(52,226,226)', 'rgb(238,238,236)']
default-size-columns=110
default-size-rows=20
cursor-shape='block'
cursor-blink-mode='on'
text-blink-mode='always'
use-system-font=true
use-theme-colors=true
use-transparent-background=true
use-theme-transparency=false
background-transparency-percent=20

[legacy]
schema-version=uint32 3
default-show-menubar=false

上記の設定ファイルをインポートする。

Gnome Terminal設定をファイルからインポートする
dconf load /org/gnome/terminal/ < terminal.dconf

設定をエクスポートする場合は以下のようにする。

Gnome Terminal設定をファイルにエクスポートする
dconf dump /org/gnome/terminal/ > terminal.dconf

テキストエディタ(Gedit)の設定

以下の内容で設定ファイルを用意しておく。 あるいはエクスポートしたものを用意しておく。

gedit.dconf
[preferences/editor]
display-right-margin=false
highlight-current-line=true
display-overview-map=true
bracket-matching=true
scheme='oblivion'
tabs-size=uint32 2
editor-font='Noto Sans Mono CJK JP 10'
display-line-numbers=true
insert-spaces=true
background-pattern='none'
use-default-font=false
wrap-last-split-mode='word'
auto-indent=true

[preferences/ui]
show-tabs-mode='auto'

[plugins/drawspaces]
draw-spaces=['space', 'tab', 'nbsp', 'leading', 'text', 'trailing']

[plugins]
active-plugins=['drawspaces', 'git']

上記の設定ファイルをインポートする。

Gedit設定をファイルからインポートする
dconf load /org/gnome/gedit/ < gedit.dconf

プラグインのインストール等はこのあと§.使用するパッケージをインストールするで行う。

設定をエクスポートする場合は以下のようにする。

Gedit設定をファイルにエクスポートする
dconf dump /org/gnome/gedit/ > gedit.dconf

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

デフォルトのエディタをvimにする。

update-alternatives
sudo update-alternatives --config editor
update-alternativesを使ってデフォルトエディタを変更する例
alternative editor (/usr/bin/editor を提供) には 3 個の選択肢があります。

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

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

~/.vimrc

以下の内容で作成。

~/.vimrc
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,utf-16,japan

set backspace=indent,eol,start

set tabstop=2
set shiftwidth=2
set expandtab

highlight tabs ctermbg=green guibg=green

set list
set number
set showmatch
set ruler
set smartindent

~/.bash_aliases, ~/.bashrc

~/.bash_aliasesを作成して以下のエイリアスを書き込む。

~/.bash_aliases
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

if [[ -x `which git` ]]; then
  alias diff='git --no-pager diff --no-index --color'
else
  alias diff='diff -u'
fi

~/.bashrcを編集して、force_color_promptyesにする。 また、このあと作成する~/.bash_promptを読み込むように設定する。

~/.bashrc
# コメントアウトされているので解除する
force_color_prompt=yes

  :
  :

# .bash_promptがある場合はそれを読み込んでプロンプトの内容を設定させる
if [ -f ~/.bash_prompt ]; then
    . ~/.bash_prompt
fi

# 下記コマンドの前あたりに上記を記述する
unset color_prompt force_color_prompt

  :
  :

プロンプトの内容を設定するファイル~/.bash_promptを作成する。 (以下は参考程度に。 好みに合わせて変数$PS1を設定する。)

~/.bash_prompt
function __prompt_reset_color() {
  echo -n '\[\e[m\]'
}

function __prompt_status_time() {
  if [ $? = 0 ]; then
    echo -n '\[\e[1;32m\]✔'
  else
    echo -n '\[\e[1;31m\]✖'
  fi

  echo -n ' \t'

  __prompt_reset_color
}

function __prompt_user_host_env() {
  echo -n '\[\e[1;33m\]\u'
  __prompt_reset_color

  echo -n '@'

  echo -n '\[\e[1;36m\]\h'
  __prompt_reset_color

  if [ -n "$ENV_NAME" ]; then
    echo -n '%'

    echo -n '\[\e[1;35m\]${ENV_NAME}'
    __prompt_reset_color
  fi
}

function __prompt_working_directory() {
  echo -n '\[\e[0;37m\]\w'
  __prompt_reset_color
}

function __prompt_euid() {
  if [ ${EUID:-${UID}} = 0 ]; then
    echo -n '\[\e[1;31m\]'
  fi
  echo -n '\$'
  __prompt_reset_color
}

function __set_ps1() {
  PS1="$1$2"
}

function __set_prompt_command() {
  PS1_PRE='[$(__prompt_status_time) <$(__prompt_user_host_env)>'
  PS1_POST=' $(__prompt_working_directory)]$(__prompt_euid) '

  #
  # git-prompt.sh
  # https://github.com/git/git/tree/master/contrib/completion
  #
  if [ -f ~/.git-prompt.sh ]; then
    . ~/.git-prompt.sh

    GIT_PS1_SHOWDIRTYSTATE=true
    GIT_PS1_SHOWSTASHSTATE=true
    GIT_PS1_SHOWUNTRACKEDFILES=true
    GIT_PS1_SHOWUPSTREAM=
    GIT_PS1_SHOWCOLORHINTS=true
    GIT_PS1_HIDE_IF_PWD_IGNORED=true

    PROMPT_COMMAND="__git_ps1 \"$PS1_PRE\" \"$PS1_POST\" ' (%s)'"
  else
    PROMPT_COMMAND="__set_ps1 \"$PS1_PRE\" \"$PS1_POST\""
  fi
}

if [ "$color_prompt" = yes ]; then
  __set_prompt_command
fi

この設定では次のようなプロンプトを表示する。

表示されるプロンプトの例
[✔ 10:10:10 <smdn@hostname> ~]$ ^C
[✖ 10:10:10 <smdn@hostname> ~]$ 
[✔ 10:10:10 <smdn@hostname> ~/Desktop]$ 
[✔ 10:10:10 <smdn@hostname> (master) /build/mono/master/mono]$ git status 
[✔ 10:10:10 <root@hostname> /root]#

以降、bashを起動すると上記の内容が読み込まれる。 変更した内容をすぐに反映させたい場合はsource .bashrcで再読み込みすることができる。

ネットワークの設定

以下は、NetworkManagerを無効にしてsystemd-networkdによる管理を行い静的IPアドレスでのネットワークを設定する手順。

NetworkManagerによる管理を無効にする

NetworkManagerを無効にする。

NetworkManagerの無効化
sudo systemctl disable network-manager
echo "manual" | sudo tee /etc/init/network-manager.override

NetworkManager用のnetplan設定ファイルを削除する。 (以降の設定用に流用して書き換える場合はリネームする。)

NetworkManager設定ファイルの削除
sudo rm /etc/netplan/01-network-manager-all.yaml

NetworkManagerを無効にしてもトップバーやメニュー等にネットワーク設定が表示される箇所が残るので、それらも削除する場合はnmcliでオフにする。

nmcli networking off

これによりnmcli generalで表示されるSTATEが休止中となる。

$ nmcli general
STATE   CONNECTIVITY  WIFI-HW  WIFI  WWAN-HW  WWAN 
休止中  不明          有効     有効  有効     有効

ネットワークインターフェイスを設定する

ネットワークインターフェイスとデバイス名を確認する。 設定するデバイス名が既知の場合はnetworkctl status デバイス名とする。 すべてのデバイスを表示する場合はデバイス名の代わりに-aオプションを指定する。

$ networkctl status -a
● 1: lo
       Link File: n/a
    Network File: n/a
            Type: loopback
           State: carrier (unmanaged)
         Address: 127.0.0.1
                  ::1

● 2: enp1s0
       Link File: n/a
    Network File: /run/systemd/network/10-netplan-enp1s0.network
            Type: ether
           State: routable (configured)
            Path: *********
          Vendor: *********
           Model: *********
      HW Address: **:**:**:**:**:**
         Address: 192.168.0.10
                  xxxx::xxxx:xxxx:xxxx:xxxx
         Gateway: 192.168.0.1
             DNS: 192.168.0.1

以下、上記のコマンドで表示されたデバイスenp1s0を設定の対象とする。


/etc/netplan/ディレクトリに以下の内容でnetplan設定ファイルを作成する。 ここではファイル名を01-netcfg.yamlとした。

/etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      addresses: [192.168.0.10/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [192.168.0.1]
      dhcp4: false
      dhcp6: false

真偽値を設定する項目では、true/falseの代わりにon/offあるいはyes/noを指定することもできる。

参考として、上記の設定は下記/etc/network/interfacesでの設定と同等のものとなる。

/etc/network/interfaces
auto lo
iface lo inet loopback

auto enp1s0
iface enp1s0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1

sudo netplan generate, sudo netplan applyで変更した設定を適用する。 オプション--debugを指定するとgenerateの詳細を表示することができる。

$ sudo netplan --debug generate 
DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:6941): DEBUG: 11:26:52.031: Processing input file //etc/netplan/01-netcfg.yaml..
** (generate:6941): DEBUG: 11:26:52.031: starting new processing pass
** (generate:6941): DEBUG: 11:26:52.031: enp1s0: setting default backend to 1
** (generate:6941): DEBUG: 11:26:52.031: Generating output files..
** (generate:6941): DEBUG: 11:26:52.031: NetworkManager: definition enp1s0 is not for us (backend 1)

$ sudo netplan apply

networkctl status enp1s0で設定が適用されたか確認する。

$ networkctl status enp1s0
● 2: enp1s0
       Link File: n/a
    Network File: /run/systemd/network/10-netplan-enp1s0.network
            Type: ether
           State: routable (configured)
            Path: *********
          Vendor: *********
           Model: *********
      HW Address: **:**:**:**:**:**
         Address: 192.168.0.10
                  xxxx::xxxx:xxxx:xxxx:xxxx
         Gateway: 192.168.0.1
             DNS: 192.168.0.1

あるいはipコマンドを使ってip addressとすればすべてのネットワークインターフェイスとアドレスの情報を確認することができる。 ip address show dev enp1s0とすれば特定のインターフェイスのみ確認できる。

ip addressの出力例
$ ip address show dev enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 ffff::ffff:ffff:ffff:ffff/64 scope link 
       valid_lft forever preferred_lft forever

IPv6を無効化する

無効化するために以下の内容を追記。

/etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

sysctl -pで変更を反映させる。 また、無効になったかを確認。

$ cat /proc/net/if_inet6 
00000000000000000000000000000001 01 80 10 80      lo
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 02 40 20 80  enp1s0

$ sudo sysctl -p
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

$ cat /proc/net/if_inet6 

sysctl -pを実行すると変更した内容が表示され、またcat /proc/net/if_inet6で何も表示されなければ無効になっている。

ブリッジ接続を設定する

仮想マシンのネットワークで使用するブリッジを設定する。 まずはbridge-utilsをインストールしておく。

bridge-utilsのインストール
sudo apt install bridge-utils

先に作成した /etc/netplan/01-netcfg.yamlを変更してブリッジ設定を記述する。 ここではブリッジ名をbr0とする。

/etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: false
      dhcp6: false
  bridges:
    br0:
      interfaces: [enp1s0]
      addresses: [192.168.0.10/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [192.168.0.1]
      dhcp4: false
      dhcp6: false
      parameters:
        stp: false
        forward-delay: 0

また/etc/systemd/network/br0.networkを作成し以下の設定を記述する。

/etc/systemd/network/br0.network
[Match]
Name=br0

[Network]
LinkLocalAddressing=no

参考として、上記の設定は下記/etc/network/interfacesでの設定と同等のものとなる。

/etc/network/interfaces
auto lo
iface lo inet loopback

auto enp1s0
iface enp1s0 inet manual
up /sbin/ifconfig enp1s0 promisc

auto br0
iface br0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
bridge_ports enp1s0
bridge_stp off
bridge_maxwait 1

sudo netplan generate, sudo netplan applyで変更した設定を適用する。

$ sudo netplan --debug generate
DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:7590): DEBUG: 11:31:32.622: Processing input file //etc/netplan/01-netcfg.yaml..
** (generate:7590): DEBUG: 11:31:32.622: starting new processing pass
** (generate:7590): DEBUG: 11:31:32.623: enp1s0: setting default backend to 1
** (generate:7590): DEBUG: 11:31:32.623: br0: setting default backend to 1
** (generate:7590): DEBUG: 11:31:32.623: Generating output files..
** (generate:7590): DEBUG: 11:31:32.623: NetworkManager: definition enp1s0 is not for us (backend 1)
** (generate:7590): DEBUG: 11:31:32.623: NetworkManager: definition br0 is not for us (backend 1)

$ sudo netplan apply

networkctl status enp1s0 br0で設定が適用されたか確認する。

$ networkctl status enp1s0 br0
● 2: enp1s0
       Link File: n/a
    Network File: /run/systemd/network/10-netplan-enp1s0.network
            Type: ether
           State: carrier (configured)
            Path: *********
          Vendor: *********
           Model: *********
      HW Address: **:**:**:**:**:**

● 3: br0
       Link File: /lib/systemd/network/99-default.link
    Network File: /run/systemd/network/10-netplan-br0.network
            Type: ether
           State: routable (configured)
          Driver: bridge
      HW Address: **:**:**:**:**:**
         Address: 192.168.0.10
                  xxxx::xxxx:xxxx:xxxx:xxxx
         Gateway: 192.168.0.1
             DNS: 192.168.0.1

あるいはipコマンドを使って確認する。

ip addressの出力例
$ ip address show dev enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff

$ ip address show dev br0 
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 ffff::ffff:ffff:ffff:ffff/64 scope link 
       valid_lft forever preferred_lft forever

システムの設定

スワップ頻度を変更する

スワップ頻度をデフォルトの60から10に下げるために、以下の内容を追記。

/etc/sysctl.conf
vm.swappiness = 10

sysctl -pで変更を反映させる。 また、正しく変更されたかを確認。

$ cat /proc/sys/vm/swappiness 
60

$ sudo sysctl -p
vm.swappiness = 10

$ cat /proc/sys/vm/swappiness 
10

sysctl -pを実行すると変更した内容が表示される。 また、現在の設定値はcat /proc/sys/vm/swappinessで確認できる。

フロッピーディスクデバイス(/dev/fd0)を無効化する

/etc/modprobe.d/blacklist-floppy.confを作成し、以下の内容を書き込む。

/etc/modprobe.d/blacklist-floppy.conf
blacklist floppy

モジュールをアンロードし、update-initramfsを実行しておく。

sudo rmmod floppy
sudo update-initramfs -u

不要なら下記のマウント用ディレクトリも削除する。

sudo unlink /media/floppy
sudo rmdir /media/floppy0

lsmodfloppyが表示されなければ無効化されている。 (再起動後も永続的に無効化される)

$ lsmod | grep -i floppy

その他設定ファイル等の編集

/etc/hosts

必要に応じてホストを追記。

/etc/fstab

マウントポイントを作成し、必要に応じてパーティションを追記。

一般ユーザー・グループを追加する

必要に応じて追加する。

ユーザー・グループの追加
# 一般ユーザーのグループ・ユーザーの作成
sudo groupadd -g 1001 user2
sudo adduser --uid 1001 --gid 1001 user2

# 管理者ユーザーにする場合(sudoグループ・admグループに追加)
sudo gpasswd -a user2 sudo
sudo gpasswd -a user2 adm

# ホームディレクトリ・ログインシェルを持たないユーザーを作成する場合
sudo adduser --uid 5000 --gid 5000 --disabled-login --disabled-password --no-create-home user3

ソフトウェアの追加と削除

アップグレードする場合や、他の環境から移行する場合は、事前に必要になるソフトウェア・不要なソフトウェアの一覧を作成しておくとよい。 /var/log/apt/history.logにはaptでの操作の履歴が記録されているので、それを元に要・不要の判断およびリストアップをすることができる。

aptインストール履歴
# aptコマンドでの操作の履歴を表示
grep "Commandline:" /var/log/apt/history.log

# 実際にインストールしたパッケージを表示
# (自動的にインストールされた関連パッケージも含まれる)
grep "Install:" /var/log/apt/history.log

パッケージの削除・インストール

不要なパッケージを削除する

以下のコマンドで一括して削除する。 削除目的等については省略。

不要なパッケージの削除
sudo apt purge \
  aspell aspell-en \
  bluez bluez-cups bluez-obexd \
  cups cups-browsed cups-bsd cups-client cups-common cups-core-drivers cups-daemon cups-server-common \
  enchant \
  '^espeak(-.*)?' \
  gnome-accessibility-themes \
  gnome-online-accounts \
  hplip hplip-data printer-driver-.* \
  modemmanager \
  ntfs-3g libntfs-3g.* libntfs.* \
  nano \
  openprinting-ppds \
  ppp pppconfig pppoeconf \
  sane-utils libsane-hpaio \
  usbmuxd \
  wamerican wbritish

上記コマンドで削除されるパッケージは次のとおり。

以下のパッケージは「削除」されます:
  aspell* aspell-en* bluez* bluez-cups* bluez-obexd* cups* cups-browsed* cups-bsd* cups-client* cups-common* cups-core-drivers*
  cups-daemon* cups-ppdc* cups-server-common* enchant* espeak-ng-data* gnome-accessibility-themes* gnome-bluetooth*
  gnome-online-accounts* hplip* hplip-data* libespeak-ng1* libntfs-3g88* libsane-hpaio* modemmanager* nano* network-manager-pptp*
  network-manager-pptp-gnome* ntfs-3g* openprinting-ppds* ppp* pppconfig* pppoeconf* pptp-linux* printer-driver-brlaser*
  printer-driver-c2esp* printer-driver-foo2zjs* printer-driver-foo2zjs-common* printer-driver-gutenprint* printer-driver-hpcups*
  printer-driver-m2300w* printer-driver-min12xxw* printer-driver-pnm2ppa* printer-driver-postscript-hp* printer-driver-ptouch*
  printer-driver-pxljr* printer-driver-sag-gdi* printer-driver-splix* pulseaudio-module-bluetooth* sane-utils*
  speech-dispatcher-espeak-ng* ubuntu-desktop* usbmuxd* wamerican* wbritish*

各パッケージの概要は次のとおり。

削除するパッケージと概要
パッケージ名 概要
aspell GNU aspell スペルチェッカ
aspell-en GNU Aspell 用英語辞書
bluez Bluetooth 用ツールとデーモン
bluez-cups Bluetooth printer driver for CUPS
bluez-obexd bluez obex daemon
cups Common UNIX Printing System(tm) - PPD/ドライバサポート、web インターフェース
cups-browsed OpenPrinting CUPS Filters - cups-browsed
cups-bsd Common UNIX Printing System(tm) - BSD commands
cups-client Common UNIX Printing System(tm) - クライアントプログラム (SysV)
cups-common Common UNIX Printing System(tm) - common files
cups-core-drivers Common UNIX Printing System(tm) - driverless printing
cups-daemon Common UNIX Printing System(tm) - daemon
cups-server-common Common UNIX Printing System(tm) - server common files
enchant 各種スペルチェッカエンジンへのラッパー (バイナリプログラム)
'^espeak(-.*)?' speech data files
gnome-accessibility-themes High Contrast GTK+ 2 theme and icons
gnome-online-accounts service to manage online accounts for the GNOME desktop
hplip HP Linux Printing and Imaging System (HPLIP)
hplip-data HP Linux Printing and Imaging - データファイル
printer-driver-.* CUPS 用プリンタドライバ
modemmanager モデムを管理する D-Bus サービス
ntfs-3g FUSE 用の読み書き可能な NTFS ドライバ
libntfs-3g.* read/write NTFS driver for FUSE (runtime library)
libntfs.* read/write NTFS driver for FUSE (runtime library)
nano Pico にヒントを得て作られた、コンパクトで使いやすいテキストエディタ
openprinting-ppds OpenPrinting printer support - PostScript PPD files
ppp Point-to-Point Protocol (PPP) デーモン
pppconfig ppp 設定用のテキストメニューベースのユーティリティ
pppoeconf configures PPPoE/ADSL connections
sane-utils スキャナ用 API ライブラリ - ユーティリティ
libsane-hpaio HP の複合機用 SANE バックエンド
usbmuxd iPhone や iPod Touch デバイス向け USB マルチプレクサデーモン
wamerican /usr/share/dict 用米国英語単語リスト
wbritish /usr/share/dict 用英国英語単語リスト
パッケージ名 概要

使用するパッケージをインストールする

以下のコマンドで一括してインストールする。 インストール目的等については省略。

使用するパッケージのインストール
sudo apt install \
  autoconf automake autotools-dev build-essential gettext libtool libboost-dev bison \
  cmake \
  chromium-browser \
  chrony \
  curl \
  fonts-ipafont.* fonts-monapo fonts-mikachan \
  gedit-plugins \
  gimp \
  git gitweb git-svn \
  gnome-shell-extension-dashtodock \
  gnome-shell-extension-hide-activities \
  gnome-shell-extension-log-out-button \
  gnome-shell-extension-remove-dropdown-arrows \
  gnome-shell-extension-system-monitor \
  gnome-software-plugin-flatpak \
  gnome-tweak-tool \
  gparted \
  gsmartcontrol \
  hddtemp \
  icedax \
  logwatch \
  lm-sensors \
  mdadm \
  mono-mcs mono-csharp-shell libmono-simd4.0-cil \
  munin munin-node munin-libvirt-plugins \
  nasm \
  nethogs \
  nfs-kernel-server \
  nginx-extras \
  nkf \
  nodejs \
  partitionmanager \
  postfix \
  php-fpm fcgiwrap \
  samba \
  smartmontools \
  swig \
  subversion \
  synaptic \
  tree \
  virt-manager qemu-kvm \
  vlc \
  xinetd \
  xclip \
  yasm

ここでインストールする各パッケージの概要は次のとおり。

インストールするパッケージと概要
パッケージ名 概要
autoconf configure スクリプト自動作成プログラム
automake GNU 標準準拠の Makefile 生成ツール
autotools-dev config.{guess,sub} ファイルの更新用基盤
build-essential build-essential なパッケージの一覧情報
gettext GNU 国際化ユーティリティ
libtool 汎用ライブラリサポートスクリプト
libboost-dev Boost C++ Libraries development files (default version)
bison YACC 互換なパーサジェネレータ
cmake cross-platform, open-source make system
chromium-browser Chromium web browser, open-source version of Chrome
chrony Versatile implementation of the Network Time Protocol
curl command line tool for transferring data with URL syntax
fonts-ipafont.* Japanese OpenType font set, IPA Gothic and IPA P Gothic Fonts
fonts-monapo 日本語 TrueType フォント - Monapo
fonts-mikachan handwritten Japanese Truetype font
gedit-plugins set of plugins for gedit
gimp GNU Image Manipulation Program
git 速く、スケーラブルな分散型リビジョン管理システム
gitweb fast, scalable, distributed revision control system (web interface)
git-svn fast, scalable, distributed revision control system (svn interoperability)
gnome-shell-extension-dashtodock dash-to-dock extension for GNOME shell
gnome-shell-extension-hide-activities GNOME shell extension that hides the activities button
gnome-shell-extension-log-out-button Adds a log out button to the system action list in GNOME Shell
gnome-shell-extension-remove-dropdown-arrows removes drop down arrows from panel on GNOME shell
gnome-shell-extension-system-monitor Display system information in GNOME Shell status bar
gnome-software-plugin-flatpak Flatpak support for GNOME Software
gnome-tweak-tool adjust advanced settings for GNOME - transitional package
gparted GNOME パーティションエディタ
gsmartcontrol graphical user interface for smartctl
hddtemp hard drive temperature monitoring utility
icedax オーディオ CD から WAV を生成する
logwatch 出力が優れ、Perl で書かれたログアナライザ
lm-sensors 温度・電圧・ファンセンサ読み取り用ユーティリティ
mdadm Linux MD アレイ (ソフトウェア Raid) 管理ツール
mono-mcs Mono C# 2.0 / 3.0 / 4.0 / 5.0 compiler for CLI 2.0 / 4.0 / 4.5
mono-csharp-shell interactive C# shell
libmono-simd4.0-cil Mono SIMD (for CLI 4.0)
munin network-wide graphing framework (grapher/gatherer)
munin-node network-wide graphing framework (node)
munin-libvirt-plugins Munin plugins using libvirt
nasm General-purpose x86 assembler
nethogs Net top tool grouping bandwidth per process
nfs-kernel-server NFS カーネルサーバ用サポート
nginx-extras nginx web/proxy server (extended version)
nkf ネットワーク漢字コード変換フィルタ
nodejs evented I/O for V8 javascript
partitionmanager file, disk and partition management for KDE
postfix 高性能メール配送エージェント
php-fpm server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
fcgiwrap simple server to run CGI applications over FastCGI
samba UNIX 用 SMB/CIFS ファイル、プリンタ、認証サーバ
smartmontools S.M.A.R.T を使ってストレージシステムの制御と監視を実施
swig スクリプト言語向けに C/C++ のコードのインターフェースを生成
subversion Advanced version control system
synaptic グラフィカルなパッケージマネージャ
tree displays an indented directory tree, in color
virt-manager 仮想マシン管理用デスクトップアプリケーション
qemu-kvm QEMU Full virtualization on x86 hardware
vlc マルチメディアプレイヤおよびストリーマ
xinetd replacement for inetd with many enhancements
xclip command line interface to X selections
yasm modular assembler with multiple syntaxes support
パッケージ名 概要

ドライバ類をインストールする

  1. 「ソフトウェアとアップデート」を起動する
  2. [追加のドライバー]タブを開く
  3. 使用するドライバを選択して[変更の適用]を行う

必要とされていないパッケージを削除する

sudo apt autoremove

パッケージ情報を更新してアップデートする

sudo apt update && sudo apt dist-upgrade

GRUBを設定する

/etc/default/grubを編集する。 変更内容は次のとおり。

GRUB_HIDDEN_TIMEOUTをコメントアウト
メニュー画面を表示する
GRUB_TIMEOUT5に変更
GRUB起動メニューでのタイムアウト時間を5秒にする
GRUB_CMDLINE_LINUX_DEFAULT"quiet splash"から"noquiet nosplash intel_iommu=on"に変更
noquiet nosplash
ブート中に表示される内容をスプラッシュ画面からテキスト表示にする
intel_iommu=on
KVMでPCIパススルーを行うために、IOMMUを有効にする (Intel CPU/VT-dの場合。 AMD CPU/AMD-Viの場合はamd_iommu=on。)
関連:§.PCIパススルーでUSBデバイスを使用できるようにする
GRUB_GFXMODE=1024x768を追記(またはコメントアウトされているものを変更)
フレームバッファの解像度を1024x768に設定
/etc/default/grub
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="noquiet nosplash intel_iommu=on"
GRUB_CMDLINE_LINUX=""

  :
  :

GRUB_GFXMODE=1024x768

編集が終わったら、update-grub2で設定を反映させる。

sudo update-grub2
update-grub2の実行例
$ sudo update-grub2 
Generating grub configuration file ...
Linux イメージを見つけました: /boot/vmlinuz-4.15.0-20-generic
Found initrd image: /boot/initrd.img-4.15.0-20-generic
Adding boot menu entry for EFI firmware configuration
完了

root宛て・一般ユーザ宛てメールの送信先を変更する

/etc/aliasesに送信先を追記する。

/etc/aliases
# Added by installer for initial user
root: root@mail.example.com
user: user@mail.example.com

追記した内容を反映させる。

sudo newaliases

再起動

ここまででいったん再起動。 再起動後にps, pstree, topで必要なさそうなプロセスが動いてないかチェックする。

デスクトップ環境の設定とカスタマイズ

~/.cacheディレクトリ

~/.cacheディレクトリを/homeとは異なるパーティションに置く。

rm -rf ~/.cache
ln -s /opt/cache/users/user/.cache/ ~/.cache

設定

設定(gnome-control-center)を起動して設定を編集する。

[通知]タブ
不必要なものをオフにする
[地域と言語]タブ
[入力ソース]
日本語(Mozc)の優先度を上げる
[ユニバーサルアクセス]タブ
[タイピング]
[リピートキー]
オンにして、繰り返しキー入力の時間と速度を適度な値に変更する
[カーソルの点滅]
オンにして、点滅の速度を適度な値に変更する
[プライバシー]タブ
不必要なものをオフにする
[電源]タブ
[省電力]
[ブランクスクリーン]
「しない」に設定

ブランクスクリーンの設定を任意の時間にしたい場合は、gsettingsコマンドを用いてorg.gnome.desktop.sessionのキーidle-delayに秒数単位で値を設定する。 0に設定すれば「しない」と同じ設定となる。

スクリーンをブランクにするまでの時間を設定する
# 3600秒(=1時間)に設定する
gsettings set org.gnome.desktop.session idle-delay 3600

# 現在設定されている値を表示する
gsettings get org.gnome.desktop.session idle-delay

[デバイス]の設定

[キーボード]タブ
必要に応じてショートカット設定を変更
[マウス]タブ
マウスの速度を適当な値に変更する

[詳細]の設定

[日付と時刻]タブ
[自動日時設定]
オンにする
[日時書式]
24時間制にする

Tweaks (デスクトップ環境・ウィンドウマネージャの設定等)

Tweaks(gnome-tweak-tool)を起動して設定を編集する。

[ウィンドウ]タブ
[ウィンドウ操作キー]
Altに変更
[タイトルバーボタン]
「位置」を左に変更
[キーボードとマウス]タブ
[入力ソースを追加表示する]
オンに変更
[追加のレイアウトオプション]
[Xサーバーを終了するためのキーシーケンス]
Ctrl+Alt+Backspaceにチェックを入れる
[デスクトップ]タブ
[デスクトップアイコン]
[マウントボリューム]
オフに変更
[トップバー]タブ
[アプリケーションメニュー]
オフに変更
[時計]
[日付]
オンに変更
[秒]
オンに変更
[フォント]タブ
[等幅]
Noto Sans Mono CJK JP Regular 11にする
[外観]タブ
[アニメーション]
オフに変更
[拡張機能]タブ
インストールしたものをオンにする

Dash to dockの詳細設定

[位置とサイズ]タブ
[インテリジェント表示]
オンにする
詳細設定
[オンデマンド表示]
オンにする
[押し込んで表示]
チェックを入れる
[ウィンドウ重なり防止]
オンにする
[パネルモード]
チェックを外す
[アイコンサイズの上限]
32px程度にする
[アイコンサイズの固定]
チェックを入れる
[ランチャー]タブ
[[アプリケーションを表示する]アイコンの表示]
オンにする
[ドックの先頭に表示]
チェックを入れる
[アニメーションしながらアプリケーション一覧を表示]
チェックを外す
[外観]タブ
[Dashの縮小表示]
オンにする
[Dashの背景色の設定]
オンにする、色を任意に設定

Mozcの設定

Mozcの設定(mozc)を起動して設定を編集する。

[一般]タブ
[キー設定の選択]
[ATOK]に変更
[辞書]タブ
[ユーザー辞書の編集]
[Mozc辞書ツール]を起動でユーザー辞書をインポートする
[サジェスト]タブ
[サジェストの最大候補数]
9にする

Firefox

user.jsを作成して以下の内容を記述しておく。

~/.mozilla/firefox/(ユーザープロファイルディレクトリ)/user.js
user_pref("intl.accept_languages", "ja,en"); // 言語の優先順位(Accept-Language)を設定する

user_pref("network.dns.disableIPv6", true); // IPv6を無効にする

user_pref("general.autoScroll", false); // 自動スクロール機能を使用しない
user_pref("general.smoothScroll", false); // スムーススクロールを無効にする

user_pref("accessibility.browsewithcaret", true); // キャレットブラウズモードを有効にする

user_pref("layout.spellcheckDefault", 0); // 自動スペルチェック機能を使用しない

user_pref("browser.search.openintab", true); // 検索結果を新しいタブで開く
user_pref("browser.search.widget.inNavBar", true); // 検索バーをツールバーに表示する
user_pref("browser.tabs.loadInBackground", false); // リンクを新しいタブで開いたとき、すぐにそのタブに切り替える
user_pref("browser.tabs.loadBookmarksInTabs", true); // ブックマークを新しいタブで開く
user_pref("browser.tabs.closeWindowWithLastTab", false); // 最後のタブを閉じたあともウィンドウを開いたままにする
user_pref("browser.tabs.warnOnClose", false); // 複数のタブを閉じるときにダイアログを表示しない

その他、メニューの[設定]から以下の設定を行う。

[検索]タブ
[ワンクリック検索エンジン]
不要な検索エンジンを選択解除あるいは削除
[プライバシーとセキュリティ]タブ
[ウェブサイトのログイン情報とパスワードを保存する]
チェックを外す

プロファイルごとのショートカットを作る

デフォルト以外のプロファイルがまだ存在しない場合は、一旦Firefoxを終了したのちにfirefox -pでプロファイル選択ウィンドウを開き、新しいプロファイルを作成する。

firefox -p

~/.local/share/applicationsにデスクトップエントリファイルを作成して以下のような内容を記述する。 あるいは/usr/share/applications/firefox.desktopをコピーして編集する。 拡張子を除くファイル名部分は任意に設定できる。 以下の例では、プロファイル名user2でFirefoxを起動するようにしている。

~/.local/share/applications/firefox-profile-user2.desktop
[Desktop Entry]
Version=1.0
Name=Firefox (user2)
Exec=firefox -P "user2" %u
Type=Application
Terminal=false
Icon=firefox

# 「新しいウィンドウを開く」などのアクションを定義する場合は、Actionsキーにアクション名を記述して、
# 対応する名前のセクションにて動作を定義する
# アクションを複数定義する場合は、";"で区切ってアクション名を記述する
Actions=new-window;

[Desktop Action new-window]
Name=新しいウィンドウを開く
Exec=firefox -P "user2" --new-window

デスクトップエントリファイルを作成するとアプリケーション一覧にアイコンが表示されるようになる。

Thunderbird

user.jsを作成して以下の内容を記述しておく。

~/.thunderbird/(ユーザープロファイルディレクトリ)/user.js
user_pref("general.smoothScroll", false); // スムーススクロールを無効にする
user_pref("mail.mdn.report.enabled", false); // 開封確認を送信しない
user_pref("mail.server.default.mdn_report_enabled", false); // (新規に作成されるアカウントに対して)開封確認を送信しない
user_pref("mail.server.default.offline_download", false); // (新規に作成されるアカウントに対して)メッセージの同期を無効にする
user_pref("mail.server.default.check_all_folders_for_new", true); // すべてのIMAPフォルダの新着メールをチェックする

アプリケーション一覧にThunderbirdが表示されない場合は、再インストールする。 (2018-05-03時点、環境依存の不具合?)

sudo apt --reinstall install thunderbird

Nautilus

メニューの[設定]から以下の設定を行う。

[表示]タブ
[一覧表示]
[フォルダーを展開可能にする]
チェックを入れる
[動作]タブ
[実行可能なテキストファイル]
「どうするか確認する」を選択する
[一覧の項目]タブ
[更新日]
チェックを外す
[更新日時]
チェックを入れる
[検索とプレビュー]タブ
[全文検索]
[デフォルトに設定する]
チェックを外す
[サムネイル]
[サムネイルの表示]
「このコンピューターのファイルのみ」を選択する

ロケーションバーを常に表示するようにする

Nautilusロケーションバーを常に表示する
gsettings set org.gnome.nautilus.preferences always-use-location-entry true

/home/のディレクトリ表記を英語にする・不要なディレクトリを削除する

次項§.不要なディレクトリをサイドバーに表示しないようにするを参照のこと。

不要なディレクトリをサイドバーに表示しないようにする

~/.config/user-dirs.dirsを編集し、表示したくないディレクトリをコメントアウトする。 またディレクトリ名を日本語表記から英語表記に変えたい場合も、このファイルを変更する。

~/.config/user-dirs.dirs
# 以下のディレクトリはサイドバーに表示する、かつ英語表記のディレクトリ名を使用する
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"

# 以下のディレクトリはNautilusのサイドバーに表示させない
#XDG_TEMPLATES_DIR="$HOME/Templates"
#XDG_PUBLICSHARE_DIR="$HOME/Public"
#XDG_DOCUMENTS_DIR="$HOME/Documents"
#XDG_MUSIC_DIR="$HOME/Music"
#XDG_PICTURES_DIR="$HOME/Pictures"
#XDG_VIDEOS_DIR="$HOME/Videos"

再度ログインした際にも有効にするため、~/.config/user-dirs.confを作成して以下の内容を書き込む。

~/.config/user-dirs.conf
enabled=False

~/.config/user-dirs.localeに記載されているロケールがja_JPになっているので、C等に変更しておく。

~/.config/user-dirs.locale
C

その後、ディレクトリ名を変更する。 また不要になったディレクトリを削除する。

cd ~
mv デスクトップ/ Desktop/
mv ダウンロード/ Downloads/
rmdir テンプレート/ 公開/ ドキュメント/ ミュージック/ ピクチャ/ ビデオ/

ログアウトするなどしてセッションを再起動する。 最後にNautilushのサイドバーの不要なディレクトリを右クリックして一覧から削除する。


以前のUbuntuでディレクトリ名の表記を変更する場合、以下の手順で変更することができた。 参考として記載しておく。

cd ~
LANG=C xdg-user-dirs-gtk-update

表示されるダイアログにしたがって変更すればOK。 ディレクトリを削除する前に、以下の内容を記述した~/.config/user-dirs.confを作成し、ディレクトリを削除しても二度と作成させないようにする。

~/.config/user-dirs.conf
enabled=False

その後、不要なディレクトリを削除する。

rmdir Documents/ Public/ Templates/

その他のシステム設定・環境設定

メニュー項目からの再起動・シャットダウン・サスペンド等を無効にする

/etc/polkit-1/localauthority/90-mandatory.d/disable-power.pklaを編集して、以下の内容を追記する。

/etc/polkit-1/localauthority/90-mandatory.d/disable-power.pkla
[Disable power management]
Identity=unix-user:*
Action=org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions;org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions;org.freedesktop.login1.suspend;org.freedesktop.login1.suspend-multiple-sessions;org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultAny=no
ResultInactive=no
ResultActive=no

上記の内容でファイルを作成するとメニュー項目等に再起動・電源オフが表示されなくなる。 変更が反映されない場合は一旦ログアウトする、あるいはGDMを再起動する。

GDMの再起動
sudo systemctl restart gdm.service

以降、再起動・電源オフはコマンドの入力によって行う。

再起動・電源オフ
sudo reboot # 再起動
sudo shutdown -h # 電源オフ

iPhone/iPodのマウント

USBでの接続で「iPhone(またはiPod)をマウントできません」というエラーが出る場合は、/var/lib/lockdownのディレクトリの存在とパーミッションを確認する。

sudo mkdir /var/lib/lockdown
sudo chmod 777 /var/lib/lockdown

開発環境の設定

Logwatch

動作テストした結果をroot宛にメールで送信する。

sudo logwatch --detail high --mailto root

Munin

設定ファイルを編集する。

/etc/munin/munin.conf
# 収集したデータ、HTMLの出力先などを設定
dbdir	/var/lib/munin
htmldir	/srv/www/munin
logdir	/var/log/munin
rundir  /var/run/munin

# a simple host tree
[localhost.example.com]
    address 127.0.0.1
    use_node_name yes

# 以下、監視するノードをここに追記
[server1.example.com]
    address server1
    use_node_name yes

localhostからのアクセスのみを許可するように変更する。

/etc/munin/munin-node.conf
allow ^127\.0\.0\.1$

/etc/munin/pluginsに必要なプラグインを追加・不要なプラグインを削除する。

cd /etc/munin/plugins/
sudo ln -s /usr/share/munin/plugins/xxx #必要なプラグインの追加
sudo unlink xxx # 不要なプラグインの削除

munin-nodeを再起動する。

sudo service munin-node restart

別途HTTPサーバーの設定を変更して/etc/munin/munin.confhtmldirで設定したHTMLの出力先を表示できるようにする。

xinetd

/etc/hosts.allow, /etc/hosts.denyを編集。 この例では、svnserve, git-daemon, nfsdの3つのサービスを有効にする。

/etc/hosts.allow
svnserve : 127.0.0.1 192.168.0.0/24
git-daemon : 127.0.0.1 192.168.0.0/24
portmap rpcbind mountd nfsd statd lockd rquotad : 192.168.0.0/24
/etc/hosts.deny
ALL: PARANOID

/etc/xinetd.d/以下の設定ファイルを編集した後、再起動。

sudo service xinetd restart

git-daemon

/etc/xinetd.d/gitを作成。

/etc/xinetd.d/git
service git
{
        disable         = no
        type            = UNLISTED
        port            = 9418
        socket_type     = stream
        wait            = no
        user            = git
        server          = /usr/lib/git-core/git-daemon
        server_args     = --inetd --export-all --enable=receive-pack --base-path=/srv/repos/git/
        only_from       = 192.168.0.0/24 127.0.0.1
        log_on_failure  += USERID
}

git-daemon用にユーザーとグループを追加。 (ここではそれぞれIDに602番を用いる)

sudo groupadd -g 602 git
sudo adduser --uid 602 --gid 602 --disabled-login --disabled-password --no-create-home git

リポジトリを格納するディレクトリがまだない場合は作成する。

sudo -u git mkdir -p /srv/repos/git

svnserve

/etc/xinetd.d/svnを作成。

/etc/xinetd.d/svn
service svn
{
        disable         = no
        socket_type     = stream
        user            = svn
        wait            = no
        server          = /usr/bin/svnserve
        server_args     = -i -r /srv/repos/svn
        only_from       = 192.168.0.0/24 127.0.0.1
        log_on_failure  += USERID
}

svnserve用にユーザーとグループを追加。 (ここではそれぞれIDに601番を用いる)

sudo groupadd -g 601 svn
sudo adduser --uid 601 --gid 601 --disabled-login --disabled-password --no-create-home svn

リポジトリを格納するディレクトリがまだない場合は作成する。

sudo -u svn mkdir -p /srv/repos/svn

Gitクライアント

git configで各種初期設定を行う。 または~/.gitconfigを編集する。

git config
git config --global user.name "username"
git config --global user.email "email"
git config --global core.editor 'vi -c "set fenc=utf-8"'
git config --global core.autocrlf input
git config --global core.safecrlf true
git config --global core.ignorecase false
git config --global core.quotepath false
git config --global push.default simple
git config --global color.ui true
git config --global color.diff.meta "bold yellow"
git config --global color.diff.frag "bold cyan"
git config --global color.diff.old "bold red"
git config --global color.diff.new "bold green"

git-prompt.sh

git-prompt.shをダウンロードする。

git-prompt.shのダウンロード
curl -L https://github.com/git/git/raw/master/contrib/completion/git-prompt.sh --output ~/.git-prompt.sh

Subversionクライアント

適当なsvnコマンドを実行することで~/.subversion/configのテンプレートを作成する。

svn help

作成された~/.subversion/configを編集。

~/.subversion/config
[auth]
# 認証情報を保存しない (毎回ユーザ名とパスワードを入力する)
store-passwords = no
store-auth-creds = no
password-stores =

[helpers]
# diffの代わりにgit diffを使うラッパーを呼び出す
diff-cmd = /home/smdn/.subversion/git-diff.sh

[tunnels]
# ssh = $SVN_SSH ssh
# rsh = rsh
# rsh = /path/to/rsh -l myusername

[miscellany]
# log-encoding = latin1
use-commit-times = yes
# no-unlock = yes
enable-auto-props = yes
global-ignores = *.o *.lo *.obj *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.suo *.pidb *.mdb *.userprefs *.usertasks

[auto-props]
# 記述例
*.cs         = svn:eol-style=native; svn:mime-type=text/plain
*.csproj     = svn:eol-style=CRLF; svn:mime-type=text/xml

差分出力にgit diffを使う

git diffを呼び出すラッパーを~/.subversion/git-diff.shなどのファイル名で作成する。 作成したらchmod u+xする。

~/.subversion/git-diff.sh
#!/bin/sh
/usr/bin/git --no-pager diff --no-index --color "$6" "$7"

次に、~/.subversion/configを編集し、diff-cmdで作成したラッパーを呼び出すように変更する。

~/.subversion/config
[helpers]
diff-cmd = /home/smdn/.subversion/git-diff.sh

NFS

/etc/exportsを編集。

/etc/exports
# エクスポート設定を追記する
/srv/export/share     server1(rw,sync,root_squash,anonuid=500,anongid=500)

NFSサーバを再起動。

sudo service nfs-kernel-server restart

libvirt

Intel VTが有効になっているか、KVMが利用できるか確認する。

$ egrep -c '(vmx|svm)' /proc/cpuinfo
2

$ kvm-ok 
INFO: /dev/kvm exists
KVM acceleration can be used

PCIパススルーでUSBデバイスを使用できるようにする

GRUBの設定を変更してIOMMUを有効にしておく(詳細:§.GRUBを設定する)。 IOMMUが有効な場合はdmesgで以下のようなメッセージが表示されるようになる。

$ dmesg | grep IOMMU
[    0.000000] DMAR: IOMMU enabled

AppArmorによりアクセス制御がされている場合、USBデバイスへのアクセスが拒絶され、仮想マシンを起動する際に以下のようなメッセージが表示される場合がある。

$ dmesg | grep libvirt

[  585.002227] audit: type=1400 audit(1486069534.271:84): apparmor="DENIED" operation="open" profile="libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name="/run/udev/data/c189:1" pid=5275 comm="qemu-system-x86" requested_mask="r" denied_mask="r" fsuid=121 ouid=0
[  585.002277] audit: type=1400 audit(1486069534.271:85): apparmor="DENIED" operation="open" profile="libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name="/run/udev/data/c189:2" pid=5275 comm="qemu-system-x86" requested_mask="r" denied_mask="r" fsuid=121 ouid=0
[  585.002322] audit: type=1400 audit(1486069534.271:86): apparmor="DENIED" operation="open" profile="libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name="/run/udev/data/c189:3" pid=5275 comm="qemu-system-x86" requested_mask="r" denied_mask="r" fsuid=121 ouid=0
  :
  :

この場合は、以下の2つのAppArmorプロファイルを編集してアクセスを許可する。 まずlibvirt共通のプロファイル/etc/apparmor.d/abstractions/libvirt-qemuを編集して以下の箇所を変更する。 (/dev/bus/usb/rwにする)

/etc/apparmor.d/abstractions/libvirt-qemu
  # for usb access
  /dev/bus/usb/ rw,
  /etc/udev/udev.conf r,
  /sys/bus/ r,
  /sys/class/ r,

次に、USBデバイスを使用する仮想マシンのプロファイル/etc/apparmor.d/libvirt/libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxを編集して以下の二行を追記する。

/etc/apparmor.d/libvirt/libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
profile libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx {
  #include <abstractions/libvirt-qemu>
  #include <libvirt/libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.files>

  /dev/bus/usb/*/[0-9]* rw,
  /run/udev/** rw,
}

仮想マシンに対応するプロファイルのUUIDは、virsh dominfo <name>で確認することができるほか、上記のdmesgでもprofile="libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"と出力されている部分で確認できる。

以下のコマンドで編集したプロファイルを更新・反映させる。

sudo apparmor_parser -r /etc/apparmor.d/libvirt/libvirt-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

その後、再度仮想マシンを起動するとUSBデバイスへのアクセスが許可されるようになる。

nginx

Ubuntu 18.04でインストールされるnginx(nginx/1.14.0)では、Apacheのような動的モジュール(Dynamic Modules)機能をサポートしている。

Ubuntu 16.04等からそのまま設定ファイルを引き継ぐ場合は、下記のように/etc/nginx/modules-enabled/配下にあるモジュールの設定ファイルを読み込むよう設定を追記し、使用するモジュールを有効にするよう修正する必要がある。

/etc/nginx/nginx.conf
include /etc/nginx/modules-enabled/*.conf;

.NET Core / Visual Studio Code

Microsoft製品のLinux Software Repositoryを追加する

事前準備としてMicrosoftの公開鍵をインストールする。

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

リポジトリを追加する。

sudo apt-add-repository https://packages.microsoft.com/ubuntu/18.04/prod
sudo apt update

.NET Core

あらかじめMicrosoftのリポジトリを追加しておく。

.NET Core SDKをインストールする。

sudo apt install dotnet-sdk-2.1.105

#ランタイムのみインストールする場合
sudo apt install dotnet-runtime-2.0.7
動作確認
$ dotnet --info
.NET コマンド ライン ツール (2.1.105)

Product Information:
 Version:            2.1.105
 Commit SHA-1 hash:  141cc8d976

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.105/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

Visual Studio Code

あらかじめMicrosoftのリポジトリを追加しておく。

Visual Studio Codeをインストールする。

sudo apt install code

MonoDevelop

Flatpakを使ってMonoDevelopをインストールする。 (事前にgnome-software-plugin-flatpakをインストールしておく)

flatpak install --user --from https://download.mono-project.com/repo/monodevelop.flatpakref

起動する際は、アプリケーション一覧からMonoDevelopを選択するか、下記のコマンドで起動する。

flatpak run com.xamarin.MonoDevelop

Flatpakではアプリケーションをサンドボックス化した状態で動作するため、サンドボックス化されていないファイルシステム(/home以外など)を参照する場合は--filesystemオプションを指定して起動する必要がある。

flatpak --filesystem=/srv/work/ run com.xamarin.MonoDevelop

アップデートする場合はflatpak updateコマンドを使用する。

flatpak --user update com.xamarin.MonoDevelop

その他

udevルールファイルの作成

ソフトウェアのビルド・インストール