How to Set Highest Priority for Local Repository in APT

Here’s an example of how to do this:


# This script sets the package priority for all packages in Ubuntu to 500

# Sets the package priority for all packages in Ubuntu to 500
Package: *

# Specifies the release of Ubuntu to pin the packages to
Pin: release o=Ubuntu

# Sets the priority for the pinned packages to 500
Pin-Priority: 500

In the above example, we’re setting a priority of 500 for packages in Ubuntu’s main repository. This will ensure that they are preferred over any other sources. You can adjust this value as needed to suit your needs. Note that lower values (e.g., 100) indicate higher priorities, while higher values (e.g., 900) indicate lower priorities.
To explicitly see which packages APT is considering for installation from a particular source, you can use the apt-cache policy command followed by the package name. For example:


# This script uses the apt-cache policy command to check the installation priority of the kubuntu-desktop package.

# The apt-cache policy command displays the priority of each package from a particular source.

# The package name, in this case kubuntu-desktop, is specified after the command.

apt-cache policy kubuntu-desktop

This will show you which version of kubuntu-desktop is currently installed (if any), as well as which sources are being considered for installation. If your local repository has a higher priority than other sources, it should be listed first in the output.
To remove this pinning entry and return to default behavior, simply delete the /etc/apt/preferences file or set its contents to an empty string:

# This script removes the pinning entry from the /etc/apt/preferences file, which sets the priority for sources being considered for installation.
# To return to default behavior, the file can be deleted or its contents can be set to an empty string.

# The following line uses the "echo" command to output an empty string and overwrite the contents of the /etc/apt/preferences file.
# The "echo" command is used to display a line of text, in this case an empty string, and the ">" symbol is used to redirect the output to a file.
# The file path "/etc/apt/preferences" is specified to indicate which file the output should be redirected to.
echo "" > /etc/apt/preferences

This will ensure that packages are installed from their default sources without any preference given to local repositories.
In addition to pinning package versions, you can also reduce upgrade prompts and configure your default distribution by adding lines to the /etc/apt/apt.conf.d/local file as shown below:


# This script ensures that packages are installed from their default sources without any preference given to local repositories.
# It also reduces upgrade prompts and configures the default distribution by adding lines to the /etc/apt/apt.conf.d/local file.

# Set options for dpkg to force it to use the default configuration and avoid prompts during upgrades.
DPkg::options {
    "--force-confdef"; # Forces dpkg to use the default configuration for any new configuration file.
    "--force-confold"; # Forces dpkg to keep the old configuration file when a new one is available.
}


APT::Default-Release "kali-rolling";

The first line tells APT to try to choose by itself if the files have not changed (–force-confdef) and if the files are different, keep the existing version (–force-confold). The second line sets your default distribution to kali-rolling.
To learn more about APT and how to bend it to your will, we encourage you to refer to Kali Linux Revealed and The Debian Administrators Handbook, both of which contain a wealth of information, tips, and tricks.
In terms of learning version control technologies like Git or Subversion, the best way is to start developing something from scratch using Vagrant . This will allow you to easily create and manage a virtual machine that you can use as your new playground. Then, install a web server and a database and start creating. By doing so, you’ll gain hands-on experience with these technologies while also learning how they work in practice.

SICORPS