Sudo apt update что это
Перейти к содержимому

Sudo apt update что это

  • автор:

APT command in detail.

When you go through this post, please write every command in the terminal and execute it. Then look at the result. It will help you a lot to remember the command.

Introduction

APT stands for Advanced Packaging Tool. It is a package manager for the Debian base system. APT package manager download and install packages from online repositories. It only uses one file for download and installs. In that file has a listing of all of the online locations it gets it to package from. This filename is sources.list located on /etc/apt/sources.list.

With APT, we can search, install, remove, update, and upgrade packages. We will learn together how to do these actions. We want to install a package.
To install, let's first open the terminal. There are many ways to open the terminal.
1. Go to the launcher and search for the terminal.
2. Right-click on the window and select the open terminal.
3. Press the shortcut ctrl + alt + t.
You can choose whatever you prefer.

Search

Say, We want to install GIMP. GIMP is a photo editor for Ubuntu. First, we have to make sure GIMP is present in the online repositories. We can not do anything if it is not present in the online repositories. To makes sure that, We can search for a package using apt.

This will give us everything about gimp packages. This is tedious to do finding the gimp package from a bunch of packages.

To make it easy we can do this.

It will give us what we are looking for. This makes sure GIMP is present in the repository.

apt list is so handy when you want to know about installed packages and upgradable packages. For install packages:

For upgradable packages:

Now we want to know details about GIMP. To know that enter

Now we will get lots of information about gimp such as version, installed size, etc.

Install

Now we want to install it. To install it enter

Note: When you enter a command with sudo It will always prompt for the password.

This command will ask for your permission, to give permission press y . Then it will take some time to install it.
Now we want to verify its really installed or not. We can verify by going into the launcher by searching “gimp”.

Remove

We can install packages. But now we want to remove it. How can I do that? To do so enter

This command will ask for your permission, to give permission press y . Then it will take some time to remove it. But it may be left some configuration file on our system. To know that configuration file enter the previous command with —purge option.

If you look at the output of the command you will find like this line.

The following packages were automatically installed and are no longer required.

After that line, list of some packages that are no longer needed. But still in our system. Why we want to take them even they are no longer needed. If you look at the output closely, the output recommends us how to remove them.

Clean up

To remove that unnecessary thing enter.

Again, this command will ask for your permission. Then it will take some time to remove the unnecessary configuration files. As well as, this command will clean up your system by removing every unnecessary configuration file of any removed packages.

To remove a package, we use 3 different commands. We can remove it with one command. To do that just enter

It will save us from extra effort and energy.

Update

As days pass every software releases its new version. So we need to make sure our system and every software are up to date. To make up to date, we can tell APT to update our system and software by entering this command.

This command will go to the repository and get an updated list of packages that are available. And synchronize the updated repository to the cache file on our system.

Now we can check which packages are ready to be upgraded using one of our previous commands.

This will give us a list of packages that are upgradable.

Upgrade

sudo apt update command just synchronizes the cache file not install the newer version of packages. To install those updated packages Enter

It will upgrade(install newer version) all of the packages according to the cache file. We can do this in one step instead of two.

There I want to show you one last thing about apt.

Now the question arises what is the difference between “upgrade” and “full upgrade”?
The difference is “upgrade” will never remove a package or install new packages that not in our system. On the other hand, «full-upgrade« will upgrade what it considers most important packages on the system and it may remove those packages if determine that are no longer needed.

Note: You must be performed “update” first then “upgrade”. Without that, it will do nothing.

In a nutshell:

  1. ctrl + alt + t the keyboard shortcut for opening terminal.
  2. apt search packagename for searching packages.
  3. apt list packagename for getting a specific package that is looking for.
  4. apt list —installed for getting installed packages in the system.
  5. apt list —upgradable for getting upgradable packages in the system.
  6. apt show packagename to know details about packages.
  7. sudo apt install packagename for installing new packages.
  8. sudo apt remove packagename for removing packages.
  9. sudo apt purge packagename for removing packages and extra config files that are no longer needed.
  10. sudo apt autoremove for clean up unnecessary config files or packages from your system.
  11. sudo apt update packagename && sudo apt upgrade packagename for updating and upgrading a single package.
  12. sudo apt update && sudo apt upgrade for updating the cache file and upgrading packages that are available.

