First we need install the apt-utils:
sudo apt install apt-utils
Create the repo directory, we create in home:
mkdir -r /home/ubuntu/main
mkdir -r /home/ubuntu/dists
Copy all .deb packages to main and change the permission for the repo directory to "0755" and run the
command dpkg-scanpackages inside the ubuntu directory:
cd /home/ubuntu
dpkg-scanpackages main | gzip -9c >dists/Packages.gz
dpkg-scanpackages will read all .deb packages from the main and will creat the Packages.gz in the dists directory.
deb file:///home/ubuntu dists/
If you add the local repo with online repos in the sources.list the package manager will give the priority to the online repo frist
and will not use the local repos, for the reason we will give high priority to the local repo in the /etc/apt/preferences.d
Package: *
Pin: origin
Pin-Priority: 700
Can create the local repo in the web server root directory or create
creat a semi link to that repos as:
sudo mkdir -r /var/www/ubuntu/main
sudo mkdir -r /var/www/ubuntu/dists
Add this repo to the apt sources.list:
deb http://localhost/ubuntu dists/
Package: *
Pin: origin localhost
Pin-Priority: 1000
to check the repos priority run the command:
apt-cache policy
Run the apt-get update, to update the packages cache.
http://www.example.com/ubuntu/dists/artful/main
http://www.example.com/ubuntu/dists/artful/non-free
http://www.example.com/ubuntu/pool
we add the above repo to the /etc/sources.list
deb http://example.com/ubuntu main non-free
Our ubuntu release is artfull, update manager reads the dists directory from the ubuntu, and then reads the main and non-free
from the artfull, directory and cache the packages of main and non-free.
dpkg -i && aptitude -f package_name
apt-cdrom -d /mnt/cdrom add
sudo apt install wajig
Run the wajig to hold the package:
sudo wajig hold package_name
Unhold the package with:
sudo wajig unhold package_name
To find which package contain a file, run the apt-cache or dpkg:
apt-cache search file_name
dpkg -S file_name
To remove a package misconfigured or improperly installed can run the command:
sudo aptitude purge $(dpkg -l|grep ^rc|awk '{ print $2 }')