为什么在给*后缀时删除不需要的包?
我做了一个sudo apt-get remove ruby*
然后我看到一些grub包也被删除所以我去安装回那些日志显示已删除的包
我在安装时将grub设置为my /sda
(一般情况下,不是任何数字)。
应该都可以,或者我应该担心我的系统并计划安装/重新配置更多的grub。
而且,为什么这样开心呢?
在终端上试试这个命令,
sudo grub-install /dev/sda
它将在您的磁盘上重新安装grub2。
如果要配置grub,请安装grub-pc
软件包。尝试以下命令安装grub-pc
软件包,
sudo apt-get install grub-pc
注意:仅当您在传统模式下安装Ubuntu时才安装此软件包。
如果您不确切知道自己在做什么,则不应使用:
sudo apt-get remove package.* # ⤷ or any other character in the place of dot
因为这可以删除意外的包并导致比它解决的更多问题。 package.*
将匹配名称中包含字符串package
所有包(及其依赖项)。 这是来自man apt-get
,在110行的某个地方:
If no package matches the given expression and the expression contains one of '.', '?' or '*' then it is assumed to be a POSIX regular expression, and it is applied to all package names in the database. Any matches are then installed (or removed). Note that matching is done by substring so 'lo.*' matches 'how-lo' and 'lowest'. If this is undesired, anchor the regular expression with a '^' or '$' character, or create a more specific regular expression.
这来自正则表达式/ POSIX Basic正则表达式 Wikibooks:
*
匹配前面的元素零次或多次。 例如,ab*c
匹配“ ac ”,“ abc ”,“ abbbc ”等。[xyz]*
匹配“”,“ x ”,“ y ”,“ z ”,“ zx ”,“ zyx ”,“ xyzzy “,等等。\(ab\)*
匹配“”,“ ab ”,“ abab ”,“ ababab ”等。
无论如何,如果你真的想运行像sudo apt-get remove package.*
(或sudo apt-get remove packagey*
,或者sudo apt-get remove packagec*
– 所有在这种情况下都是相同的), 首先运行它-s
(– --simulate
)选项,以确切了解它将执行的操作 (有关详细信息,请参阅man apt-get
)。
现在,我认为您可以使用以下两个步骤解决问题:
-
重新安装已删除的所有软件包
-
仅删除
ruby
:sudo apt-get remove ruby
或者,如果要删除所有使用
ruby
开头名称的包:sudo apt-get remove ^ruby
但最好先用以下模拟:
apt-get -s remove ^ruby
Apt-get使用正则表达式,这意味着ruby*
选择名称中包含rub的所有包。 从ruby开始删除所有包的正确方法是:
apt-get remove ^ruby