Congrats! Now you know about what APT command does. I really appreciate your time and your energy to read my article. If you think it is valuable then share it with your friends. And if I am wrong please let me know to fix myself.

Package management

Ubuntu features a comprehensive package management system for installing, upgrading, configuring, and removing software. In addition to providing access to an organized base of over 60,000 software packages for your Ubuntu computer, the package management facilities also feature dependency resolution capabilities and software update checking.

Several tools are available for interacting with Ubuntu’s package management system, from simple command-line utilities that can be easily automated by system administrators, to an easy-to-use graphical interface for those new to Ubuntu.

Introduction

Ubuntu’s package management system is derived from the same system used by the Debian GNU/Linux distribution. The package files contain all of the necessary files, metadata, and instructions to implement a particular functionality or software application on your Ubuntu computer.

Debian package files typically have the extension .deb , and usually exist in repositories which are collections of packages found online or on physical media, such as CD-ROM discs. Packages are normally in a pre-compiled binary format; thus installation is quick and requires no compiling of software.

Many packages use dependencies. Dependencies are additional packages required by the principal package in order to function properly. For example, the speech synthesis package festival depends upon the package alsa-utils , which is a package supplying the Advanced Linux Sound Architecture (ALSA) sound library tools needed for audio playback. In order for festival to function, it – and all of its dependencies – must be installed. The software management tools in Ubuntu will do this automatically.

Advanced Packaging Tool – APT

The apt command is a powerful command-line tool, which works with Ubuntu’s Advanced Packaging Tool (APT). The commands contained within apt provide the means for installing new software packages, upgrading existing software packages, updating the package list index, and even upgrading the entire Ubuntu system.

Some examples of popular uses for the apt utility include:

Install a Package
Installation of packages using apt is quite simple. For example, to install the nmap network scanner, type the following:

Tip
You can specify multiple packages to be installed or removed, by separating them with spaces.

Remove a Package
Removal of a package (or packages) is also straightforward. To remove the package installed in the previous example, simply type:

Adding the —purge option to apt remove will remove the package configuration files as well. This may or may not be the desired effect, so use with caution.

Note:
While apt is a command-line tool, it is intended to be used interactively, and not to be called from non-interactive scripts. The apt-get command should be used in scripts (perhaps with the —quiet flag). For basic commands the syntax of the two tools is identical.

Update the package index
The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file and in the /etc/apt/sources.list.d directory. To update the local package index with the latest changes made in the repositories, type the following:

Upgrade packages
Installed packages on your computer may periodically have upgrades available from the package repositories (e.g., security updates). To upgrade your system, first, update your package index with sudo apt update , and then type:

For details on how to upgrade to a new Ubuntu release, see our guide on upgrading.

Actions of the apt command, such as installation and removal of packages, are logged in the /var/log/dpkg.log log file.

For further information about the use of APT, read the comprehensive APT User’s Guide, or type apt help .

Aptitude

Launching Aptitude with no command-line options will give you a menu-driven, text-based frontend to the APT system. Many of the common package management functions, such as installation, removal, and upgrade, can be performed in Aptitude with single-key commands, which are typically lowercase letters.

Aptitude is best suited for use in a non-graphical terminal environment to ensure proper functioning of the command keys. You can start the menu-driven interface of Aptitude as a normal user by typing the following command at a terminal prompt:

When Aptitude starts, you will see a menu bar at the top of the screen and two panes below the menu bar. The top pane contains package categories, such as New Packages and Not Installed Packages. The bottom pane contains information related to the packages and package categories.

Using Aptitude for package management is relatively straightforward, and the user interface makes common tasks simple to perform. The following are examples of common package management functions as performed in Aptitude:

Install Packages
To install a package, locate it via the Not Installed Packages package category by using the keyboard arrow keys and the Enter key. Highlight the desired package, then press the + key. The package entry should turn green, indicating it has been marked for installation. Now press g to be presented with a summary of package actions. Press g again, and the package will be downloaded and installed. When finished, press Enter to return to the menu.

