streda 18. decembra 2019

Pracujeme s apt (Debian, Ubuntu, Linux Mint)

V Debianoch (Ubuntu, Linux Mint ) existuje nástroj apt alebo apt-get




Linuxy si svoje updaty sťahujú pomocou repozitárov. Repozitár je zdroj súborov, noviniek a podobne. V počítačovom a najmä v linuxovom svete tomu hovoríme balíčky.

Ako sa pracuje s balíčkami:

A) Linux sa prihlási na repozitár, stiahne si balíček a nainštaluje si ho
B) Linux sa prihlási na repozitár, stiahne si novinky balíčka a vykoná update toho balíčka

Všetky balíčky v debian svete sú súbory .deb, takže .deb balíčky. (V RHEL je to .rpm) a keď chcete zomrieť, používajte distribúcie, kde si všetko musíte napísať sami.



Otázka: Kde sa nastavuje cesta k repozitárom? Alebo k zdrojom.

Odpoveď: /etc/apt/sources.list
(mriežka je poznámka)

root@guliverkel:/home/martin# cat /etc/apt/sources.list
#

# deb cdrom:[Debian GNU/Linux 9.6.0 _Stretch_ - Official amd64 NETINST 20181110-11:34]/ stretch main

#deb cdrom:[Debian GNU/Linux 9.6.0 _Stretch_ - Official amd64 NETINST 20181110-11:34]/ stretch main

etch main non-free contrib
deb-src http://ftp.sk.debian.org/debian/ stretch main non-free contrib

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free


pomocou príkazu apt sa prihlási na zdroje, ktoré má uvedené. (U nás to je deb-src http://ftp.sk.debian.org/debian/ ). Vo firemných prostrediach máte väčšinou vlastné repozitáre, o ktoré sa niekto správa. Je to najmä preto, aby na serveroch admini nehrali Míny, Princa alebo niečo iné.

ako sa pracuje s príkazom apt

1) keď chceme inštalovať balíček: 


apt install arj
root@guliverkel:/home/martin# apt install arj
Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following NEW packages will be installed:
  arj
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 208 kB of archives.
After this operation, 529 kB of additional disk space will be used.
Get:1 http://ftp.sk.debian.org/debian stretch/main amd64 arj amd64 3.10.22-15 [208 kB]
Fetched 208 kB in 0s (1,338 kB/s)
Selecting previously unselected package arj.
(Reading database ... 152275 files and directories currently installed.)
Preparing to unpack .../arj_3.10.22-15_amd64.deb ...
Unpacking arj (3.10.22-15) ...
Setting up arj (3.10.22-15) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@guliverkel:/home/martin#




2) keď chceme balíček (súbor zmazať)


apt remove arj

takto:

root@guliverkel:/home/martin# apt remove arj
Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following packages will be REMOVED:
  arj
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 529 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 152294 files and directories currently installed.)
Removing arj (3.10.22-15) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@guliverkel:/home/martin#



3) Čo je purge?


purge je po anglicky vyčistiť, zbaviť sa, niečo v štýle: naj to idze do guty

rozdiel medzi remove a purge je ten, že pri remove ostávajú konfiguračné súbory; pri purge vymaže aj konfiguračné súbory. Napr:

root@guliverkel:/home/martin# apt purge sl
Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following packages will be REMOVED:
  sl*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 99.3 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 152276 files and directories currently installed.)
Removing sl (3.03-17+b2) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@guliverkel:/home/martin#


4) apt autoremove názov balíčku:


autoremove odstráni balíček, ale aj závislosti, ktoré už nepotrebuje: 

root@guliverkel:/home/martin# apt autoremove apache2
Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following packages will be REMOVED:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
0 upgraded, 0 newly installed, 9 to remove and 0 not upgraded.
After this operation, 6,714 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 152945 files and directories currently installed.)
Removing apache2 (2.4.25-3+deb9u9) ...
Removing apache2-bin (2.4.25-3+deb9u9) ...
dpkg: warning: while removing apache2-bin, directory '/var/lib/apache2' not empty so not removed
Removing apache2-data (2.4.25-3+deb9u9) ...
Removing apache2-utils (2.4.25-3+deb9u9) ...
Removing libaprutil1-ldap:amd64 (1.5.4-3) ...
Removing libaprutil1-dbd-sqlite3:amd64 (1.5.4-3) ...
Removing libaprutil1:amd64 (1.5.4-3) ...
Removing libapr1:amd64 (1.5.2-5) ...
Removing ssl-cert (1.0.39) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@guliverkel:/home/martin#




