LoginSignup
0
0

More than 1 year has passed since last update.

パッケージ管理入門

Posted at

この記事の内容

  • パッケージ管理ツールについて
  • dpkg
  • apt

パッケージ管理ツール

 Linuxには様々なパッケージ管理ツールが存在しています。今回は、その中でもDebianやUbuntuで主に使われているdpkgとaptについて説明します。

OS系パッケージ管理

名称 正式名称 OS リポジトリ
RPM RPM Package Manager Red Hatディストリビューション https://github.com/rpm-software-management/rpm
yum Yellowdog Updater Modified Red Hatディストリビューション http://yum.baseurl.org/gitweb/
dnf Dandified YUM Red Hatディストリビューション https://github.com/rpm-software-management/dnf
dpkg --- Debianディストリビューション https://git.dpkg.org/git/dpkg/dpkg.git
apt Advanced Packaging Tool Debianディストリビューション https://salsa.debian.org/apt-team/apt
Homebrew --- macOS https://github.com/Homebrew/brew

dpkgとは?

 dpkgは、DebianやUbuntuにおけるパッケージ管理ツールです。ローカルにあるdebファイルを使いパッケージの管理を行います。

debファイルを元にツールをインストールするときは、

dpkg -i パッケージファイル名

パッケージを削除するときは、

dpkg -r パッケージファイル名

パッケージを設定ファイル含め完全に削除するときは、

dpkg -P パッケージファイル名

-lで、パッケージ一覧を表示ができる。