Remove Packages
To remove a package, locate it in the Installed Packages package category by using the keyboard arrow keys and the Enter key. Highlight the package you want to remove, then press the — key. The package entry should turn pink, indicating it has been marked for removal. Now press g to be presented with a summary of package actions. Press g again, and the package will be removed. When finished, press Enter to return to the menu.

Update Package Index
To update the package index, simply press the u key.

Upgrade Packages
To upgrade packages, first update the package index as detailed above, and then press the U key to mark all packages with updates. Now press g , which will present you with a summary of package actions. Press g again to begin the download and installation. When finished, press Enter to return to the menu.

The first column of information displayed in the package list (in the top pane) lists the current state of the package (when viewing packages). It uses the following key to describe the package state:

i: Installed package

c: Package not installed, but package configuration remains on the system

p: Purged from system

v: Virtual package

B: Broken package

u: Unpacked files, but package not yet configured

C: Half-configured — configuration failed and requires fix

H: Half-installed — removal failed and requires a fix

To exit Aptitude, simply press the q key and confirm you wish to exit. Many other functions are available from the Aptitude menu by pressing the F10 key.

Command Line Aptitude

You can also use Aptitude as a command-line tool, similar to apt . To install the nmap package with all necessary dependencies (as in the apt example), you would use the following command:

To remove the same package, you would use the command:

Consult the Aptitude manpages for full details of Aptitude’s command-line options.

dpkg is a package manager for Debian-based systems. It can install, remove, and build packages, but unlike other package management systems, it cannot automatically download and install packages – or their dependencies. APT and Aptitude are newer, and layer additional features on top of dpkg . This section covers using dpkg to manage locally installed packages:

To list all packages in the system’s package database, installed and uninstalled, from a terminal prompt type:

Depending on the number of packages on your system, this can generate a large amount of output. Pipe the output through grep to see if a specific package is installed:

Replace apache2 with any package name, part of a package name, or a regular expression.

To list the files installed by a package, in this case the ufw package, enter:

If you are unsure which package installed a file, dpkg -S may be able to tell you. For example:

The output shows that the /etc/host.conf belongs to the base-files package.

Note:
Many files are automatically generated during the package install process, and even though they are on the filesystem, dpkg -S may not know which package they belong to.

You can install a local .deb file by entering:

Change zip_3.0-4_amd64.deb to the actual file name of the local .deb file you wish to install.

You can uninstall a package by:

Caution:
Uninstalling packages using dpkg , is NOT recommended in most cases. It is better to use a package manager that handles dependencies to ensure that the system is in a consistent state. For example, using dpkg -r zip will remove the zip package, but any packages that depend on it will still be installed and may no longer function correctly.

For more dpkg options see the manpage: man dpkg .

APT configuration

Configuration of the APT system repositories is stored in the /etc/apt/sources.list file and the /etc/apt/sources.list.d directory. An example of this file is referenced here, along with information on adding or removing repository references from the file.

You can edit the file to enable and disable repositories. For example, to disable the requirement of inserting the Ubuntu CD-ROM whenever package operations occur, simply comment out the appropriate line for the CD-ROM, which appears at the top of the file:

Extra repositories

In addition to the officially-supported package repositories available for Ubuntu, there are also community-maintained repositories which add thousands more packages for potential installation. Two of the most popular are the universe and multiverse repositories. These repositories are not officially supported by Ubuntu, but because they are maintained by the community they generally provide packages which are safe for use with your Ubuntu computer.

Note:
Packages in the multiverse repository often have licensing issues that prevent them from being distributed with a free operating system, and they may be illegal in your locality.

Warning:
Be advised that neither universe nor multiverse contain officially-supported packages. In particular, there may not be security updates for these packages.

Many other package sources are available – sometimes even offering only one package, as in the case of packages provided by the developer of a single application. You should always be very careful and cautious when using non-standard package sources/repos, however. Research the packages and their origins carefully before performing any installation, as some packages could render your system unstable or non-functional in some respects.

By default, the universe and multiverse repositories are enabled. If you would like to disable them, edit /etc/apt/sources.list and comment out the following lines:

Automatic updates

