วิธีใช้ 8 'Debian Goodies Utilities' ที่มีประโยชน์เพื่อจัดการแพ็คเกจ Debian
Debian-goodies เป็นแพ็คเกจที่รวมยูทิลิตี้สไตล์กล่องเครื่องมือที่ใช้จัดการ Debian และระบบอนุพันธ์ของมัน เช่น Ubuntu, Kali Linux ยูทิลิตี้ภายใต้แพ็คเกจนี้ได้รับการพัฒนาในลักษณะที่จะรวมเข้ากับเครื่องมือเชลล์ที่เป็นที่รู้จักจำนวนมาก และเครื่องมืออื่น ๆ รวมอยู่ด้วยเนื่องจากไม่สามารถพัฒนาเป็นแพ็คเกจของตัวเองบนการกระจาย Linux ที่ใช้ Debian
ในคู่มือนี้ เราจะดูวิธีใช้ยูทิลิตี้ภายใต้แพ็คเกจ debian-goodies ซึ่งรวมถึง dglob, debget, dpigs<, dgrep, debmany, checkrestart, popbugs และ ซึ่ง-pkg-break แข็งแกร่ง>.
มาดูคำอธิบายของแต่ละเครื่องมือด้านล่าง:
- dglob – สร้างรายการชื่อแพ็คเกจที่ตรงกับรูปแบบ
- dgrep – ค้นหาไฟล์ทั้งหมดในแพ็คเกจที่กำหนดสำหรับ regex
- dpigs – แสดงว่าแพ็คเกจใดที่ติดตั้งใช้พื้นที่ดิสก์มากที่สุด
- debget – รับ .deb สำหรับแพ็คเกจในฐานข้อมูลของ APT
- debmany – เลือก manpages ของแพ็คเกจที่ติดตั้งหรือลบออก
- ตรวจสอบรีสตาร์ท – ค้นหาและรีสตาร์ทกระบวนการที่ใช้ไฟล์ที่อัปเกรดเวอร์ชันล้าสมัย
- popbugs – แสดงรายงานข้อบกพร่องที่มีความสำคัญต่อการเผยแพร่ที่ปรับแต่งตามแพ็คเกจที่คุณใช้
- ซึ่ง pkg พัง – จับได้ว่าพัสดุชิ้นใดที่อาจแตกหักอีกชิ้นหนึ่ง
สิ่งเหล่านี้เป็นโปรแกรมอรรถประโยชน์ที่มีประโยชน์มากที่สามารถทำให้ การดูแลระบบ ง่ายขึ้นมากเมื่อใช้ร่วมกับเครื่องมือเชลล์อื่นๆ ในความเป็นจริง เครื่องมือ Debian-goodies จะแสดงข้อมูลเกี่ยวกับแพ็คเกจมากกว่าเครื่องมือมาตรฐาน เช่น dpkg และ apt tools
อ่านเพิ่มเติม: เรียนรู้คำสั่ง 15 dpkg และคำสั่ง apt-get 25 คำสั่งเพื่อจัดการแพ็คเกจใน Debian และอนุพันธ์ของคำสั่งนั้น
วิธีการติดตั้ง Debian-goodies ใน Debian, Ubuntu และ Linux Mint
หากต้องการติดตั้งแพ็คเกจ debian-goodies ให้เรียกใช้คำสั่งนี้ด้านล่าง
sudo apt-get install debian-goodies
เมื่อติดตั้งแพ็คเกจ debian-goodies แล้ว ตอนนี้ก็ถึงเวลาตรวจสอบการใช้งานยูทิลิตี้แต่ละรายการที่มีให้ในแพ็คเกจนี้ในส่วนที่เหลือของบทความ
วิธีใช้ยูทิลิตี้ Debian-Goodies
1. ยูทิลิตี้ dglob
dglob สร้างรายการชื่อของแพ็คเกจหรือไฟล์ตามที่ระบุไว้ในรูปแบบ หากต้องการสร้างชื่อของแพ็คเกจทั้งหมด เพียงเรียกใช้ dglob หรือรวมตัวเลือก -a
root@tecmint:~# dglob
fonts-sil-abyssinica
libatk-adaptor
openoffice-onlineupdate
libvorbisfile3
libquadmath0
libxkbfile1
linux-sound-base
python-apt-common
python-gi-cairo
libgs9-common
libgom-1.0-common
libqt5qml5
libgtk2.0-bin
libregexp-common-perl
evolution-data-server
libaccount-plugin-generic-oauth
bind9-host
libhtml-tagset-perl
iputils-ping
libcgmanager0
evince
...
หากต้องการทราบว่ามีแพ็คเกจอยู่ในระบบของคุณหรือไม่ ให้รัน dglob ด้วยชื่อแพ็คเกจ ในตัวอย่างด้านล่าง เราจะค้นหา Firefox, Apache2 และ debain-goodies
root@tecmint:~# dglob firefox
firefox-locale-en
unity-scope-firefoxbookmarks
firefox
root@tecmint:~# dglob apache2
apache2
apache2-utils
apache2-bin
apache2-data
root@tecmint:~# dglob debian-goodies
debian-goodies
คุณสามารถพิมพ์รายการไฟล์ทั้งหมดในแพ็คเกจที่ระบุได้โดยใช้ตัวเลือก -f
root@tecmint:~# dglob -f firefox
/usr/share/doc/firefox-locale-en/copyright
/usr/share/doc/firefox-locale-en/changelog.Debian.gz
/usr/lib/firefox-addons/extensions/[email
/usr/lib/firefox-addons/extensions/[email
/usr/lib/firefox/distribution/searchplugins/locale/en-ZA/amazondotcom.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-ZA/google.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-ZA/ddg.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-GB/google.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-GB/amazon-en-GB.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-GB/ddg.xml
/usr/lib/firefox/webapprt/extensions/[email
/usr/lib/firefox/webapprt/extensions/[email
/usr/share/unity/scopes/web/firefoxbookmarks.scope
/usr/share/unity-scopes/firefoxbookmarks/unity_firefoxbookmarks_daemon.py
/usr/share/unity-scopes/firefoxbookmarks/__init__.py
/usr/share/doc/unity-scope-firefoxbookmarks/copyright
....
2. วิธีใช้ยูทิลิตี้ dgrep
ยูทิลิตี dgreb ใช้เพื่อค้นหาไฟล์ในชื่อแพ็กเกจที่ระบุสำหรับนิพจน์ทั่วไป โดยทั่วไปแล้วจะ greps ผ่านไฟล์ของแพ็คเกจที่ติดตั้งบนระบบของคุณและตัวเลือกส่วนใหญ่ที่ใช้กับคือตัวเลือกที่ใช้กับ grep ยกเว้นบางส่วน
หากต้องการระบุรูปแบบ ให้ใช้ตัวเลือก -e
ดังต่อไปนี้
root@tecmint:~# dgrep -e README apache2
/usr/sbin/apache2ctl: echo Setting ulimit failed. See README.Debian for more information. >&2
/usr/sbin/a2enmod: info( "See /usr/share/doc/apache2/README.Debian.gz on "
/etc/apache2/mods-available/autoindex.conf: AddIcon /icons/hand.right.gif README
/etc/apache2/mods-available/autoindex.conf: # ReadmeName is the name of the README file the server will look for by
/etc/apache2/mods-available/autoindex.conf: ReadmeName README.html
/etc/apache2/mods-available/cache_disk.conf: # /usr/share/doc/apache2/README.Debian, and the htcacheclean(8)
/etc/apache2/sites-available/default-ssl.conf: # /usr/share/doc/apache2/README.Debian.gz for more info.
...
หากต้องการพิมพ์ชื่อของไฟล์อินพุตแต่ละไฟล์ที่จะใช้พิมพ์เอาต์พุต ให้ใช้ตัวเลือก -l
root@tecmint:~# dgrep -l conf apache2
/usr/sbin/a2query
/usr/sbin/apache2ctl
/usr/sbin/a2enmod
/usr/share/doc/apache2/migrate-sites.pl
/usr/share/doc/apache2/copyright
/usr/share/doc/apache2/README.multiple-instances
/usr/share/doc/apache2/examples/setup-instance
/usr/share/doc/apache2/examples/secondary-init-script
/usr/share/doc/apache2/README.backtrace
/usr/share/apache2/apache2-maintscript-helper
/usr/share/lintian/overrides/apache2
/etc/bash_completion.d/apache2
/etc/init.d/apache2
...
หากต้องการแสดงเฉพาะส่วนที่ตรงกันของบรรทัดที่ตรงกัน ให้ใช้ตัวเลือก -o
root@tecmint:~# dgrep -o conf apache2
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
...
3. วิธีใช้ยูทิลิตี้ dpigs
ยูทิลิตี้นี้ใช้เพื่อแสดงแพ็คเกจที่ใช้พื้นที่มากที่สุดในระบบของคุณ มันสำคัญมากโดยเฉพาะเมื่อคุณมีพื้นที่เหลือน้อยและต้องการลบแพ็คเกจบางส่วนออก
หากต้องการค้นหาแพ็คเกจที่ใช้พื้นที่มากที่สุดในระบบของคุณ เพียงรันคำสั่งนี้
root@tecmint:~# dpigs
158762 linux-image-extra-4.2.0-16-generic
157066 linux-image-extra-3.19.0-31-generic
155037 wine1.8-amd64
143459 wine1.8-i386
103364 linux-firmware
100412 firefox
96741 openjdk-8-jre-headless
96302 libgl1-mesa-dri
90808 thunderbird
90652 liboxideqtcore0
คุณสามารถใช้ตัวเลือก -H
เพื่ออ่านขนาดบรรจุภัณฑ์ในรูปแบบที่มนุษย์สามารถอ่านได้
root@tecmint:~# dpigs -H
155.0M linux-image-extra-4.2.0-16-generic
153.4M linux-image-extra-3.19.0-31-generic
151.4M wine1.8-amd64
140.1M wine1.8-i386
100.9M linux-firmware
98.1M firefox
94.5M openjdk-8-jre-headless
94.0M libgl1-mesa-dri
88.7M thunderbird
88.5M liboxideqtcore0
หากต้องการระบุจำนวนแพ็คเกจที่กำหนดนอกเหนือจากค่าเริ่มต้นซึ่งก็คือ 10 ให้ใช้ตัวเลือก -n
root@tecmint:~# dpigs -H -n 15
155.0M linux-image-extra-4.2.0-16-generic
153.4M linux-image-extra-3.19.0-31-generic
151.4M wine1.8-amd64
140.1M wine1.8-i386
100.9M linux-firmware
98.1M firefox
94.5M openjdk-8-jre-headless
94.0M libgl1-mesa-dri
88.7M thunderbird
88.5M liboxideqtcore0
87.9M libgl1-mesa-dri
81.3M openoffice-core04
77.8M fonts-horai-umefont
64.2M linux-headers-4.2.0-16
61.5M ubuntu-docs
หากต้องการขอความช่วยเหลือในการใช้ dpigs ให้ใช้ตัวเลือก -h
root@tecmint:~# dpigs -h
Usage: dpigs [options]
Options:
-n, --lines=N
Display the N largest packages on the system (default 10).
-s, --status=status-file
Use status-file instead of the default dpkg status file.
-S, --source
Display the largest source packages of binary packages installed
on the system.
-H, --human-readable
Display package sizes in human-readable format (like ls -lh or du -h)
-h, --help
Display this message.
4. วิธีใช้ยูทิลิตี้ debget
debget ใช้เพื่อรับ .deb ที่กำหนดสำหรับแพ็คเกจจากฐานข้อมูลแพ็คเกจของ APT ในตัวอย่างถัดไป เราจะดึงไฟล์ .deb สำหรับยูทิลิตี้ apache2, zip และ tar
root@tecmint:~# debget apache2
(apache2 -> 2.4.12-2ubuntu2)
root@tecmint:~# debget zip
(zip -> 3.0-11)
Downloading zip from http://in.archive.ubuntu.com/ubuntu/pool/main/z/zip/zip_3.0-11_amd64.deb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 154k 0 1211 0 0 2039 0 0:01:17 --:--:-- 0:01:17 47 154k 47 75059 0 0 44694 0 0:00:03 0:00:01 0:00:02 100 154k 100 154k 0 0 74182 0 0:00:02 0:00:02 --:--:-- 74220
root@tecmint:~# debget tar
(tar -> 1.27.1-2)
Downloading tar from http://in.archive.ubuntu.com/ubuntu/pool/main/t/tar/tar_1.27.1-2_amd64.deb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 15 191k 15 30155 0 0 48338 0 0:00:04 --:--:-- 0:00:04 100 191k 100 191k 0 0 201k 0 --:--:-- --:--:-- --:--:-- 201k
แพ็คเกจ .deb ที่ดึงข้อมูลทั้งหมด
root@tecmint:~# dir -hl
total 348K
-rw-r--r-- 1 root root 86K Dec 30 12:46 apache2_2.4.7-1ubuntu4.6_amd64.deb
-rw-r--r-- 1 root root 192K Dec 30 12:46 tar_1.27.1-2_amd64.deb
-rw-r--r-- 1 root root 155K Dec 30 12:46 zip_3.0-11_amd64.deb
5. วิธีใช้ยูทิลิตี้ debmany
ใช้เพื่อเลือกหน้าการป้อนข้อมูลด้วยตนเองของแพ็คเกจที่ติดตั้งหรือถอนการติดตั้งบนระบบของคุณ ยูทิลิตี้นี้ช่วยให้คุณดู manpage ทั้งหมดของแพ็คเกจได้
ตัวเลือกบางส่วนต่อไปนี้ที่คุณสามารถใช้กับ debmany เพื่อแสดง manpage โดยใช้โปรแกรมดูที่คุณเลือก:
หากคุณใช้สภาพแวดล้อมเดสก์ท็อปของ KDE ให้ใช้ตัวเลือก -k
เพื่อใช้ kfmclient
root@tecmint:~# debmany -k tar
หมายเหตุ: ฉันไม่มี KDE DE ติดตั้งอยู่ในระบบ ดังนั้นจึงเป็นเรื่องยากที่จะแสดงผลลัพธ์ของคำสั่งข้างต้น
หากคุณใช้สภาพแวดล้อมเดสก์ท็อป GNOME ให้ใช้ตัวเลือก -g
เพื่อใช้ gnome-open
root@tecmint:~# debmany -g tar
หากคุณใช้สภาพแวดล้อมเดสก์ท็อป KDE/GNOME/Xfce ให้ใช้ตัวเลือก -x
เพื่อใช้ kdg-open
root@tecmint:~# debmany -x tar
ตรวจสอบให้แน่ใจว่าได้ติดตั้งโปรแกรมดูข้างต้นแล้วก่อนจึงจะสามารถใช้งานได้ ไม่เช่นนั้นคุณอาจได้รับข้อผิดพลาด
6. วิธีใช้ยูทิลิตี checkrestart
chechstart ใช้เพื่อค้นหาและรีสตาร์ทกระบวนการที่ใช้ไฟล์เวอร์ชันเก่าที่ได้รับการอัปเกรดแล้ว
หากต้องการใช้ checkrestart กับกระบวนการทั้งหมด ให้ใช้ตัวเลือก -a
root@tecmint:~# checkrestart -a
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
Found 30 processes using old versions of upgraded files
(28 distinct programs)
(23 distinct packages)
Of these, 1 seem to contain systemd service definitions or init scripts which can be used to restart them.
The following packages seem to have definitions that could be used
to restart their services:
openssh-server:
1947 /usr/sbin/sshd
1889 /usr/sbin/sshd
These are the initd scripts:
service ssh restart
...
หากต้องการระบุเฉพาะไฟล์ที่ถูกลบซึ่งแนบไปกับแพ็คเกจที่กำหนดบนระบบ ให้ใช้อ็อพชัน -p
root@tecmint:~# checkrestart -p
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
Found 0 processes using old versions of upgraded files
คุณสามารถสร้างข้อมูลผลลัพธ์โดยละเอียดได้โดยใช้ตัวเลือก -v
root@tecmint:~# checkrestart -v
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
Found 1 processes using old versions of upgraded files
(1 distinct program)
[DEBUG] Process /usr/bin/update-manager (PID: 2027)
List of deleted files in use:
/var/cache/apt/pkgcache.bin
/var/lib/dpkg/status (deleted)
/var/cache/apt/pkgcache.bin
/var/lib/dpkg/status (deleted)
/var/cache/apt/pkgcache.bin
/var/lib/dpkg/status (deleted)
/var/cache/apt/pkgcache.bin
/var/lib/dpkg/status (deleted)
[DEBUG] Running:['dpkg-query', '--search', '/usr/bin/update-manager']
[DEBUG] Reading line from dpkg-query: update-manager: /usr/bin/update-manager
[DEBUG] Found package update-manager for program /usr/bin/update-manager
(1 distinct packages)
[DEBUG] Running:['dpkg-query', '--listfiles', 'update-manager']
These processes (1) do not seem to have an associated init script to restart them:
update-manager:
2027 /usr/bin/update-manager
7. วิธีใช้ยูทิลิตี้ popbugs
ใช้เพื่อแสดงรายการจุดบกพร่องที่มีความสำคัญต่อการเผยแพร่ที่ปรับแต่งตามแพ็คเกจที่คุณใช้โดยทั่วไปในระบบของคุณ เมื่อคุณเรียกใช้ popbugs โดยไม่มีตัวเลือกใดๆ เป็นครั้งแรก ระบบจะแสดงข้อความดังตัวอย่างด้านล่างนี้
root@tecmint:~# popbugs
There is no popularity-contest data present on your system. This
probably means that popularity-contest has not yet run since it
was installed. Try waiting for /etc/cron.daily/popularity-contest to
to collect some data or manually run (as root user):
/usr/sbin/popularity-contest >/var/log/popularity-contest
หากต้องการสร้างบันทึก การแข่งขันความนิยม ให้เรียกใช้คำสั่งนี้ด้านล่าง
root@tecmint:~# /usr/sbin/popularity-contest > /var/log/popularity-contest
หากต้องการจัดเก็บเอาต์พุตเป็นไฟล์ ให้ใช้ตัวเลือก –output=/path/to/file ไฟล์เอาต์พุตควรเป็นไฟล์ html
root@tecmint:~# popbugs --output=/tmp/output.html
หากต้องการดูไฟล์เอาต์พุตให้เปิดไฟล์จากเว็บเบราว์เซอร์โดยระบุตำแหน่งไฟล์
หากต้องการแสดงข้อมูลการดีบัก ให้ใช้ตัวเลือก -d
root@tecmint:~# popbugs --d
POPCON: Adding package zeitgeist-core
POPCON: Adding package upstart
POPCON: Adding package unity-gtk2-module
POPCON: Adding package whoopsie
POPCON: Adding package xserver-xorg-input-evdev
POPCON: Adding package unity-services
POPCON: Adding package zlib1g
POPCON: Adding package xserver-xorg-core
..
8. วิธีใช้ยูทิลิตี้ which-pkg-break
ใช้เพื่อค้นหาแพ็คเกจที่ทำให้แพ็คเกจอื่นเสียหาย บางครั้งระบบของคุณอาจเสียหายจากแพ็คเกจบางอย่าง โดยเฉพาะอย่างยิ่งเมื่อทำการอัพเกรด ดังนั้น ซึ่ง pkg-break อาจช่วยคุณค้นหาแพ็คเกจที่ทำให้ระบบของคุณเสียหายหรือแพ็คเกจเฉพาะบนระบบ
หากต้องการค้นหาแพ็คเกจที่เสียหาย apache2 ให้รันคำสั่งนี้ด้านล่าง
root@tecmint:~# which-pkg-broke apache2
Package apache2 has no install time info
Package mysql-common has no install time info
Package libaprutil1-ldap has no install time info
Package has no install time info
Package libmysqlclient18 has no install time info
Package has no install time info
Package libaprutil1-dbd-sqlite3 has no install time info
Package has no install time info
Package libaprutil1-dbd-mysql has no install time info
Package apache2-utils has no install time info
Package libpq5 has no install time info
Package apache2-data has no install time info
Package libaprutil1-dbd-pgsql has no install time info
Package libaprutil1-dbd-odbc has no install time info
libacl1:amd64 Wed Apr 22 17:31:54 2015
libattr1:amd64 Wed Apr 22 17:31:54 2015
insserv Wed Apr 22 17:31:54 2015
libc6:amd64 Wed Apr 22 17:31:55 2015
...
สรุป
มียูทิลิตี้อื่นๆ อีกมากมายที่เกี่ยวข้องกับสิ่งที่เราได้พิจารณา ซึ่งเราอาจเรียนรู้เกี่ยวกับในบทความต่อๆ ไป หวังว่าคู่มือนี้จะเป็นประโยชน์ และหากคุณพบข้อผิดพลาดขณะใช้งานหรือมีแนวคิดอื่นใดที่จะเพิ่ม โปรดแสดงความคิดเห็น เชื่อมต่อกับ Tecmint