{"id":19133,"date":"2023-01-07T21:01:27","date_gmt":"2023-01-07T21:01:27","guid":{"rendered":"https:\/\/linuxways.net\/?p=19133"},"modified":"2023-01-07T21:01:27","modified_gmt":"2023-01-07T21:01:27","slug":"apt-command-in-linux-complete-guide","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/apt-command-in-linux-complete-guide\/","title":{"rendered":"apt command in Linux [Complete Guide]"},"content":{"rendered":"<p>apt is a useful command that stands for Advanced Package Tool and is used for installing, updating, removing, and overall managing deb packages on Ubuntu, Debian, and other Linux-based systems. The apt command is particularly useful as it allows an interactive way for users to update their system with the latest security patches, which makes it a very important Linux command.<\/p>\n<p>In this article, we will take a closer look at the apt commands in Linux, and find out how you can use them even as a complete beginner.<\/p>\n<p>Also read: <a href=\"https:\/\/linuxways.net\/de\/apache\/useful-apache-command-line-to-manage-web-service-in-linux-with-example\/\">Useful Apache commands to manage web service in Linux<\/a><\/p>\n<h2>What is apt?<\/h2>\n<p>Before we dig deep into the common syntax that apt has to offer, let us first look at what apt command does for you. apt is a free, user-centric software that works with the core libraries in Linux to offer an interactive way of installing and removing software. Where apt excels is the simplified process of handling the installation and removal of software in Linux-based systems. apt automates the entire process by precompiling source code and is considered an &#8220;important&#8221; priority in all current Debian releases.<\/p>\n<p>Now, the apt command is not the only solution to manage your Linux installations as dpkg commands already exist that too can manage installations. However, the apt command is a more friendly way to find, install, upgrade and remove packages from a Linux-based system.<\/p>\n<h2>apt Command Syntax<\/h2>\n<p>Below is a common syntax of the apt command<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt <span class=\"br0\">&#91;<\/span>option<span class=\"br0\">&#93;<\/span> <span class=\"kw3\">command<\/span> <span class=\"br0\">&#91;<\/span>packages<span class=\"br0\">&#93;<\/span><\/div><\/div>\n<p>You can manage specific packages by including the name of the package in the command line. The apt command also supports different options to customize the process. Below are examples of some well-known apt arguments.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt -d, <span class=\"re5\">--download-only<\/span><\/div><\/div>\n<p>This command downloads a package only but does not proceed with the installation.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt <span class=\"re5\">--no-download<\/span><\/div><\/div>\n<p>Does not download any new package and instead install packages already installed.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt -f, <span class=\"re5\">--fix-broken<\/span><\/div><\/div>\n<p>There may be several dependencies when managing packages. The command above tries to fix broken dependencies.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt -s, <span class=\"re5\">--simulate<\/span><\/div><\/div>\n<p>This command shows what the output will be without altering the system.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt -h, <span class=\"re5\">--help<\/span><\/div><\/div>\n<p>When you are ever in doubt, pull up the help section, and an array of useful commands will pop up on the screen.<\/p>\n<h2>Most Common apt Commands<\/h2>\n<p>The apt tool works with several commands which will be difficult to list in this article. However, here are some of the most used apt commands that you will inevitably come across while using a Linux system.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19134 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.38.15-pm-1024x667.png\" alt=\"\" width=\"1020\" height=\"664\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.38.15-pm-1024x667.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.38.15-pm-300x195.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.38.15-pm-768x500.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.38.15-pm.png 1464w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<p>One of the most used commands which is used to get the latest versions of available packages, but not install the updates.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt upgrade<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19135 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.39.05-pm-1024x666.png\" alt=\"\" width=\"1020\" height=\"663\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.39.05-pm-1024x666.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.39.05-pm-300x195.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.39.05-pm-768x500.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.39.05-pm.png 1466w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<p>Similar to the update command, the upgrade command downloads and installs packages to the new version.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt full-upgrade<\/div><\/div>\n<p>Upgrade installed packages and remove any pre-installed packages that are no longer necessary.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19136 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.41.25-pm-1024x672.png\" alt=\"\" width=\"1020\" height=\"669\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.41.25-pm-1024x672.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.41.25-pm-300x197.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.41.25-pm-768x504.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.41.25-pm.png 1470w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt <span class=\"kw2\">install<\/span><\/div><\/div>\n<p>Installs a specified package.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19137 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.42.33-pm-1024x665.png\" alt=\"\" width=\"1020\" height=\"662\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.42.33-pm-1024x665.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.42.33-pm-300x195.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.42.33-pm-768x499.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.42.33-pm.png 1472w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt remove<\/div><\/div>\n<p>Remove any specific packages.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19138 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.43.39-pm-1024x666.png\" alt=\"\" width=\"1020\" height=\"663\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.43.39-pm-1024x666.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.43.39-pm-300x195.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.43.39-pm-768x499.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.43.39-pm.png 1470w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt search<\/div><\/div>\n<p>Search specific packages when a name is provided in the description.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19139 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.57.02-pm-1024x669.png\" alt=\"\" width=\"1020\" height=\"666\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.57.02-pm-1024x669.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.57.02-pm-300x196.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.57.02-pm-768x502.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-06-at-12.57.02-pm.png 1466w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<h2>Useful tips and tricks when using the apt command<\/h2>\n<p>Now that we have looked into some common apt commands, let us look at some of the common usages of the apt command.<\/p>\n<h3>Upgrade Packages with apt upgrade<\/h3>\n<p>We have previously seen an update and upgrade command using which we can install new packages. However, if you want to upgrade specific packages, appending its name at the end is a handy little trick.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt upgrade lsof<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19140 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.54.30-pm-1024x668.png\" alt=\"\" width=\"1020\" height=\"665\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.54.30-pm-1024x668.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.54.30-pm-300x196.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.54.30-pm-768x501.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.54.30-pm.png 1468w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<p>The update and upgrade command also prints the output when executed. But you can run these commands in just one step and avoid any confirmation pop-up by appending -y attribute at the end.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update <span class=\"sy0\">&amp;&amp;<\/span> <span class=\"kw2\">sudo<\/span> apt upgrade <span class=\"re5\">-y<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19141 size-large\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.56.12-pm-1024x663.png\" alt=\"\" width=\"1020\" height=\"660\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.56.12-pm-1024x663.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.56.12-pm-300x194.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.56.12-pm-768x497.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/01\/Screen-Shot-2023-01-07-at-12.56.12-pm.png 1464w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><\/p>\n<h3>List Packages using the apt list<\/h3>\n<p>The apt list is a command which is used to print the name and details of all available packages. However, the list can often be extremely big resulting in difficulty navigating between the list. This is where more attributes come in handy. For instance, you can type in<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\">apt list <span class=\"sy0\">|<\/span> <span class=\"kw2\">more<\/span><\/div><\/div>\n<p>To move through the terminal page one at a time.<\/p>\n<h2>Conclusion<\/h2>\n<p>The apt command is a useful command which simplifies many of the tedious parts of managing packages in a Linux system. While it is often impossible to list all the things you can do with the apt command, our guide serves as a starting point that will guide you to speed with the apt command. You can learn more about the tips and tricks in Linux by <a href=\"https:\/\/linuxways.net\/de\/\">clicking here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>apt is a useful command that stands for Advanced Package Tool and is used for installing, updating, removing, and overall managing deb packages on Ubuntu, Debian, and other&hellip;<\/p>","protected":false},"author":107,"featured_media":19142,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-19133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/19133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/107"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=19133"}],"version-history":[{"count":1,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/19133\/revisions"}],"predecessor-version":[{"id":19143,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/19133\/revisions\/19143"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/19142"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=19133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=19133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=19133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}