本文介绍了如何检查软件包是否已安装,如果没有安装,该如何安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Ubuntu系统上工作,目前这是我正在做的事情:
I'm working on a Ubuntu system and currently this is what I'm doing:
if ! which command > /dev/null; then echo -e "Command not found! Install? (y/n) \c" read if "$REPLY" = "y"; then sudo apt-get install command fi fi这是大多数人会做的吗?还是有一个更优雅的解决方案?
Is this what most people would do? Or is there a more elegant solution?
推荐答案要检查是否已安装 packagename ,请输入:
To check if packagename was installed, type:
dpkg -s <packagename>您还可以使用 dpkg-query ,该输出具有更整洁的输出,并且可以接受通配符.
You can also use dpkg-query that has a neater output for your purpose, and accepts wild cards, too.
dpkg-query -l <packagename>要查找什么包拥有 command ,请尝试:
To find what package owns the command, try:
dpkg -S `which <command>`有关更多详细信息,请参见文章 了解软件包是否已安装在Linux中 和 dpkg速查表.
For further details, see article Find out if package is installed in Linux and dpkg cheat sheet.
更多推荐
如何检查软件包是否已安装,如果没有安装,该如何安装?
发布评论