Alpine Linuxのmotdを変更

表題の通り。

■ 環境

  • Alpine Linux 3.3.3
  • VirtualBox
  • Mac OSX El Capitan

■ motd

ログイン時に下記のメッセージが表示されるが、不要なので削除したい。

$ ssh -l root -p 22222 localhost
root@localhost's password:
Welcome to Alpine!

The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org>.

You can setup the system with the command: setup-alpine

You may change this message by editing /etc/motd.

localhost:~#

メッセージに表示の通り、`/etc/motd`を編集する。今回は下記のようにした。

localhost:~# cat /etc/motd
Welcome to Alpine!
localhost:~#

ログインしてみる。

$ ssh -l root -p 22222 localhost
root@localhost's password:
Welcome to Alpine!
localhost:~#

満足。

ちなみに他のOSだと、`update-motd`で`/etc/motd`ファイルが更新されたりするが、Alpine Linuxではそういうことは無いようである。

更にAlpine LinuxのDockerコンテナを確認すると、`/etc/motd`は下記のようになっている。

/ # cat /etc/motd
Welcome to Alpine!

The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org>.

You can setup the system with the command: setup-alpine

You may change this message by editing /etc/motd.

/ #

しかしDockerの場合はSSHでログインしているわけではないので、この`/etc/motd`は使用されない。

以上。

■ 関連

パッケージ一覧の情報量

Alpine Linuxにおいて表題の件について。

■ 環境

  • Alpine Linux 3.3.3

■ apk info

先日のエントリでインストール済みのパッケージ一覧については取得できることを確認した。

Alpine Linuxのインストール済みパッケージ

これに更にversion情報等、情報を加えることができるようである。

■ -v

`apk`コマンドのGlobal Optionに下記のようにオプションがある。

/ # apk info --help
apk-tools 2.6.5, compiled for x86_64.
  :
Global options:
  :
  -v, --verbose           Print more information (can be doubled)
  :
/ #

実際にDocker環境のAlpineで試してみると下記のような結果となった。

/ # apk -v info
musl-1.1.12-r5
busybox-1.24.1-r7
alpine-baselayout-2.3.2-r10
alpine-keys-1.1-r0
zlib-1.2.8-r2
libcrypto1.0-1.0.2h-r0
libssl1.0-1.0.2h-r0
apk-tools-2.6.5-r1
scanelf-0.9.1-r0
musl-utils-1.1.12-r5
libc-utils-0.7-r0
/ #
/ # apk info
musl
busybox
alpine-baselayout
alpine-keys
zlib
libcrypto1.0
libssl1.0
apk-tools
scanelf
musl-utils
libc-utils
/ #

version情報が追加されているようである。

■ -vv

can be doubled“と記載されているのでこちらも試してみる。

/ # apk -vv info
musl-1.1.12-r5 - the musl c library (libc) implementation
busybox-1.24.1-r7 - Size optimized toolbox of many common UNIX utilities
alpine-baselayout-2.3.2-r10 - Alpine base dir structure and init scripts
alpine-keys-1.1-r0 - Public keys for Alpine Linux packages
zlib-1.2.8-r2 - A compression/decompression Library
libcrypto1.0-1.0.2h-r0 - Crypto library from openssl
libssl1.0-1.0.2h-r0 - SSL shared libraries
apk-tools-2.6.5-r1 - Alpine Package Keeper - package manager for alpine
scanelf-0.9.1-r0 - Scan ELF binaries for stuff
musl-utils-1.1.12-r5 - the musl c library (libc) implementation
libc-utils-0.7-r0 - Meta package to pull in correct libc
/ #

更にDescriptionと思わしき文言も追加された。

以上。

■ 関連

どのパッケージでインストールされたかを確認

Alpine Linuxにおいて表題の件を調べる。

■ 環境

  • Alpine Linux 3.3.3
  • VirtualBox
  • Mac OSX El Capitan

■ やりたいこと

あるファイルが、どのパッケージでインストールされたのかを知りたい。`rpm`コマンドでは下記で確認が可能である。

$ rpm -qf [ファイルの絶対パス]

実際にCentOS7でやってみると下記のようになる。

$ rpm -qf /bin/ls
coreutils-8.22-15.el7_2.1.x86_64
$

先日の下記エントリの逆パターンである。

パッケージでインストールされるモジュール

■ apk

下記のように`apk info`で取得できそうである。

localhost:~# apk info --help
apk-tools 2.6.5, compiled for x86_64.
  :
Info options:
  :
  -W, --who-owns          Print the package owning the specified file
  :
localhost:~#

早速”/bin/busybox“で試してみる。

localhost:~# apk info -W /bin/busybox
/bin/busybox is owned by busybox-1.24.1-r7
localhost:~#
localhost:~# apk info --who-owns /bin/busybox
/bin/busybox is owned by busybox-1.24.1-r7
localhost:~#

busybox-1.24.1-r7“というパッケージでインストールされたということであろう。

以上。

■ 関連

パッケージでインストールされるモジュール

Alpine Linuxにおいて表題の件を知りたい。

■ 環境

  • Alpine Linux 3.3.3
  • VirtualBox
  • Mac OSX El Capitan

■ やりたいこと

