1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Linux パッケージ管理

Posted at

概要

Linuxでは、多くのソフトウェアを使用することができます。
プログラム本体、設定ファイル、ライブラリ、ドキュメントのセットをパッケージと呼んでいます。

RedHat系のパッケージ管理

◇rpmコマンド
個々のパッケージ単位で管理を行うため、依存関係を自動解決されない。

◇yum,dnfコマンド
リポジトリを参照し、依存関係を含めて管理される。

rpmコマンド

オプション 説明
-i インストールする
-U アップグレードする
-e アンインストールする
-v 情報表示を増やす
-h インストール経過を#で示す

rpm [オプション] パッケージ が記載方法になる。

# パッケージをインストールする
$ rpm -ivh パッケージファイル名

# パッケージを更新する
$ rpm -Uvh パッケージファイル名

# パッケージをアンインストールする
$ rpm -evh パッケージ名

yumコマンド

yum [オプション] コマンド パッケージ が記載方法になる。

サブコマンド 説明
list 利用可能な全rpmを表示
list installed インストール済のrpm表示
info 指定したrpmの詳細情報を表示
search 指定したキーワードでrpmを検索して表示
deplist 指定したrpmの依存情報を表示
list updates、check-update 既インストールのrpmで更新可能なものを表示

インストール・アンインストール関連

サブコマンド 説明
install 依存関係を解決し、パッケージをインストール
update 更新可能な既インストールのrpmをすべてアップデート
upgrade システム全体のバージョンアップ
remove rpmをアンインストール

yumの設定

yumの設定情報は、/etc/yu.confファイルに記載する。

ec2-user@ip-172-31-45-214 ~]$ cat /etc/yum.repos.d/amazonlinux.repo 
[amazonlinux]
name=Amazon Linux 2023 repository
mirrorlist=https://al2023-repos-$awsregion-de612dc2.s3.dualstack.$awsregion.$awsdomain/core/mirrors/$releasever/$basearch/mirror.list
priority=10
enabled=1
repo_gpgcheck=0
type=rpm
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-linux-2023

[amazonlinux-source]
name=Amazon Linux 2023 repository - Source packages
mirrorlist=https://al2023-repos-$awsregion-de612dc2.s3.dualstack.$awsregion.$awsdomain/core/mirrors/$releasever/SRPMS/mirror.list
enabled=0
repo_gpgcheck=0
type=rpm
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-linux-2023
metadata_expire=6h

[amazonlinux-debuginfo]
name=Amazon Linux 2023 repository - Debug
mirrorlist=https://al2023-repos-$awsregion-de612dc2.s3.dualstack.$awsregion.$awsdomain/core/mirrors/$releasever/debuginfo/$basearch/mirror.list
enabled=0
repo_gpgcheck=0
type=rpm
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-amazon-linux-2023
metadata_expire=6h

Ubuntu系のパッケージ管理

◇dpkgコマンド
個々のパッケージ単位で管理を行うため、依存関係を自動解決されない。

◇aptコマンド
リポジトリを参照し、依存関係を含めて管理される。

dpkgコマンド

コマンド 説明
-i インストールする
-r 設定ファイルを残して、パッケージ削除
-P 設定も含めて、すべて削除

aptコマンド

apt コマンド パッケージ名 が記載方法になる。

検索・表示に関するコマンド

サブコマンド 説明
liset 利用可能な全パッケージ情報を表示
list --installed インストール済みのパッケージを表示
list --upgradeable アップデート可能なパッケージを表示
search 指定したキーワードから該当するパッケージを表示
show 指定したパッケージについての情報を表示

インストール・アンインストール

コマンド 説明
install インストール
update 索引ファイルとソースの同期する
upgrade 既インストールのパッケージをすべて更新する(削除無し)
full-upgrade 既インストールのパッケージをすべて更新する(必要に応じて削除する)
remove 設定ファイルを残して、パッケージを削除
purge 設定ファイルも含めて、パッケージを削除

### 設定情報
aptの設定情報は、/etc/apt/sourced.listに記載します。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?