5) Ako updatovať systém


Pokiaľ leziete do súboru /etc/apt/sources.list a meníte tam niečo, treba spustiť apt update (on si načíta zoznam balíčkov, aby bol aktuálny.) Redhaty pracujú s yum clean all a yum repolist.

root@guliverkel:/home/martin# apt update
Ign:1 http://ftp.sk.debian.org/debian stretch InRelease
Hit:2 http://ftp.sk.debian.org/debian stretch Release
Hit:3 http://security.debian.org/debian-security stretch/updates InRelease
Reading package lists... Done
Building dependency tree     
Reading state information... Done
All packages are up to date.
root@guliverkel:/home/martin#


6) upgrade balíčkov


začne aktualizovať balíčky, ktoré si načítal s apt update

apt upgrade

root@guliverkel:/home/martin# apt upgrade
Reading package lists... Done
Building dependency tree     
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


7) apt dist-upgrade


Vytvorí prechod na novú verziu balíčkov aj za tú cenu, že niektoré balíčky musí odstraniť alebo nainštalovať. (Nie je to prechod na novšiu verziu.)



8) autoclean


Debiany si svoje stiahnuté balíčky ukladujú do /var/cache/apt/archives

root@guliverkel:/home/martin# ls -lh /var/cache/apt/archives/
total 378M
-rw-r--r-- 1 root root  1.2M Jan 19  2019 apt_1.4.9_amd64.deb
-rw-r--r-- 1 root root  401K Jan 19  2019 apt-utils_1.4.9_amd64.deb
-rw-r--r-- 1 root root   66K Jan 22  2019 base-files_9.9+deb9u7_amd64.deb
-rw-r--r-- 1 root root   66K Feb  3  2019 base-files_9.9+deb9u8_amd64.deb
-rw-r--r-- 1 root root   66K Mar 28  2019 base-files_9.9+deb9u9_amd64.deb
-rw-r--r-- 1 root root  226K May  9  2019 bind9-host_1%3a9.10.3.dfsg.P4-12.3+deb9u5_amd64.deb
-rw-r--r-- 1 root root   55M Mar 31  2019 chromium_73.0.3683.75-1~deb9u1_amd64.deb
-rw-r--r-- 1 root root  207K Jun 12  2019 dbus_1.10.28-0+deb9u1_amd64.deb
-rw-r--r-- 1 root root   78K Jun 12  2019 dbus-user-session_1.10.28-0+deb9u1_all.deb
-rw-r--r-- 1 root root   90K Jun 12  2019 dbus-x11_1.10.28-0+deb9u1_amd64.deb
-rw-r--r-- 1 root root  1.5M Mar 25  2019 firmware-amd-graphics_20161130-5_all.deb
-rw-r--r-- 1 root root  5.4M Mar 25  2019 firmware-iwlwifi_20161130-5_all.deb
-rw-r--r-- 1 root root   15K Mar 25  2019 firmware-linux_20161130-5_all.deb
-rw-r--r-- 1 root root   14K Mar 25  2019 firmware-linux-nonfree_20161130-5_all.deb
-rw-r--r-- 1 root root  2.3M Mar 25  2019 firmware-misc-nonfree_20161130-5_all.deb
-rw-r--r-- 1 root root  335K Mar 25  2019 firmware-realtek_20161130-5_all.deb
-rw-r--r-- 1 root root  255K Aug  7 02:37 fonts-opensymbol_2%3a102.7+LibO5.2.7-1+deb9u10_all.



Tento autoclean zmaže všetky nepotrebné (nenainštalované) miesto na disku.

root@guliverkel:/home/martin# apt autoclean
Reading package lists... Done
Building dependency tree     
Reading state information... Done
Del vlc-plugin-qt 3.0.7-0+deb9u1 [1,140 kB]
Del vim-runtime 2:8.0.0197-4+deb9u1 [5,407 kB]
Del libreoffice-writer 1:5.2.7-1+deb9

(trochu to prečistil)

root@guliverkel:/home/martin# ls -lh /var/cache/apt/archives/
total 210M

9) apt f-install 


odstraní balíček so zlými závislosťami:

10) apt cache


(Hľadáme, či môžeme nainštalovať zo zdroju

A) hľadáme pomocou search: 

root@guliverkel:/home/martin# apt-cache search alien
alien - convert and install rpm and other packages
alien-hunter - Interpolated Variable Order Motifs to identify horizontally acquired DNA
alienblaster - Classic 2D shoot 'em up
alienblaster-data - Game data for Alien Blaster
blobandconquer - 3D platform shooting game
blobwars - platform shooting game
blobwars-data - platform shooting game
defendguin - defender clone with penguins
defendguin-data - Data files for defendguin


B) zisťujeme informácie o balíčku pomocou show

root@guliverkel:/home/martin# apt-cache show vlc
Package: vlc
Version: 3.0.8-0+deb9u1
Installed-Size: 225
Maintainer: Debian Multimedia Maintainers <pkg-multimedia-maintainers@lists.alioth.debian.org>
Architecture: amd64
Provides: mp3-decoder
Depends: vlc-bin (= 3.0.8-0+deb9u1), vlc-plugin-base (= 3.0.8-0+deb9u1), vlc-plugin-qt (= 3.0.8-0+deb9u1), vlc-plugin-video-output (= 3.0.8-0+deb9u1), vlc-l10n (= 3.0.8-0+deb9u1)
Pre-Depends: dpkg (>= 1.17.14)
Recommends: vlc-plugin-notify (= 3.0.8-0+deb9u1), vlc-plugin-samba (= 3.0.8-0+deb9u1), vlc-plugin-skins2 (= 3.0.8-0+deb9u1), vlc-plugin-video-splitter (= 3.0.8-0+deb9u1), vlc-plugin-visualization (= 3.0.8-0+deb9u1)
Description-en: multimedia player and streamer


C) existuje ešte showpkg - máme viac informácií o balíčku: 

root@guliverkel:/home/martin# apt-cache showpkg vlc
Package: vlc
Versions:
3.0.8-0+deb9u1 (/var/lib/apt/lists/ftp.sk.debian.org_debian_dists_stretch_main_binary-amd64_Packages) (/var/lib/apt/lists/security.debian.org_debian-security_dists_stretch_updates_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/apt/lists/ftp.sk.debian.org_debian_dists_stretch_main_binary-amd64_Packages
                  MD5: d96da6b991aa50928533b16fb11b3136
 Description Language: en
                 File: /var/lib/apt/lists/ftp.sk.debian.org_debian_dists_stretch_main_i18n_Translation-en
                  MD5: d96da6b991aa50928533b16fb11b3136


Reverse Depends:
  libvlccore8,vlc 2.2.4-7~
  vlc-plugin-sdl,vlc
  vlc-plugin-qt,vlc 3.0.0-1~
  vokoscreen,vlc
  vlc-plugin-vlsub,vlc 2.2.0~
  vlc-plugin-visualization,vlc
  vlc-plugin-video-splitter,vlc
  vlc-plugin-video-output,vlc
  vlc-plugin-svg,vlc
  vlc-plugin-skins2,vlc
  vlc-plugin-skins2,vlc 3.0.0-1~
  vlc-plugin-skins2,vlc 3.0.0-1~
  vlc-plugin-samba,vlc
  vlc-plugin-qt,vlc 3.0.0-1~
  freeplayer,vlc 0.8.6b
  vlc-plugin-notify,vlc
  vlc-plugin-jack,vlc
  vlc-plugin-fluidsynth,vlc
  vlc-plugin-access-extra,vlc
  tunapie,vlc




Čítajte aj tu: https://wiki.ubuntu.cz/apt

Žiadne komentáre:

Zverejnenie komentára