Apt-Get: Difference between revisions
Brodriguez (talk | contribs) (Add "uninstalling package" section) |
Brodriguez (talk | contribs) (Update notification command) |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The terminal command '''apt-get''' is the preferred means to update and install packages for an Ubuntu system. | The terminal command '''apt-get''' is the preferred means to update and install packages for an Ubuntu system. When working on an Ubuntu server, '''apt-get''' is essentially mandatory. | ||
For a list of useful packages to install via Apt-Get, see [[Apt-Get Packages]]. | |||
== Apt Vs Apt-Get == | == Apt Vs Apt-Get == | ||
This command '''apt''' is essentially shorthand for '''apt-get'''. All the main functionality of '''apt-get''' is present in '''atp''', and the | This command '''apt''' is essentially shorthand for '''apt-get'''. All the main functionality of '''apt-get''' is present in '''atp''', and the missing functions are ones that the average user never would have used anyways. | ||
The command '''apt''' also aims to be "more pleasant for end users", but as result, the output might not be as useful for things like scripts. | The command '''apt''' also aims to be "more pleasant for end users", but as result, the output might not be as useful for things like scripts. | ||
Line 12: | Line 13: | ||
* '''Apt-Get''' should be used in the rare occurrence that '''apt''' is missing functionality you need (You'll likely know if this is the case). | * '''Apt-Get''' should be used in the rare occurrence that '''apt''' is missing functionality you need (You'll likely know if this is the case). | ||
* '''Apt-Get''' should be used for scripting purposes, particularly if the script cares about the command's output. | * '''Apt-Get''' should be used for scripting purposes, particularly if the script cares about the command's output. | ||
== Installing Packages == | |||
To install a new package, run | |||
sudo apt install <package_name> | |||
See [[Apt-Get Packages]] for common packages. | |||
== Updating Packages == | == Updating Packages == | ||
To search for updates of known packages: | To search for updates of known packages: | ||
sudo apt update | |||
To apply found updates: | To apply found updates: | ||
sudo apt upgrade | |||
To remove files made obsolete from new updates: | To remove files made obsolete from new updates: | ||
sudo apt autoremove | |||
== Listing Installed Packages == | |||
Show all packages installed through apt with: | |||
apt list --installed | |||
To limit output to a given package name (or partial name), apply grep: | |||
apt list --installed | grep <partial_package_name> | |||
== Searching through Known Packages == | == Searching through Known Packages == | ||
If you don't know the exact name of a program you want to install, you can search through apt's known repositories with the following: | If you don't know the exact name of a program you want to install, you can search through apt's known repositories with the following: | ||
apt-cache search <keyword> | |||
Where '''<keyword>''' - The string to compare with. | |||
* Ex: If you want to see what nvidia drivers are available, you can type <code>apt-cache search nvidia</code> to display all matches with "nvidia". | * Ex: If you want to see what nvidia drivers are available, you can type <code>apt-cache search nvidia</code> to display all matches with "nvidia". | ||
Line 34: | Line 51: | ||
== Uninstalling a Package through Apt == | == Uninstalling a Package through Apt == | ||
If you installed a package through apt, you can remove it by running the command: | If you installed a package through apt, you can remove it by running the command: | ||
sudo apt-get purge --auto-remove <package_name> | |||
Line 40: | Line 57: | ||
Sometimes (rarely), a package source will become depreciated and cause errors when running <code>apt-get update</code>. Other times, you'll decide you no longer want a previously installed third party package, and you'll want to stop checking the package repo for updates (for example, if you used the commands above to uninstall a package). | Sometimes (rarely), a package source will become depreciated and cause errors when running <code>apt-get update</code>. Other times, you'll decide you no longer want a previously installed third party package, and you'll want to stop checking the package repo for updates (for example, if you used the commands above to uninstall a package). | ||
In either case, you can find and remove the given source url from <code>/etc/apt/sources.list</code> or <code>/etc/apt/sources.list.d</code>. | In either case, you can find and remove the given source url from <code>/etc/apt/sources.list</code> or <code>/etc/apt/sources.list.d/</code>. | ||
== Automatic Updates & Notifications == | |||
By default, Ubuntu will automatically update "core packages" and display regular notifications of package updates. | |||
Generally, you should be running manual updates through apt-get at minimum once a month anyways (See [[Apt-Get#Updating Packages|Updating Packages]]) so automatic updates/notifications just get in the way. Specifically, the notifications are just annoying. While the automatic updates "take control" of apt-get while they run, preventing you from manually updating. Sometimes, they'll also prevent your machine from shutting down or rebooting at really inconvenient times. | |||
To disable Update Notification Popups: | |||
sudo apt remove update-notifier update-notifier-common | |||
To disable Automatic Updates: | |||
sudo apt remove unattended-upgrades |
Latest revision as of 02:16, 25 October 2020
The terminal command apt-get is the preferred means to update and install packages for an Ubuntu system. When working on an Ubuntu server, apt-get is essentially mandatory.
For a list of useful packages to install via Apt-Get, see Apt-Get Packages.
Apt Vs Apt-Get
This command apt is essentially shorthand for apt-get. All the main functionality of apt-get is present in atp, and the missing functions are ones that the average user never would have used anyways.
The command apt also aims to be "more pleasant for end users", but as result, the output might not be as useful for things like scripts.
Essentially:
- In most cases, apt and apt-get can be fully interchanged.
- Apt is pretty safe to use as the default, if only because it's less characters to type.
- Apt-Get should be used in the rare occurrence that apt is missing functionality you need (You'll likely know if this is the case).
- Apt-Get should be used for scripting purposes, particularly if the script cares about the command's output.
Installing Packages
To install a new package, run
sudo apt install <package_name>
See Apt-Get Packages for common packages.
Updating Packages
To search for updates of known packages:
sudo apt update
To apply found updates:
sudo apt upgrade
To remove files made obsolete from new updates:
sudo apt autoremove
Listing Installed Packages
Show all packages installed through apt with:
apt list --installed
To limit output to a given package name (or partial name), apply grep:
apt list --installed | grep <partial_package_name>
Searching through Known Packages
If you don't know the exact name of a program you want to install, you can search through apt's known repositories with the following:
apt-cache search <keyword>
Where <keyword> - The string to compare with.
- Ex: If you want to see what nvidia drivers are available, you can type
apt-cache search nvidia
to display all matches with "nvidia".
Uninstalling a Package through Apt
If you installed a package through apt, you can remove it by running the command:
sudo apt-get purge --auto-remove <package_name>
Removing Package Sources
Sometimes (rarely), a package source will become depreciated and cause errors when running apt-get update
. Other times, you'll decide you no longer want a previously installed third party package, and you'll want to stop checking the package repo for updates (for example, if you used the commands above to uninstall a package).
In either case, you can find and remove the given source url from /etc/apt/sources.list
or /etc/apt/sources.list.d/
.
Automatic Updates & Notifications
By default, Ubuntu will automatically update "core packages" and display regular notifications of package updates.
Generally, you should be running manual updates through apt-get at minimum once a month anyways (See Updating Packages) so automatic updates/notifications just get in the way. Specifically, the notifications are just annoying. While the automatic updates "take control" of apt-get while they run, preventing you from manually updating. Sometimes, they'll also prevent your machine from shutting down or rebooting at really inconvenient times.
To disable Update Notification Popups:
sudo apt remove update-notifier update-notifier-common
To disable Automatic Updates:
sudo apt remove unattended-upgrades