The unattended-upgrades package can be used to automatically install updated packages and can be configured to update all packages or just install security updates. First, install the package by entering the following in a terminal:

To configure unattended-upgrades , edit /etc/apt/apt.conf.d/50unattended-upgrades and adjust the following to fit your needs:

Certain packages can also be excluded and therefore will not be automatically updated. To block a package, add it to the list:

Note:
The double “//” serve as comments, so whatever follows “//” will not be evaluated.

To enable automatic updates, edit /etc/apt/apt.conf.d/20auto-upgrades and set the appropriate APT configuration options:

The above configuration updates the package list, downloads, and installs available upgrades every day. These actions are triggered by timer units at a set time but with a random delay: apt-daily.timer and apt-daily-upgrade.timer . These timers activate the correspondent services that run the /usr/lib/apt/apt.systemd.daily script.

However, it may happen that if the server is off at the time the timer unit elapses, the timer will be triggered immediately at the next startup. As a result, they will often run on system startup
and thereby cause immediate activity and hold the apt-lock.

In many cases this is beneficial, but in some cases it might be counter-productive; examples are administrators with many shut-down machines or VM images that are only started for some quick action, which is delayed or even blocked by the unattended upgrades. To adapt this behaviour, we can change/override the configuration of both APT’s timer units [ apt-daily-upgrade.timer, apt-daily.timer ]. To do so, use systemctl edit <timer_unit> and override the Persistent attribute, for example with Persistent=delay :

The local download archive is cleaned every week. On servers upgraded to newer versions of Ubuntu, depending on your responses, the file listed above may not be there. In this case, creating a new file of the same name should also work.

Note:
You can read more about apt Periodic configuration options in the apt.conf(5) manpage and in the /usr/lib/apt/apt.systemd.daily script header.

The results of unattended-upgrades will be logged to /var/log/unattended-upgrades .

Notifications

Configuring Unattended-Upgrade::Mail in /etc/apt/apt.conf.d/50unattended-upgrades will enable unattended-upgrades to email an administrator detailing any packages that need upgrading or have problems.

Another useful package is apticron . apticron will configure a cron job to email an administrator information about any packages on the system that have updates available, as well as a summary of changes in each package.

To install the apticron package, enter the following command in a terminal:

Once the package is installed, edit /etc/apticron/apticron.conf , to set the email address and other options:

References

Most of the material covered in this chapter is available in man pages, many of which are available online.

The Installing Software Ubuntu wiki page has more information.

For more dpkg details see the dpkg man page.

The APT User’s Guide and apt man page contain useful information regarding APT usage.

For more info about systemd timer units (and systemd in general), visit the systemd man page and systemd.timer man page.

See the Aptitude user’s manual for more Aptitude options.

The Adding Repositories HOWTO (Ubuntu Wiki) page contains more details on adding repositories.

What does "sudo apt-get update" do?

Pandya's user avatar

In a nutshell, apt-get update doesn’t actually install new versions of software. Instead, it updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories.

apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs. From http://linux.die.net/man/8/apt-get:

Used to re-synchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list (5). An update should always be performed before an upgrade or dist-upgrade.

apt-get upgrade will fetch new versions of packages existing on the machine if APT knows about these new versions by way of apt-get update .

Used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list (5). Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, nor are packages that are not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. [Emphasis mine] An update must be performed first so that apt-get knows that new versions of packages are available.

apt-get dist-upgrade (on apt equivalent to full-upgrade ) will do the same job which is done by apt-get upgrade , plus it will also intelligently handle the dependencies, so it might remove obsolete packages or add new ones. See here: What is "dist-upgrade" and why does it upgrade more than "upgrade"?

In addition to performing the function of upgrade, this option also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones, if necessary. The /etc/apt/sources.list (5) file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for over-riding the general settings for individual packages.

You can combine commands with && as follows:

or to get newest versions possible as per version requirements of dependencies:

You need sudo both times, but since sudo by default doesn’t prompt you within 5 or so minutes since the last sudo operation, you will be prompted for your password only once (or not at all).

Sorry, you have been blocked

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 7a25692ebfb477bf • Your IP: Click to reveal 88.135.219.175 • Performance & security by Cloudflare

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *