Difference between revisions of "Debian - handbook for apt-get"

From Blue-IT.org Wiki

(APT)
(Dselect)
Line 44: Line 44:
  
 
On the old machine, which you want to create the list. No root priviledges required.
 
On the old machine, which you want to create the list. No root priviledges required.
** NOTE: the list represents the status of the OLD machine. Probably you want to remove files, you don't like on the new machine (old kernels, special versions for the distribution, etc. Just edit the file. **
+
 
 +
'''NOTE: the list represents the status of the OLD machine. Probably you want to remove files, you don't like on the new machine (old kernels, special versions for the distribution, etc. Just edit the file.'''
  
 
  dpkg --get-selections > selections_${HOSTNAME}_$(date +%F}
 
  dpkg --get-selections > selections_${HOSTNAME}_$(date +%F}
Line 62: Line 63:
  
 
  apt-get dselect-upgrade
 
  apt-get dselect-upgrade
 
  
 
==APT==
 
==APT==

Revision as of 11:10, 17 November 2019

Konsole öffnen, als Administrator anmelden. Open a console (terminal) and login as root.

Also see

Navigate

Navigieren in Verzeichnissen

Wo bin ich?

pwd

Verzeichnis anzeigen

ls

In Verzeichnis wechseln. (Tip: mit Tabulatortaste vervollständigen)

ls
cd Ve (Tabulatortaste drücken)
cd Verzeichnisname

Verzeichnis runter

cd ..

Locate

Datei suchen / Search for files

1. Suchdatenbank aktualisieren / actuate search database

updatedb

2. Suchen / search

locate dateiname | grep muster

Beispiel für Dateinamen / Examples for filenames

locate *.rpm | grep synaptic
locate *.doc | grep tax
locate *.txt

Dselect

Dselect is a tool for dpkg and the debian package mangement. It is handy, if you like to make a list of all installed packages of a machine and replay it on a new machine.

Install it:

sudo apt install dselect

On the old machine, which you want to create the list. No root priviledges required.

NOTE: the list represents the status of the OLD machine. Probably you want to remove files, you don't like on the new machine (old kernels, special versions for the distribution, etc. Just edit the file.

dpkg --get-selections > selections_${HOSTNAME}_$(date +%F}

On another machine, which you want to add this list:

available_package_list=`mktemp`
apt-cache dumpavail > "$available_package_list"
dpkg --merge-avail "$available_package_list"
rm -f "$available_package_list"

The systems database of apt will now be updated via the dpkg selections list you created:

dpkg --set-selections < selections_${HOSTNAME}_$(date +%F}

Upgrade the system via apt-get (apt ist _not_ working here):

apt-get dselect-upgrade

APT

apt-mirror

Apt-mirror will download you own package repository. You can put it on any computer, which will be able to share the mirror directory via apache or any other webserver.

Cleanup all cache an lists, that apt- created as root and recreate them:

