LoginSignup
0
0

More than 1 year has passed since last update.

Linux で、とあるコマンドが含まれるパッケージ名を特定する方法

Posted at

はじめに

Linux を勉強してて沼るパターンとして、自身の環境と参考サイトの環境で、OS のディストリビューションやバージョンが異なることで、必要なコマンドをインストールする際のパッケージ名がわからない、といった事例があるあるかと思います。

そんな時に便利な読み替え方法を共有します。

インストールしたいコマンドがどのパッケージに含まれるかを確認する

yum provides

# uname -rs
Linux 3.10.0-1160.62.1.el7.x86_64

# more /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

# yum provides which
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
which-2.20-7.el7.x86_64 : Displays where a particular program in your path is located
Repo        : base



which-2.20-7.el7.x86_64 : Displays where a particular program in your path is located
Repo        : @anaconda



# 

apt-file search

# uname -rs
Linux 5.10.102.1-microsoft-standard-WSL2

# more /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
# 

# apt-file search -x "^.*/which$"
bash-doc: /usr/share/doc/bash/examples/functions/which
debianutils: /bin/which
epic4-help: /usr/share/epic4/help/4_Misc/which
epic4-help: /usr/share/epic4/help/6_Functions/which
ircii: /usr/share/ircII/help/which
scrollz: /usr/share/scrollz/help/which
yash: /usr/share/yash/completion/which
zsh-common: /usr/share/zsh/help/which
# 

おわりに

Linux は色々な種類があり、微妙にコマンドの仕様が異なるのでそれぞれ覚えるのが大変かと思います。
ですがどれも考え方は大体一緒なので、まずはどれか一つのパッケージマネージャで出来ることをある程度理解するのがおすすめです。

yum と apt ではコマンド対応表などもネット上にあるので、こんな便利なことが出来る、という概念とキーワードさえ押さえておけば、上手くググることで別のパッケージマネージャでも同等のコマンドを見つけれたりします。

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