`rpm`コマンドで言うところの下記を`apk`コマンドではどう実現するのかを知りたい。

$ rpm -ql [package]

■ apk info

`apk info`でパッケージを指定すればいけるのだろうか。

localhost:~# apk info busybox
busybox-1.24.1-r7 description:
Size optimized toolbox of many common UNIX utilities

busybox-1.24.1-r7 webpage:
http://busybox.net

busybox-1.24.1-r7 installed size:
913408

localhost:~#

上記は”busybox“のパッケージについての`info`を見てみたが、これはパッケージに関する情報のようである。ヘルプを確認する。

localhost:~# apk info --help
apk-tools 2.6.5, compiled for x86_64.
  :
Info options:
  -L, --contents          List contents of the PACKAGE
  -e, --installed         Check if PACKAGE is installed
  -W, --who-owns          Print the package owning the specified file
  -R, --depends           List packages that the PACKAGE depends on
  -P, --provides          List virtual packages provided by PACKAGE
  -r, --rdepends          List all packages depending on PACKAGE
  --replaces              List packages whom files PACKAGE might replace
  -i, --install-if        List the PACKAGE's install_if rule
  -I, --rinstall-if       List all packages having install_if referencing PACKAGE
  -w, --webpage           Show URL for more information about PACKAGE
  -s, --size              Show installed size of PACKAGE
  -d, --description       Print description for PACKAGE
  -t, --triggers          Print active triggers of PACKAGE
  -a, --all               Print all information about PACKAGE

This apk has coffee making abilities.
localhost:~#

-L, –contents“が欲しい情報のような感じであるので試してみる。

localhost:~# apk info -L busybox
busybox-1.24.1-r7 contains:
bin/busybox
bin/sh
etc/securetty
etc/udhcpd.conf
etc/logrotate.d/acpid

localhost:~#

どうやらこれで良いようだ。

以上。

■ 関連

Alpine Linuxのインストール済みパッケージ

どのパッケージでインストールされたかを確認

インストールされるモジュール一覧

Alpine Linuxのインストール済みパッケージ

表題の件を知りたい。VirtualBoxで稼働させているものと、Dockerのコンテナで稼働させているものとで、どういうったパッケージの違いがあるのかを知る為に、インストール済みのパッケージ一覧を取得する方法を把握したい。

■ 環境

  • Alpine Linux 3.3.3
  • VirtualBox
  • Mac OSX El Capitan

■ apk

Alpine Linuxではパッケージ管理をするコマンドは`apk`なので、このヘルプを確認。

localhost:~# apk -h
apk-tools 2.6.5, compiled for x86_64.
   :
The following commands are available:
  add       Add PACKAGEs to 'world' and install (or upgrade) them, while ensuring that all dependencies are met
  del       Remove PACKAGEs from 'world' and uninstall them
  fix       Repair package or upgrade it without modifying main dependencies
  update    Update repository indexes from all remote repositories
  info      Give detailed information about PACKAGEs or repositores
  search    Search package by PATTERNs or by indexed dependencies
  upgrade   Upgrade currently installed packages to match repositories
  cache     Download missing PACKAGEs to cache and/or delete unneeded files from cache
  version   Compare package versions (in installed database vs. available) or do tests on literal version strings
  index     Create repository index file from FILEs
  fetch     Download PACKAGEs from global repositories to a local directory
  audit     Audit the directories for changes
  verify    Verify package integrity and signature
  dot       Generate graphviz graphs
  policy    Show repository policy for packages
  stats     Show statistics about repositories and installations
   :
localhost:~#

`info`と`stats`あたりを確認すれば良さそうな感じである。早速試す。

localhost:~# apk info
musl
acct
busybox
alpine-baselayout
openrc
alpine-conf
zlib
libcrypto1.0
libssl1.0
apk-tools
busybox-suid
busybox-initscripts
scanelf
musl-utils
libc-utils
alpine-keys
alpine-base
libattr
libcap
chrony
libuuid
libblkid
libcom_err
e2fsprogs-libs
e2fsprogs
lddtree
device-mapper
cryptsetup-libs
xz-libs
kmod
mkinitfs
linux-firmware
linux-grsec
openssh-client
openssh-sftp-server
openssh
mtools
blkid
syslinux
localhost:~#

39個のパッケージと思われる名称の一覧が取得できた。たぶんこれがパッケージ一覧で間違いはないであろう。`stats`も確認してみる。

localhost:~# apk stats
installed:
  packages: 39
  dirs: 882
  files: 4751
  bytes: 280416256
  triggers: 4
available:
  names: 8604
  packages: 5315
atoms:
  num: 4518
localhost:~#

installed“の”packages“が39なので前述のものと一致する。

ちなみにDockerで稼働しているAlpine Linuxのコンテナでも確認してみると下記の通り。

/ # apk stats
installed:
  packages: 11
  dirs: 70
  files: 62
  bytes: 5410816
  triggers: 1
available:
  names: 19
  packages: 11
atoms:
  num: 37
/ #
/ # apk info
musl
busybox
alpine-baselayout
alpine-keys
zlib
libcrypto1.0
libssl1.0
apk-tools
scanelf
musl-utils
libc-utils
/ #

Dockerのコンテナでは随分とパッケージ数が少ない。

以上。

■ 関連