見出し画像

Linucメモ⑤ リポジトリとパッケージ管理

aptコマンド

apt-get

依存関係を調整しながらパッケージのインストール。アップグレード、アンインストールができる
apt-get update パッケージのインデックスを更新

root@Ubuntu-LInuc:/home/ken# apt-get update
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:2 http://jp.archive.ubuntu.com/ubuntu jammy InRelease
Get:3 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease [108 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages [438 kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [764 kB]
Get:7 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [196 kB]
Fetched 1,734 kB in 3s (507 kB/s)
Reading package lists... Done
  • apt-get upgrade パッケージの削除を行わずに、インストール済みの全パッケージを対象として更新

  • apt-get dist-upgrade システム全体(全パッケージ、カーネル)のアップグレード

apt-cache

パッケージ情報を照会・検索
depend パッケージ名 指定したパッケージの依存関係情報を表示

ken@Ubuntu-LInuc:~$ apt-cache depends ssh
ssh
  PreDepends: dpkg
    dpkg:i386
  Depends: openssh-client
    openssh-client:i386
  Depends: openssh-server
    openssh-server:i386
  • apt-cache seach キーワードを含むパッケージを表示

  • apt-cache show 指定したパッケージ情報の表示

  • apt-cache showpkg  指定したパッケージの依存関係を含めた情報を表示

  • apt-cache depends 指定したパッケージが依存しているパッケージをすべて表示

apt

apt-getとapt-cachを合わせたようなコマンド
apt list --installed インストールされたパッケージを一覧で表示

root@Ubuntu-LInuc:/home/ken# apt list --installed
Listing... Done
accountsservice/jammy-updates,jammy-security,now 22.07.5-2ubuntu1.4 amd64 [installed,automatic]
acl/jammy,now 2.3.1-1 amd64 [installed,automatic]
acpi-support/jammy,now 0.144 amd64 [installed,automatic]
acpid/jammy,now 1:2.0.33-1ubuntu1 amd64 [installed,automatic]
adduser/jammy,jammy,now 3.118ubuntu5 all [installed,automatic]
adwaita-icon-theme/jammy,jammy,now 41.0-1ubuntu1 all [installed,automatic]
aisleriot/jammy,now 1:3.22.22-1 amd64 [installed,automatic]
alsa-base/jammy,jammy,now 1.0.25+dfsg-0ubuntu7 all [installed,automatic]
alsa-topology-conf/jammy,jammy,now 1.2.5.1-2 all [installed,automatic]
alsa-ucm-conf/jammy-updates,jammy-updates,now 1.2.6.3-1ubuntu1.6 all [installed,automatic]

apt-file

指定したファイルを含むパッケージを検索

  • apt-file search =  apt-file find パスに検索パターンがはいっているファイルを含むパッケージを検索

  • apt-file list = apt-file show パッケージに含まれているファイル一覧表示

dpkgコマンド

dpkg

Debian/GNU LinuxやUbuntuなどのDebian系ディストリビューションのパッケージ管理に使用されるコマンド。

dpkg -l、--list インストール済みのパッケージ一覧を表示

ken@Ubuntu-LInuc:~$ 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                         >
+++-==========================================-================================>
ii  accountsservice                            22.07.5-2ubuntu1.4              >
ii  acl                                        2.3.1-1                         >
ii  acpi-support                               0.144                           >
ii  acpid                                      1:2.0.33-1ubuntu1               >
ii  adduser                                    3.118ubuntu5                    >
ii  adwaita-icon-theme                         41.0-1ubuntu1                   >
ii  aisleriot                                  1:3.22.22-1                     >
ii  alsa-base                                  1.0.25+dfsg-0ubuntu7            >
ii  alsa-topology-conf                         1.2.5.1-2                       >
ii  alsa-ucm-conf                              1.2.6.3-1ubuntu1.6              >
ii  alsa-utils                                 1.2.6-1ubuntu1                  >
ii  amd64-microcode                            3.20191218.1ubuntu2             >
ii  anacron                                    2.3-31ubuntu2                   >
ii  apg                                        2.2.3.dfsg.1-5build2
  • dpkg -E(Equal) すでに同バージョンがインストールされていればインストールしない

  • dpkg -G(high grade) すでに新しいバージョンがインストールされていればインストールしない

  • dpkg -P,--purge 設定ファイルを含めパッケージをアンインストール

  • dpkg -r,--remove 設定ファイルを残してパッケージをアンインストール

  • dpkg -s,--status インストール済みパッケージの詳細情報を表示

  • dpkg -S,--search 指定したファイルがどのパッケージからインストールされたかを表示

  • dpkg -l,--list インストール済みパッケージを検索して表示

  • dpkg -L,--listfiles 指定したパッケージからインストールされたファイルを一覧表示

  • dpkg -C,--audit インストールが完了していない不完全なパッケージを表示

dpkg-reconfigure

dpkgツールにおいてインストール済みのパッケージを再設定するコマンド
GUIでパッケージ設定ができるので便利!

yumコマンド

CentOSやFedoraで使用されるパッケージ管理システムを制御するコマンド。

yum check-update アップデート対象のパッケージリストを表示。

[root@CentOS ken]# yum check-update
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: mirrors.aliyun.com
 * updates: ftp.iij.ad.jp
base                                                     | 3.6 kB     00:00
extras                                                   | 2.9 kB     00:00
updates                                                  | 2.9 kB     00:00
(1/2): extras/7/x86_64/primary_db                          | 250 kB   00:00
(2/2): updates/7/x86_64/primary_db                         |  22 MB   00:02

bpftool.x86_64                            3.10.0-1160.92.1.el7           updates
c-ares.x86_64                             1.10.0-3.el7_9.1               updates
cronie.x86_64                             1.4.11-25.el7_9                updates
cronie-anacron.x86_64                     1.4.11-25.el7_9                updates
  • yum groupinstall パッケージグループのインストール

  • yum info パッケージの詳細情報を表示

  • yum update パッケージのアップデート

  • yum dplist 指定したパッケージが依存しているパッケージの一覧表示

yumdownloader

YUMツールにおいてパッケージファイルのダウンロードのみを行うコマンド

[root@CentOS etc]# yumdownloader php
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: mirrors.aliyun.com
 * updates: ftp.iij.ad.jp
php-5.4.16-48.el7.x86_64.rpm                               | 1.4 MB   00:00

設定ファイル

リポジトリ設定ファイルの場所→etc/yum.repos.d/

[root@CentOS etc]# cd yum.repos.d/
[root@CentOS yum.repos.d]# lsCentOS-Base.repo 
CentOS-Media.repo    CentOS-fasttrack.repoCentOS-CR.repo 
CentOS-Sources.repo  CentOS-x86_64-kernel.repoCentOS-Debuginfo.repo
CentOS-Vault.repo

YUMツールの設定ファイルの場所→/etc/yum.conf

[root@CentOS etc]# cat yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

rpmコマンド

Red Hat系のLinuxやTurbolinuxでは、プログラムの配布形式としてRPM(Redhat Package Manager)を採用している。これにより、ソフトウェアのインストールやアップデート、アンインストールが非常に簡単に行える。

rpm

rpm -qi bash 指定したパッケージファイルの表示と問い合わせ

[root@CentOS etc]# rpm -qi bash
Name        : bash
Version     : 4.2.46
Release     : 35.el7_9
Architecture: x86_64
Install Date: 20230416004528秒
Group       : System Environment/Shells
Size        : 3667724
License     : GPLv3+
Signature   : RSA/SHA256, 20211201061351秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : bash-4.2.46-35.el7_9.src.rpm
Build Date  : 20211124083549秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.gnu.org/software/bash
Summary     : The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.
  • rpm -ih パッケージを新規インストールする際に進行状況を表示
    rpm -i --hash

  • rpm -qa システムにインストールされている全てのパッケージを表示
    rpm --query --all

  • rpm -V  パッケージの検査
    rpm --verify
    <検査内容>
    ・RPMデータベースに格納されているファイルに関する情報と、インストールされたパッケージのファイルに関する情報を比較して変更(改ざんなど)が無いか検査する
    ・検査する内容は主にファイルのサイズ、MD5チェックサム、所有ユーザ、所有グループ、タイムスタンプである

  • rpm -e 依存関係を無視してパッケージを強制的にアンインストール
    rpm --erase

  • rpm -U(--upgrade) パッケージのアップグレード(なければインストール)

  • rpm -F(--freshen) パッケージのアップグレード(なければインストールしない)

  • rpm --query --configfiles 指定したパッケージファイルからインストールされた設定ファイルのみ表示
    rpm -qc


この記事が気に入ったらサポートをしてみませんか?