什么是APT命令?
APT(Advanced Package Tool)是Ubuntu和其他基于Debian的Linux发行版中的软件包管理工具,它负责从软件仓库中下载、安装、升级和删除软件包,APT使用deb(Debian软件包)格式来描述软件包,并通过源(sources)列表来指定软件包的来源。
如何更新APT源?
1、打开终端(Terminal)。
2、输入以下命令以添加新的APT源:
sudo add-apt-repository <repository_url>
<repository_url>
是新源的URL,要添加官方的Ubuntu源,可以使用以下命令:
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse'
3、更新APT源列表:
sudo apt update
4、等待更新完成,这可能需要一些时间,因为APT需要从多个源下载软件包。
如何使用APT命令安装软件包?
1、搜索可用的软件包:
apt search <package_name>
<package_name>
是要搜索的软件包名称,要搜索Firefox浏览器,可以使用以下命令:
apt search firefox
2、安装软件包:
sudo apt install <package_name>
<package_name>
是要安装的软件包名称,要安装Firefox浏览器,可以使用以下命令:
sudo apt install firefox
3、升级已安装的软件包:
sudo apt upgrade <package_name>
<package_name>
是要升级的软件包名称,要升级Firefox浏览器,可以使用以下命令:
sudo apt upgrade firefox
如何卸载软件包?
1、查找已安装的软件包:
dpkg --get-selections | grep <package_name> | cut -d' ' -f2 | tr ' ' ' ' | sed 's/^[[:space:]]*//g' | sed 's/[[:space:]]*$//g' > packages.txt
<package_name>
是要卸载的软件包名称,要卸载Firefox浏览器,可以使用以下命令:
dpkg --get-selections | grep firefox | cut -d' ' -f2 | tr ' ' ' ' | sed 's/^[[:space:]]*//g' | sed 's/[[:space:]]*$//g' > packages.txt
2、从文件中读取软件包列表,然后逐个卸载:
while read line; do sudo apt remove $line; done < packages.txt; sudo rm packages.txt; sudo apt autoremove --purge && sudo apt clean all && sudo apt autoclean && sudo rm -rf /var/lib/apt/lists/* && sudo dpkg --configure -a && sudo apt update && sudo apt upgrade -y && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean all && sudo apt autoclean && sudo rm -rf /var/lib/apt/lists/* && sudo dpkg --configure -a && sudo apt update && sudo apt upgrade -y && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean all && sudo apt autoclean && sudo rm -rf /var/lib/apt/lists/* && sudo dpkg --configure -a && sudo apt update && sudo apt upgrade -y && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean all && sudo apt autoclean && sudo rm -rf /var/lib/apt/lists/* && sudo dpkg --configure -a && sudo apt update && sudo apt upgrade -y && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean all && sudo apt autoclean && sudo rm -rf /var/lib/apt/lists/*; echo "All packages have been uninstalled successfully!" || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; done < packages.txt; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remaining packages." || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!" || echo "Some packages were not uninstalled correctly. Please try again later!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes to take effect!"; exit; echo "Please run the above command again to uninstall the remainingpackages and then restart your system for changes
原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/215940.html