mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Update and rename sources/tech/20221123.0 ⭐️⭐️ apt remove vs apt purge What’s the Difference.md to translated/tech/20221123.0 ⭐️⭐️ apt remove vs apt purge What’s the Difference.md
提交译文
This commit is contained in:
parent
d19d20fcc3
commit
1e4c7a198b
@ -1,121 +0,0 @@
|
||||
[#]: subject: "apt remove vs apt purge: What’s the Difference?"
|
||||
[#]: via: "https://itsfoss.com/apt-remove/"
|
||||
[#]: author: "Abhishek Prakash https://itsfoss.com/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "Tngze-G"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
apt remove vs apt purge: What’s the Difference?
|
||||
======
|
||||
|
||||
To [uninstall an application in the Ubuntu terminal][1], you can use:
|
||||
|
||||
```
|
||||
sudo apt remove package_name
|
||||
```
|
||||
|
||||
But in various forums, you may come across the suggestion to use the apt purge command for removing applications completely.
|
||||
|
||||
This leaves you confused because using apt purge is quite similar to apt remove:
|
||||
|
||||
```
|
||||
sudo apt purge package_name
|
||||
```
|
||||
|
||||
So, why are there two similar commands for removing packages? What’s the difference between the two? Let me explain it to you with a few examples.
|
||||
|
||||
### What’s the difference between apt-remove and apt-purge?
|
||||
|
||||
Both apt-remove and apt-purge do the same thing and that is to uninstall a package. The apt-purge removes the package and purges any configuration files associated with it. That’s the only difference between the two. Neither command touches the application files under the home directory of the user.
|
||||
|
||||
Have you ever removed an application and installed it again, only to notice that all your settings are in place? It’s because the apt remove command doesn’t remove the configuration files.
|
||||
|
||||
#### See what’s being removed and what remains
|
||||
|
||||
Let me share a practical example of removing the mplayer application using both apt remove and apt purge commands. The focus is on seeing what files remain after each operation.
|
||||
|
||||
Here are the files associated with mplayer before removal.
|
||||
|
||||
![mplayer before removal][2]
|
||||
|
||||
Now, if I run the apt remove command.
|
||||
|
||||
![apt uninstall package ubuntu][3]
|
||||
|
||||
Here are the files that remain in the system:
|
||||
|
||||
![files after mplayer removal][4]
|
||||
|
||||
As you can see, there are mplayer files remaining in two locations: /etc and /home/abhishek.
|
||||
|
||||
Now, if I install mplayer again and use apt purge to remove mplayer application this time.
|
||||
|
||||
![apt purge command][5]
|
||||
|
||||
Let’s look for files associated mplayer now.
|
||||
|
||||
![files after mplayer removal][6]
|
||||
|
||||
As you can see, the files from /etc directory no longer exists.
|
||||
|
||||
But what about the files in the home directory? Should apt purge not remove it?
|
||||
|
||||
The answer is negative. The apt commands do not touch the configuration files located under the home directory. They remain in the system unless you manually remove them. Those files are really small in size and hardly take disk space.
|
||||
|
||||
Do note that not all applications create configuration files under /etc or home directory.
|
||||
|
||||
#### The effect of using apt remove or apt purge
|
||||
|
||||
A practical example I can think of is Discord. You [install Discord on Ubuntu][7] with deb file. Start using it by logging into your account. Remove discord and install it again using deb file.
|
||||
|
||||
Now if you start Discord, you’ll notice that you are already logged into your account. Surprising, no?
|
||||
|
||||
But this is a feature because some applications like Discord, VirtualBox provide you updates similarly. You remove the current version and install the newer one (even if you don’t see this process). Since the application configuration files are not touched, you are logged back in without additional effort.
|
||||
|
||||
The apt remove command gives you the option to reuse an application with similar configuration that you used in the past.
|
||||
|
||||
However, you may not always want it. If you configured an application in a bad way and want to start from scratch, the apt purge command is the way to go forward.
|
||||
|
||||
#### Does apt purge perform a wild-card removal?
|
||||
|
||||
When you purge a package, you’ll notice that it mentions removing package-name*. This indicates that it will remove all the packages with names starting from package-name.
|
||||
|
||||
![apt purge wild card][8]
|
||||
|
||||
I didn’t find a definite answer on this point in the documentation (i.e. man page). So, I did a little test on my own. I installed espeak and espeak-ng packages. The espeak* should expand to espeak-ng as well.
|
||||
|
||||
But when espeak was pruged, the espeak-ng package was untouched. So there seems to be a mechanism that protects against such wild card expansions.
|
||||
|
||||
### So, should you use apt remove or apt purge?
|
||||
|
||||
Few people just get addicted to using apt purge.
|
||||
|
||||
In my opinion, apt remove is what you should use most of the time. Use apt purge when you have to get rid of the custom configuration files.
|
||||
|
||||
In both cases, you’ll have to remove the remaining configuration files from the user’s home directory and run apt autoremove to eliminate any leftover dependencies.
|
||||
|
||||
Over to you now. Do you understand the difference between apt remove and apt purge better now? Which one do you prefer to use?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/apt-remove/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://itsfoss.com/apt-remove/
|
||||
[2]: https://itsfoss.com/wp-content/uploads/2022/11/mplayer-before-removal.png
|
||||
[3]: https://itsfoss.com/wp-content/uploads/2022/11/apt-uninstall-package-ubuntu.png
|
||||
[4]: https://itsfoss.com/wp-content/uploads/2022/11/files-after-mplayer-removal.png
|
||||
[5]: https://itsfoss.com/wp-content/uploads/2022/11/apt-purge-command.png
|
||||
[6]: https://itsfoss.com/wp-content/uploads/2022/11/files-after-apt-purge.png
|
||||
[7]: https://itsfoss.com/install-discord-linux/
|
||||
[8]: https://itsfoss.com/wp-content/uploads/2022/11/apt-purge-wild-card.png
|
@ -0,0 +1,123 @@
|
||||
[#]: subject: "apt remove vs apt purge: What’s the Difference?"
|
||||
[#]: via: "https://itsfoss.com/apt-remove/"
|
||||
[#]: author: "Abhishek Prakash https://itsfoss.com/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "Tngze-G"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
apt remove 和 apt purge: 有什么区别?
|
||||
======
|
||||
|
||||
如果你想在Ubuntu服务器上卸载软件,可以使用
|
||||
|
||||
```
|
||||
sudo apt remove package_name
|
||||
```
|
||||
|
||||
但是在很多论坛,你可能会看到别人说,如果你想彻底删除软件就用the apt purge。
|
||||
|
||||
你可能会觉得很困惑,因为apt purge 和apt remove 看起来是一样的。
|
||||
|
||||
```
|
||||
sudo apt purge package_name
|
||||
```
|
||||
|
||||
为什么会有两个如此像的命令删除安装包呢?两者之间有什么不同呢?下面将为您揭晓
|
||||
|
||||
### apt-remove和 apt-purge有什么不同?
|
||||
|
||||
apt-remove 和 apt-purge相同之处就是都可以卸载安装包, 但是运行apt-purge 除了可以删除安装包之外,还可以清除相关的配置文件。这是两者之间唯一的不同点。要注意的是这两条命令都不能删除用户家目录中相关的应用程序文件。
|
||||
|
||||
你是否遇到过这样的情况,卸载一个软件然后重新安装,却发现之前的设置都还在。
|
||||
这是因为用 apt remove 不能删除该软件的相关配置文件。
|
||||
|
||||
|
||||
#### 哪些东西被删除了?哪些还在?
|
||||
|
||||
我用这两个命令分别卸载一下mplayer这个软件,看看卸载之后残留什么文件。
|
||||
我分享一个使用apt remove和apt purge两个命令分别卸载mplayer这个软件的实际例子。重点是看每次操作后还残余哪些文件。
|
||||
|
||||
这是删除前的文件
|
||||
|
||||
![mplayer before removal][2]
|
||||
|
||||
现在运行 apt remove 这个命令
|
||||
|
||||
![apt uninstall package ubuntu][3]
|
||||
|
||||
下面的是还残留在系统中的文件
|
||||
|
||||
![files after mplayer removal][4]
|
||||
|
||||
我们可以看到,有两个地方残留着mplayer的文件: /etc 和 /home/abhishek.
|
||||
|
||||
这次我们重新安装mplayer,然后用apt purge 来卸载软件。
|
||||
|
||||
![apt purge command][5]
|
||||
|
||||
现在让我们看看与mplayer相关的文件
|
||||
|
||||
![files after mplayer removal][6]
|
||||
|
||||
我们可以看到/etc目录下的文件已经没有了。
|
||||
|
||||
但是在家目录中的文件呢?apt purge会删除它们吗?
|
||||
|
||||
答案是否定的。apt命令不会删除家目录中的配置文件。所以它们仍然在系统中,除非你手动删除。但是这些文件所占的空间真的很小,几乎不占磁盘空间。
|
||||
|
||||
值得注意的是,不是所有的软件在家目录或者 /etc目录下都有配置文件。
|
||||
|
||||
#### 使用 apt remove 或者 apt purge的效果
|
||||
|
||||
我能想到的一个实际例子就是discord, 你用deb文件 [在Ubuntu上安装了Discord][7]. 然后登录自己的账号,之后又卸载并重新用deb文件安装。
|
||||
|
||||
现在如果你打开Discord,你会发现你的账号自动登录了。是不是觉得很奇怪?
|
||||
|
||||
|
||||
这个现象,就像是一些软件,比如Discord,VirtualBox,它们会提供更新,就是卸载现在的版本然后下载新的(尽管你不知道它内部怎么进行的),但是它在卸载的时候,这些软件的配置文件没有被删除,所以等你打开这些软件的时候就会自动登录。
|
||||
|
||||
当你想卸载一个软件,但是想保留你过去使用该软件留下的配置文件的时候,你就可以用apt remove。
|
||||
但是,有时候用它不能满足你的需求,比如当你没有配置好一个软件的时候,你想要重新开始,这个时候用apt purge就比较合适。
|
||||
|
||||
#### 运行apt purge 是否可以删除通配符?
|
||||
|
||||
当你删除一个包的时候,它会提示removing package-name*. 这意味着它会删除以这个包名开头的所有文件
|
||||
|
||||
![apt purge wild card][8]
|
||||
|
||||
我在文档中没有找到关于这个问题的答案 (i.e. man page)。 所以我自己做了一个小测试,我安装了espeak和espeak-ng这两个软件, espeak这个包按理说是可以扩展到espeak-ng。
|
||||
|
||||
但是当我用apt purge 删除espeak包时,espeak-ng包还在,没有被一并删除。因此,这似乎是有一种防止通配符的扩展的机制。
|
||||
|
||||
### 那么,你应该使用apt remove还是apt purge呢?
|
||||
|
||||
大部分人很常使用apt purge。
|
||||
|
||||
在我看来,一般清况下,用apt remove 就可以了,但是当你想删除那些自定义配置文件时,你就得用apt purge。
|
||||
不管是用apt remove 还是 apt purge, 你都需要从用户的家目录中删除残余的配置文件,并运行apt autoremove 来清除任何依赖的包。
|
||||
|
||||
现在到你啦。你现在对apt remove和apt purge的区别有更了解吗?你更喜欢使用哪一个呢?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/apt-remove/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[Tingze-G](https://github.com/Tingze-G)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://itsfoss.com/apt-remove/
|
||||
[2]: https://itsfoss.com/wp-content/uploads/2022/11/mplayer-before-removal.png
|
||||
[3]: https://itsfoss.com/wp-content/uploads/2022/11/apt-uninstall-package-ubuntu.png
|
||||
[4]: https://itsfoss.com/wp-content/uploads/2022/11/files-after-mplayer-removal.png
|
||||
[5]: https://itsfoss.com/wp-content/uploads/2022/11/apt-purge-command.png
|
||||
[6]: https://itsfoss.com/wp-content/uploads/2022/11/files-after-apt-purge.png
|
||||
[7]: https://itsfoss.com/install-discord-linux/
|
||||
[8]: https://itsfoss.com/wp-content/uploads/2022/11/apt-purge-wild-card.png
|
Loading…
Reference in New Issue
Block a user