This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

debianパッケージ周りでよく使うコマンドとオプション

Last updated at Posted at 2017-05-26

後進のためのメモシリーズ

debian パッケージのインストール

$ sudo apt-get install --no-install-recommends <パッケージ名>

デフォルトだと recommends しているだけの必須ではないパッケージも一緒に入って時間がかかるので --no-install-recommends をつけるのが常套手段

debian パッケージがインストール済みかを調べる

dpkg -l (--list) パッケージ名、または dpkg -l | grep パッケージ名

$ dpkg -l linux-headers-$(uname -r)
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                         Version                     Architecture                Description
+++-============================================-===========================-===========================-==============================================================================================
ii  linux-headers-3.13.0-112-generic             3.13.0-112.159              amd64                       Linux kernel headers for version 3.13.0 on 64 bit x86 SMP

変にカスると終了コードが 1 (エラー) ではなく 0 (正常) になることがあるので注意

$ dpkg -l linux-headers
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                         Version                     Architecture                Description
+++-============================================-===========================-===========================-==============================================================================================
un  linux-headers                                <none>                      <none>                      (no description available)
$ echo $?
0
$ dpkg -l unknown
dpkg-query: no packages found matching unknown
$ echo $?
1

終了コードでインストール済みかチェックする場合は dpkg -p (--print-avail) のほうが確実

$ dpkg -p linux-headers-$(uname -r)
Package: linux-headers-3.13.0-112-generic
Priority: optional
Section: devel
Installed-Size: 13185
Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com>
Architecture: amd64
Source: linux
Version: 3.13.0-112.159
Provides: linux-headers, linux-headers-3.0
Depends: linux-headers-3.13.0-112, libc6 (>= 2.14)
Size: 694058
Description: Linux kernel headers for version 3.13.0 on 64 bit x86 SMP
 This package provides kernel header files for version 3.13.0 on
 64 bit x86 SMP.
 .
 This is for sites that want the latest kernel headers.  Please read
 /usr/share/doc/linux-headers-3.13.0-112/debian.README.gz for details.
 $ echo $?
 0
$ dpkg -p linux-headers
dpkg-query: package 'linux-headers' is not available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
$ echo $?
1

インストールした packge に含まれていたファイルを一覧する

dpkg -L (--list-files)

$ dpkg -L wget
/.
/etc
/etc/wgetrc
/usr
/usr/bin
/usr/bin/wget
/usr/share
/usr/share/info
/usr/share/info/wget.info.gz
/usr/share/doc
/usr/share/doc/wget
/usr/share/doc/wget/MAILING-LIST
/usr/share/doc/wget/NEWS.gz
/usr/share/doc/wget/AUTHORS
/usr/share/doc/wget/copyright
/usr/share/doc/wget/changelog.Debian.gz
/usr/share/doc/wget/README
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/wget.1.gz

(あるファイルを含む)パッケージを探す

dpkg -S (--search)

$ dpkg -S libelf
libelf1:amd64: /usr/share/doc/libelf1
libelf1:amd64: /usr/lib/x86_64-linux-gnu/libelf.so.1
libelf1:amd64: /usr/lib/x86_64-linux-gnu/libelf-0.158.so
libelf1:amd64: /usr/share/doc/libelf1/changelog.Debian.gz
libelf1:amd64: /usr/share/doc/libelf1/copyright

libelf1 だ。

依存しているパッケージの表示

apt-cache depends

$ apt-cache depends vim
vim
  Depends: vim-common
  Depends: vim-runtime
  Depends: libacl1
  Depends: libc6
  Depends: libgpm2
  Depends: libpython2.7
  Depends: libselinux1
  Depends: libtinfo5
  Suggests: <ctags>
    exuberant-ctags
  Suggests: vim-doc
  Suggests: vim-scripts

再帰的に取得するには apt-rdepends を使う

パッケージソースを持ってくる

apt-get source

$ apt-get source ttyrec

debian ディレクトリ内にあてているパッチがおいてある

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