envader@172-19-1-2:~$ dpkg -l
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  adduser             3.115          all            add and remove users and groups
ii  apt                 1.4.10         amd64          commandline package manager
ii  base-files          9.9+deb9u13    amd64          Debian base system miscellaneous files
ii  base-passwd         3.5.43         amd64          Debian base system master password and grou
ii  bash                4.4-5          amd64          GNU Bourne Again SHell
ii  bsdutils            1:2.29.2-1+deb amd64          basic utilities from 4.4BSD-Lite
ii  coreutils           8.26-3         amd64          GNU core utilities
ii  dash                0.5.8-2.4      amd64          POSIX-compliant shell
ii  debconf             1.5.61         all            Debian configuration management system
ii  debian-archive-keyr 2017.5+deb9u1  all            GnuPG archive keys of the Debian archive
ii  debianutils         4.8.1.1        amd64          Miscellaneous utilities specific to Debian
ii  default-mysql-clien 1.0.2          all            MySQL database client binaries (metapackage
ii  diffutils           1:3.5-3        amd64          File comparison utilities
ii  dpkg                1.18.25        amd64          Debian package management system
ii  e2fslibs:amd64      1.43.4-2+deb9u amd64          ext2/ext3/ext4 file system libraries
ii  e2fsprogs           1.43.4-2+deb9u amd64          ext2/ext3/ext4 file system utilities
ii  findutils           4.6.0+git+2016 amd64          utilities for finding files--find, xargs
ii  gcc-6-base:amd64    6.3.0-18+deb9u amd64          GCC, the GNU Compiler Collection (base pack
ii  gpgv                2.1.18-8~deb9u amd64          GNU privacy guard - signature verification
ii  grep                2.27-2         amd64          GNU grep, egrep and fgrep
ii  gzip                1.6-5+b1       amd64          GNU compression utilities
ii  hostname            3.18+b1        amd64          utility to set/show the host name or domain
ii  init-system-helpers 1.48           all            helper tools for all init systems
ii  libacl1:amd64       2.2.52-3+b1    amd64          Access control list shared library
ii  libaio1:amd64       0.3.110-3      amd64          Linux kernel AIO access library - shared li
ii  libapt-pkg5.0:amd64 1.4.10         amd64          package management runtime library
ii  libattr1:amd64      1:2.4.47-2+b2  amd64          Extended attribute shared library
ii  libaudit-common     1:2.6.7-2      all            Dynamic library for security auditing - com
ii  libaudit1:amd64     1:2.6.7-2      amd64          Dynamic library for security auditing
ii  libblkid1:amd64     2.29.2-1+deb9u amd64          block device ID library
ii  libbsd0:amd64       0.8.3-1+deb9u1 amd64          utility functions from BSD systems - shared
ii  libbz2-1.0:amd64    1.0.6-8.1      amd64          high-quality block-sorting file compressor
ii  libc-bin            2.24-11+deb9u4 amd64          GNU C Library: Binaries
ii  libc-l10n           2.24-11+deb9u4 all            GNU C Library: localization files
ii  libc6:amd64         2.24-11+deb9u4 amd64          GNU C Library: Shared libraries
ii  libcap-ng0:amd64    0.7.7-3+b1     amd64          An alternate POSIX capabilities library
ii  libcomerr2:amd64    1.43.4-2+deb9u amd64          common error description library
ii  libconfig-inifiles- 2.94-1         all            Read .ini-style configuration files
ii  libdb5.3:amd64      5.3.28-12+deb9 amd64          Berkeley v5.3 Database Libraries [runtime]
ii  libdebconfclient0:a 0.227          amd64          Debian Configuration Management System (C-i
ii  libedit2:amd64      3.1-20160903-3 amd64          BSD editline and history libraries
ii  libevent-2.0-5:amd6 2.0.21-stable- amd64          Asynchronous event notification library
ii  libfdisk1:amd64     2.29.2-1+deb9u amd64          fdisk partitioning library
ii  libgcc1:amd64       1:6.3.0-18+deb amd64          GCC support library
ii  libgcrypt20:amd64   1.7.6-2+deb9u3 amd64          LGPL Crypto library - runtime library
ii  libgdbm3:amd64      1.8.3-14       amd64          GNU dbm database routines (runtime version)
ii  libgpg-error0:amd64 1.26-2         amd64          library for common error values and message
ii  libgssapi-krb5-2:am 1.15-1+deb9u2  amd64          MIT Kerberos runtime libraries - krb5 GSS-A
ii  libjemalloc1        3.6.0-9.1      amd64          general-purpose scalable concurrent malloc(
ii  libk5crypto3:amd64  1.15-1+deb9u2  amd64          MIT Kerberos runtime libraries - Crypto Lib
ii  libkeyutils1:amd64  1.5.9-9        amd64          Linux Key Management Utilities (library)
ii  libkrb5-3:amd64     1.15-1+deb9u2  amd64          MIT Kerberos runtime libraries
ii  libkrb5support0:amd 1.15-1+deb9u2  amd64          MIT Kerberos runtime libraries - Support li
ii  liblz4-1:amd64      0.0~r131-2+b1  amd64          Fast LZ compression algorithm library - run
ii  liblzma5:amd64      5.2.2-1.2+b1   amd64          XZ-format compression library
ii  libmount1:amd64     2.29.2-1+deb9u amd64          device mounting library
ii  libncurses5:amd64   6.0+20161126-1 amd64          shared libraries for terminal handling
ii  libncursesw5:amd64  6.0+20161126-1 amd64          shared libraries for terminal handling (wid
ii  libpam-modules:amd6 1.1.8-3.6      amd64          Pluggable Authentication Modules for PAM
ii  libpam-modules-bin  1.1.8-3.6      amd64          Pluggable Authentication Modules for PAM -
ii  libpam-runtime      1.1.8-3.6      all            Runtime support for the PAM library
ii  libpam0g:amd64      1.1.8-3.6      amd64          Pluggable Authentication Modules library
ii  libpcre3:amd64      2:8.39-3       amd64          Old Perl 5 Compatible Regular Expression Li
ii  libperl5.24:amd64   5.24.1-3+deb9u amd64          shared Perl library
ii  libprocps6:amd64    2:3.3.12-3+deb amd64          library for accessing process information f
ii  libreadline5:amd64  5.2+dfsg-3+b1  amd64          GNU readline and history libraries, run-tim
ii  libselinux1:amd64   2.6-3+b3       amd64          SELinux runtime shared libraries
ii  libsemanage-common  2.6-2          all            Common files for SELinux policy management
ii  libsemanage1:amd64  2.6-2          amd64          SELinux policy management library
ii  libsepol1:amd64     2.6-2          amd64          SELinux library for manipulating binary sec
ii  libsmartcols1:amd64 2.29.2-1+deb9u amd64          smart column output alignment library
ii  libss2:amd64        1.43.4-2+deb9u amd64          command-line interface parsing library
ii  libssl1.0.2:amd64   1.0.2u-1~deb9u amd64          Secure Sockets Layer toolkit - shared libra
ii  libstdc++6:amd64    6.3.0-18+deb9u amd64          GNU Standard C++ Library v3
ii  libsystemd0:amd64   232-25+deb9u12 amd64          systemd utility library
ii  libtinfo5:amd64     6.0+20161126-1 amd64          shared low-level terminfo library for termi
ii  libudev1:amd64      232-25+deb9u12 amd64          libudev shared library
ii  libustr-1.0-1:amd64 1.0.4-6        amd64          Micro string library: shared library
ii  libutempter0:amd64  1.1.6-3        amd64          privileged helper for utmp/wtmp updates (ru
ii  libuuid1:amd64      2.29.2-1+deb9u amd64          Universally Unique ID library
ii  libwrap0:amd64      7.6.q-26       amd64          Wietse Venema's TCP wrappers library
ii  locales             2.24-11+deb9u4 all            GNU C Library: National Language (locale) d
ii  login               1:4.4-4.1      amd64          system login tools
ii  lsb-base            9.20161125     all            Linux Standard Base init script functionali
ii  mariadb-client-10.1 10.1.48-0+deb9 amd64          MariaDB database client binaries
ii  mariadb-client-core 10.1.48-0+deb9 amd64          MariaDB database core client binaries
ii  mariadb-common      10.1.48-0+deb9 all            MariaDB common metapackage
ii  mawk                1.3.3-17+b3    amd64          a pattern scanning and text processing lang
ii  mount               2.29.2-1+deb9u amd64          tools for mounting and manipulating filesys
ii  multiarch-support   2.24-11+deb9u4 amd64          Transitional package to ensure multiarch co
ii  mysql-client        5.5.9999+defau amd64          MySQL database client binaries [transitiona
ii  mysql-common        5.8+1.0.2      all            MySQL database common files, e.g. /etc/mysq
ii  ncurses-base        6.0+20161126-1 all            basic terminal type definitions
ii  ncurses-bin         6.0+20161126-1 amd64          terminal-related programs and man pages
ii  openssh-client      1:7.4p1-10+deb amd64          secure shell (SSH) client, for secure acces
ii  openssh-server      1:7.4p1-10+deb amd64          secure shell (SSH) server, for secure acces
ii  openssh-sftp-server 1:7.4p1-10+deb amd64          secure shell (SSH) sftp server module, for
ii  passwd              1:4.4-4.1      amd64          change and administer password and group da
ii  perl                5.24.1-3+deb9u amd64          Larry Wall's Practical Extraction and Repor
ii  perl-base           5.24.1-3+deb9u amd64          minimal Perl system
ii  perl-modules-5.24   5.24.1-3+deb9u all            Core Perl modules
ii  procps              2:3.3.12-3+deb amd64          /proc file system utilities
ii  readline-common     7.0-3          all            GNU readline and history libraries, common
ii  sed                 4.4-1          amd64          GNU stream editor for filtering/transformin
ii  sensible-utils      0.0.9+deb9u1   all            Utilities for sensible alternative selectio
ii  sudo                1.8.19p1-2.1+d amd64          Provide limited super user privileges to sp
ii  sysvinit-utils      2.88dsf-59.9   amd64          System-V-like utilities
ii  tar                 1.29b-1.1      amd64          GNU version of the tar archiving utility
ii  tmux                2.3-4          amd64          terminal multiplexer
ii  tzdata              2020a-0+deb9u1 all            time zone and daylight-saving time data
ii  ucf                 3.0036         all            Update Configuration File(s): preserve user
ii  util-linux          2.29.2-1+deb9u amd64          miscellaneous system utilities
ii  zlib1g:amd64        1:1.2.8.dfsg-5 amd64          compression library - runtime

aptとは?

 aptは、dpkgには出来ない依存関係の管理までしてくれる、dpkgの機能を拡張したものです。またインターネットから自動でパッケージをダウンロードしてくれます。

aptの使い方

aptでパッケージをインストールするする前に、パッケージをアップデートする必要があります。

apt update

パッケージをインストールするには、

apt install パッケージ名

既存のパッケージをアンインストールするには、

apt remove パッケージ名

パッケージの依存関係にある物も含めてアンインストールするには、

apt --purge remove パッケージ名

まとめ

 今回は、パッケージ管理ツールのdpkgaptについて学びました。dpkgaptは、DebianやUbuntuでパッケージをインストールするときなどに必須となるコマンドなので、今回を機に覚えていきましょう!

実行環境

 オンライン学習サービスEnvaderを使いました。
Envaderは、環境構築が不要で簡単にLinux環境が学べるので学習するのにとても便利でした。コースは、

  • Linux基礎
  • Linux応用
  • セキュリティー基礎 などなど

 無料で使えて、初心者には難易度の高い環境構築しなくていいのでおすすめです。(一部有料)
今回学んだことをもっと深く学びたい方や新しい知識を身につけたい方は、ぜひ活用してみてください。

Envaderコース一覧

参考資料

https://envader.plus/course/5/scenario/1029/
https://eng-entrance.com/linux-package-dpkg

0
0
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
0
0