rm -rf /var/lib/apt/lists/*; rm -rf /var/cache/apt/*
apt-get update

Configuration

apt-get install apache2 apt-mirror

Set the base path:

vim /etc/apt/mirror.list 
cd /var/www/html
ln -s /path-to-apt-mirror apt-mirror

The last line make "apt-mirror" accessible in a link like: http://your_ip_or_host/apt-mirror You have to use exactely this URL in your local apt-mirror sources list !!!

Server preferences list

sudo vim /etc/apt/preferences.d/myAptPrefs

Package: virtualbox-5.2
Pin: version 5.2.*
Pin-Priority: 1000

Package: synergy
Pin: version 1.4.12*
Pin-Priority: 1000

Server mirror list

[Update: 17.11.2019] optimized for Ubuntu Eoan (19.10)

vim /etc/apt/sources.list.d/third-party.list

# THIRD PARTY
#
# Google2Ubuntu
#
# Docker
# https://medium.com/devgorilla/how-to-install-docker-on-ubuntu-18-04-495216a16092
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable edge # Bei Aktualisierung zu eoan deaktiviert

# Ubuntu-Make
# Official (Bionic only)
# deb http://ppa.launchpad.net/ubuntu-desktop/ubuntu-make/ubuntu bionic main
# 
# Inofficial (EOAN) https://launchpad.net/~lyzardking/+archive/ubuntu/ubuntu-make
deb http://ppa.launchpad.net/lyzardking/ubuntu-make/ubuntu eoan main
# deb-src http://ppa.launchpad.net/lyzardking/ubuntu-make/ubuntu eoan main

# Mythbuntu
# deb http://ppa.launchpad.net/mythbuntu/0.28/ubuntu zesty main # Bei Aktualisierung zu zesty deaktiviert Bei Aktualisierung zu bionic deaktiviert
# Google
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # Bei Aktualisierung zu bionic deaktiviert

# Gnome Encfs Manager 
deb http://ppa.launchpad.net/gencfsm/ppa/ubuntu disco main
# deb-src http://ppa.launchpad.net/gencfsm/ppa/ubuntu disco main

# Libreoffice stable
# deb http://ppa.launchpad.net/libreoffice/ppa/ubuntu bionic main # Bei Aktualisierung zu bionic deaktiviert Bei Aktualisierung zu eoan deaktiviert

# Multisystem
deb http://liveusb.info/multisystem/depot all main


# Macbuntu & Mbuntu - Noobslab Themes
deb http://ppa.launchpad.net/noobslab/themes/ubuntu artful main
deb http://ppa.launchpad.net/noobslab/macbuntu/ubuntu artful main

# Y-PPA-Manager
deb http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu eoan main
# deb-src http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu eoan main

# Orbital Apps
# wget -qO- https://www.orbital-apps.com/public_key.asc | sudo apt-key add -
# deb http://orbital-apps.com/repo/ stable main

# Owncloud
# deb http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/Ubuntu_18.04/ / # Bei Aktualisierung zu bionic deaktiviert Bei Aktualisierung zu eoan deaktiviert

# RabbitVCS
# NOW IN OFFICIAL REPO OF 19.10*
# sudo apt install rabbitvcs-nautilus rabbitvcs-gedit rabbitvcs-cli rabbitvcs-core
# deb http://ppa.launchpad.net/rabbitvcs/ppa/ubuntu xenial main

# Handbrake Stable
deb http://ppa.launchpad.net/stebbins/handbrake-releases/ubuntu eoan main
# deb-src http://ppa.launchpad.net/stebbins/handbrake-releases/ubuntu eoan main

# Truecrypt und Indikator
deb http://ppa.launchpad.net/stefansundin/truecrypt/ubuntu eoan main
# deb-src http://ppa.launchpad.net/stefansundin/truecrypt/ubuntu eoan main

# SVN
# deb http://ppa.launchpad.net/svn/ppa/ubuntu xenial main
#
# Tuxboot
# deb http://ppa.launchpad.net/thomas.tsai/ubuntu-tuxboot/ubuntu xenial main
#
# Equinox Theme
# deb http://ppa.launchpad.net/tiheum/equinox/ubuntu xenial main
#
# VirtualBox 5.2
# deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian <mydist> contrib
# wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian disco contrib


#
# Java WebUpd8
deb http://ppa.launchpad.net/webupd8team/java/ubuntu artful main
#
# Sublime Text 3 - WebUpd8
deb http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu artful main
#
# Tor Browser Projekt
# deb http://ppa.launchpad.net/webupd8team/tor-browser/ubuntu yakkety main
#
# Y-PPA Manager
deb http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu artful main
#
# X2Go Stable
deb http://ppa.launchpad.net/x2go/stable/ubuntu eoan main

# Mono Develop from Xamarin official Repo
# http://www.mono-project.com/docs/getting-started/install/linux/
# deb http://download.mono-project.com/repo/debian wheezy main

# Calibre - actual in xenial
# deb http://ppa.launchpad.net/n-muench/calibre2/ubuntui bionic main

# Postgres
# deb http://apt.postgresql.org/pub/repos/apt zesty-pgdg main
# deb http://apt.postgresql.org/pub/repos/apt zesty-pgdg main

# XBMC
deb http://ppa.launchpad.net/team-xbmc/ppa/ubuntu eoan main

# PDF-ocr 
# deb http://ppa.launchpad.net/gezakovacs/pdfocr/ubuntu xenial main
# deb-src http://ppa.launchpad.net/gezakovacs/pdfocr/ubuntu xenial main

# Yubico
deb http://ppa.launchpad.net/yubico/stable/ubuntu eoan main
# deb-src http://ppa.launchpad.net/yubico/stable/ubuntu xenial main

# Sound-Switcher-Indicator
# http://www.webupd8.org/2014/02/sound-switcher-ubuntu-indicator.html
deb http://ppa.launchpad.net/yktooo/ppa/ubuntu eoan main
# deb-src http://ppa.launchpad.net/yktooo/ppa/ubuntu zesty main

# Darktable
# https://launchpad.net/~pmjdebruijn/+archive/ubuntu/darktable-release?field.series_filter=bionic
deb http://ppa.launchpad.net/pmjdebruijn/darktable-release/ubuntu disco main
# deb-src http://ppa.launchpad.net/pmjdebruijn/darktable-release/ubuntu bionic main

# Brightnesscontroller
deb http://ppa.launchpad.net/apandada1/brightness-controller/ubuntu bionic main
# deb-src http://ppa.launchpad.net/apandada1/brightness-controller/ubuntu bionic main

# Dropbox
deb [arch=i386,amd64] http://linux.dropbox.com/ubuntu trusty main

# Astro: siril
deb http://ppa.launchpad.net/lock042/siril/ubuntu bionic main
# deb-src http://ppa.launchpad.net/lock042/siril/ubuntu bionic main

# Lyx
deb http://ppa.launchpad.net/lyx-devel/release/ubuntu bionic main
# deb-src http://ppa.launchpad.net/lyx-devel/release/ubuntu bionic main

# Pulseeffects
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys FE3AE55CF74041EAA3F0AD10D5B19A73A8ECB754 
# https://github.com/wwmm/pulseeffects/wiki/Package-Repositories
deb http://ppa.launchpad.net/mikhailnov/pulseeffects/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mikhailnov/pulseeffects/ubuntu bionic main

# Gphoto
deb http://ppa.launchpad.net/mutlaqja/libgphoto2/ubuntu eoan main
# deb-src http://ppa.launchpad.net/mutlaqja/libgphoto2/ubuntu bionic main

# Kstars und INDI
deb http://ppa.launchpad.net/mutlaqja/ppa/ubuntu eoan main
# deb-src http://ppa.launchpad.net/mutlaqja/ppa/ubuntu artful main

# Nextcloud
deb http://ppa.launchpad.net/nextcloud-devs/client/ubuntu eoan main
# deb-src http://ppa.launchpad.net/nextcloud-devs/client/ubuntu bionic main
# This file makes sure that Opera Browser is kept up-to-date
# as part of regular system upgrades

# Opera
deb http://deb.opera.com/opera/ stable non-free #Opera Browser (final releases)
# The line above will make sure you get all final public releases.
# Uncomment the following line if you want to get alpha and beta
# releases, too.
# deb http://deb.opera.com/opera-beta/ stable non-free #Opera Browser (beta releases)

# Gimp
deb http://ppa.launchpad.net/otto-kesselgulasch/gimp/ubuntu eoan main
# deb-src http://ppa.launchpad.net/otto-kesselgulasch/gimp/ubuntu bionic main

# Skype - skypeforlinux
# curl https://repo.skype.com/data/SKYPE-GPG-KEY | sudo apt-key add - 
deb [arch=amd64] https://repo.skype.com/deb stable main

###   TeamViewer DEB repository list
# Teamviewer
### NOTE: Manual changes to this file
###        - prevent it from being updated by TeamViewer package updates
###        - will be lost after using the 'teamviewer repo' command
###       The original file can be restored with this command:
###       cp /opt/teamviewer/tv_bin/script/teamviewer.list /etc/apt/sources.list.d/teamviewer.list
###       which has the same effect as 'teamviewer repo default'

### NOTE: It is preferred to use the following commands to edit this file:
###       teamviewer repo                - show current repository configuration
###       teamviewer repo default        - restore default configuration
###       teamviewer repo disable        - disable the repository
###       teamviewer repo stable         - make all regular TeamViewer packages available (default)
###       teamviewer repo preview        - additionally, make feature preview packages available
###       teamviewer repo development    - additionally, make the latest development packages available
deb http://linux.teamviewer.com/deb stable main
# deb http://linux.teamviewer.com/deb preview main
# deb http://linux.teamviewer.com/deb development main

# Grub-customizer
deb http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu bionic main
# deb-src http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu bionic main

Alter the achitecture

To change the mirror list do 'deb-i386'

cat mirror.list  | sed 's/^deb/deb-i386/' | sed 's/^#deb/#deb-i386/' > mirror.list.new 

Add another architecture (I am using >> here, so manually reorder the mirror list ist necessary):

 cat mirror.list  | sed 's/^deb-i386/deb-amd64/' | sed 's/^#deb-i386/#deb-amd64/' >> mirror.list.new.amd64

Server clean list

Create a clean list according to the above mirror list:

cat mirror.list | grep -v ^# | grep -v  clean | grep -v set | \
grep -v '^$' | cut -d " " -f2 | uniq | awk '{system("echo clean " $0)}' >> mirror.list

Client sources list

Then you can create an apt-mirror-client list from this file. Be aware, the the sed commands

sed 's|^deb-amd64|deb|g' | sed 's|^deb-i386|deb|g' | uniq

will filter out different architectures. If you are not using different architectures, but clean "deb http://..." lines, you don't need thist. On the other hand, if you are using other architecture, like arm, you have to add corresponding sed commands!

cat mirror.list | grep -v ^# | grep -v  clean | grep -v set | grep -v '^$' | \
sed 's|^deb-amd64|deb|g' | sed 's|^deb-i386|deb|g' | uniq | \
sed 's|//|//APT_MIRROR_IP_OR_HOST/apt-mirror/|g'

and save it on your client ;-)

Third party ppa list

This way you can create a ppa list, which will substitude all the single source.list.d entries. In my case i use the list, created by the following command as a base for such a list:

cat mirror.list | grep -v  clean | grep -v set | grep -v '^$' | \
sed 's/^deb-i386/deb/' | sed 's/^#deb-i386/#deb/' | \
sed 's/^deb-amd64/deb/' | sed 's/^#deb-amd64/#deb/' | uniq

Cleanup all cache an lists, that apt- created as root and recreate them:

rm -rf /var/lib/apt/lists/*; rm -rf /var/cache/apt/*
apt-get update

GPG

If you get an error about a missing key, do:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <###################>

where <###################> is the key which was given in the error.

Otherwise, if you have a keyfile, do:

wget -qO - http://source.url/to/the.key | sudo apt-key add -

Updaten / update

apt-get update

Suchen / search

apt-cache search irgendein_name

Pakete installieren / install packages

apt-get install (--reinstall) irgendein_paket

Force dpkg options

apt-get install -o DPkg::Options::=--force-confold --yes --force-yes --no-install-recommends YOUR_PACKAGE_WONT_INSTALL YOUR_PACKAGE

Pakete deinstallieren (VOLLSTÄNDIG) / uninstall packages

apt-get remove (--purge) irgendein_paket

Distribution auf den neuesten Stand bringen / Distribution update

apt-get upgrade
apt-get dist-upgrade

Schiefgelaufene Installation wiederholen / Redo an installation

apt-get -f install

Komplettes Desaster korrigieren / Desaster recovery

dpkg --reconfigure -a

Get all deb entries in all sources-list (for apt-mirror)

find /etc/apt -name "*.list" | grep -v mirror.list | awk '{system("cat " $0 " | grep -v deb-src | egrep ^deb")}'

Paketliste erstellen und zurückspielen

dpkg --get-selections > selections.list

Replay:

dpkg --set-selections < selections.list
apt-get dselect-upgrade

Clear the selections cache:

dpkg --clear-selections