15 ตัวอย่างการปฏิบัติของ "คำสั่ง dpkg" สำหรับ Distros ที่ใช้ Debian
Debian GNU/Linux ซึ่งเป็นระบบปฏิบัติการตัวหลักของ Linux รุ่นต่างๆ รวมถึง Knoppix, Kali, Ubuntu, Mint ฯลฯ ใช้ตัวจัดการแพ็คเกจต่างๆ เช่น dpkg, apt , ความถนัด, ซินแนปติก, งาน, ยกเลิกการเลือก, dpkg-deb และ แยก dpkg
เราจะอธิบายแต่ละข้อโดยย่อก่อนที่จะเน้นไปที่คำสั่ง 'dpkg'
คำสั่งเอพีที
Apt ย่อมาจาก เครื่องมือแพ็คเกจขั้นสูง ไม่เกี่ยวข้องกับแพ็คเกจ 'deb' และใช้งานได้โดยตรง แต่ใช้ได้กับไฟล์เก็บถาวร 'deb' จากตำแหน่งที่ระบุใน “/etc/apt/ Sources.list”
อ่านเพิ่มเติม : 25 คำสั่งพื้นฐานที่มีประโยชน์ของคำสั่ง APT-GET
ความถนัด
Aptitude เป็นตัวจัดการแพ็คเกจแบบข้อความสำหรับ Debian ซึ่งเป็นส่วนหน้าของ 'apt' ซึ่งช่วยให้ผู้ใช้สามารถจัดการแพ็คเกจได้อย่างง่ายดาย
ซินแนปติก
ตัวจัดการแพ็คเกจแบบกราฟิกซึ่งทำให้การติดตั้ง, อัปเกรดและถอนการติดตั้งแพ็คเกจเป็นเรื่องง่ายแม้กระทั่งมือใหม่
ทาสก์เซล
Tasksel ช่วยให้ผู้ใช้สามารถติดตั้งแพ็คเกจที่เกี่ยวข้องทั้งหมดที่เกี่ยวข้องกับงานเฉพาะ เช่น สภาพแวดล้อมเดสก์ท็อป
ยกเลิกการเลือก
เครื่องมือการจัดการแพ็กเกจ ขับเคลื่อนด้วยเมนู ซึ่งเริ่มใช้งานครั้งแรกระหว่างการติดตั้งครั้งแรก และตอนนี้ถูกแทนที่ด้วย ความถนัด
Dpkg-deb
โต้ตอบกับไฟล์เก็บถาวร Debian
แยก Dpkg
มีประโยชน์ในการแยกและรวมไฟล์ขนาดใหญ่ออกเป็นไฟล์ขนาดเล็กเพื่อจัดเก็บไว้ในสื่อที่มีขนาดเล็กกว่า เช่น ฟล็อปปี้ดิสก์
คำสั่ง DPKG
dpkg เป็นโปรแกรมการจัดการแพ็กเกจหลักในระบบที่ใช้ Debian และ Debian ใช้เพื่อ ติดตั้ง, สร้าง, ลบ และ จัดการ แพ็คเกจ ความถนัดเป็นส่วนหน้าหลักของ dpkg
คำสั่ง dpkg ที่ใช้บ่อยที่สุดบางคำสั่งพร้อมกับการใช้งานแสดงอยู่ที่นี่:
1. ติดตั้งแพ็คเกจ
สำหรับการติดตั้งแพ็คเกจ “.deb” ให้ใช้คำสั่งพร้อมกับตัวเลือก “-i” ตัวอย่างเช่น หากต้องการติดตั้งแพ็กเกจ “.deb” ชื่อ “flashpluginnonfree_2.8.2+squeeze1_i386.deb” ให้ใช้คำสั่งต่อไปนี้
[root@tecmint~]# dpkg -i flashpluginnonfree_2.8.2+squeeze1_i386.deb
Selecting previously unselected package flashplugin-nonfree.
(Reading database ... 465729 files and directories currently installed.)
Unpacking flashplugin-nonfree (from flashplugin-nonfree_3.2_i386.deb) ...
Setting up flashplugin-nonfree (1:3.2) ...
--2013-10-01 16:23:40-- http://fpdownload.macromedia.com/get/flashplayer/pdc/11.2.202.310/install_flash_player_11_linux.i386.tar.gz
Resolving fpdownload.macromedia.com (fpdownload.macromedia.com)... 23.64.66.70
Connecting to fpdownload.macromedia.com (fpdownload.macromedia.com)|23.64.66.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6923724 (6.6M) [application/x-gzip]
Saving to: ‘/tmp/flashplugin-nonfree.FPxQ4l02fL/install_flash_player_11_linux.i386.tar.gz’
2. แสดงรายการแพ็คเกจที่ติดตั้งทั้งหมด
หากต้องการดูและแสดงรายการแพ็คเกจที่ติดตั้งทั้งหมด ให้ใช้ตัวเลือก “-l” พร้อมกับคำสั่ง
[root@tecmint~]# dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-======================================-========================-===============================================================================
ii accerciser 3.8.0-0ubuntu1 all interactive Python accessibility explorer for the GNOME desktop
ii account-plugin-aim 3.6.4-0ubuntu4.1 i386 Messaging account plugin for AIM
ii account-plugin-facebook 0.10bzr13.03.26-0ubuntu1 i386 GNOME Control Center account plugin for single signon - facebook
ii account-plugin-flickr 0.10bzr13.03.26-0ubuntu1 i386 GNOME Control Center account plugin for single signon - flickr
ii account-plugin-generic-oauth 0.10bzr13.03.26-0ubuntu1 i386 GNOME Control Center account plugin for single signon - generic OAuth
ii account-plugin-google 0.10bzr13.03.26-0ubuntu1 i386 GNOME Control Center account plugin for single signon
rc account-plugin-identica 0.10bzr13.03.26-0ubuntu1 i386 GNOME Control Center account plugin for single signon - identica
ii account-plugin-jabber 3.6.4-0ubuntu4.1 i386 Messaging account plugin for Jabber/XMPP
....
หากต้องการดูแพ็คเกจเฉพาะที่ติดตั้งหรือไม่ใช้ตัวเลือก “-l” พร้อมด้วยชื่อแพ็คเกจ ตัวอย่างเช่น ตรวจสอบว่ามีการติดตั้งแพ็คเกจ apache2 หรือไม่
[root@tecmint~]# dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-======================================-========================-==============================================
ii apache2 2.2.22-6ubuntu5.1 i386 Apache HTTP Server metapackage
3. นำแพ็คเกจออก
หากต้องการลบแพ็คเกจ “.deb” เราต้องระบุชื่อแพ็คเกจ “flashpluginnonfree“ ไม่ใช่ชื่อเดิม “flashplugin-nonfree_3.2_i386.debแข็งแกร่ง>“. ตัวเลือก “-r” ใช้เพื่อลบ/ถอนการติดตั้งแพ็คเกจ
[root@tecmint~]# dpkg -r flashpluginnonfree
(Reading database ... 142891 files and directories currently installed.)
Removing flashpluginnonfree ...
Processing triggers for man-db ...
Processing triggers for menu ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
คุณยังสามารถใช้ตัวเลือก 'p' แทน 'r' ซึ่งจะลบแพ็คเกจพร้อมกับไฟล์การกำหนดค่า ตัวเลือก 'r' จะลบเฉพาะแพ็คเกจเท่านั้น ไม่ใช่ไฟล์การกำหนดค่า
[root@tecmint~]# dpkg -p flashpluginnonfree
4. ดูเนื้อหาของแพ็คเกจ
หากต้องการดูเนื้อหาของแพ็คเกจใดแพ็คเกจหนึ่ง ให้ใช้ตัวเลือก “-c” ตามที่แสดง คำสั่งจะแสดงเนื้อหาของแพ็คเกจ “.deb” ในรูปแบบรายการยาว
[root@tecmint~]# dpkg -c flashplugin-nonfree_3.2_i386.deb
drwxr-xr-x root/root 0 2012-12-14 22:54 ./
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/bin/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/lib/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/lib/mozilla/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/lib/mozilla/plugins/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/lib/flashplugin-nonfree/
-rw-r--r-- root/root 3920 2009-09-09 22:51 ./usr/lib/flashplugin-nonfree/pubkey.asc
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/man/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/man/man8/
-rw-r--r-- root/root 716 2012-12-14 22:54 ./usr/share/man/man8/update-flashplugin-nonfree.8.gz
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/applications/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/icons/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/icons/hicolor/
drwxr-xr-x root/root 0 2012-12-14 22:54 ./usr/share/icons/hicolor/24x24/
....
5. ตรวจสอบว่ามีการติดตั้งแพ็คเกจหรือไม่
การใช้ตัวเลือก “-s” พร้อมชื่อแพ็คเกจ จะแสดงว่ามีการติดตั้งแพ็คเกจ deb หรือไม่
[root@tecmint~]# dpkg -s flashplugin-nonfree
Package: flashplugin-nonfree
Status: install ok installed
Priority: optional
Section: contrib/web
Installed-Size: 177
Maintainer: Bart Martens <[email >
Architecture: i386
Version: 1:3.2
Replaces: flashplugin (<< 6)
Depends: debconf | debconf-2.0, wget, gnupg, libatk1.0-0, libcairo2, libfontconfig1, libfreetype6, libgcc1, libglib2.0-0, libgtk2.0-0 (>= 2.14), libnspr4, libnss3, libpango1.0-0, libstdc++6, libx11-6, libxext6, libxt6, libcurl3-gnutls, binutils
Suggests: iceweasel, konqueror-nsplugins, ttf-mscorefonts-installer, ttf-dejavu, ttf-xfree86-nonfree, flashplugin-nonfree-extrasound, hal
Conflicts: flashplayer-mozilla, flashplugin (<< 6), libflash-mozplugin, xfs (<< 1:1.0.1-5)
Description: Adobe Flash Player - browser plugin
...
6. ตรวจสอบตำแหน่งของแพ็คเกจที่ติดตั้ง
เพื่อแสดงรายการตำแหน่งของไฟล์ที่จะติดตั้งในระบบของคุณจากชื่อแพ็คเกจ
[root@tecmint~]# dpkg -L flashplugin-nonfree
/.
/usr
/usr/bin
/usr/lib
/usr/lib/mozilla
/usr/lib/mozilla/plugins
/usr/lib/flashplugin-nonfree
/usr/lib/flashplugin-nonfree/pubkey.asc
/usr/share
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/update-flashplugin-nonfree.8.gz
/usr/share/applications
/usr/share/icons
/usr/share/icons/hicolor
...
7. ติดตั้งแพ็คเกจทั้งหมดจากไดเร็กทอรี
ติดตั้งไฟล์ปกติทั้งหมดที่ตรงกับรูปแบบ “*.deb” ซ้ำๆ ที่พบในไดเร็กทอรีที่ระบุและไดเร็กทอรีย่อยทั้งหมด สามารถใช้กับตัวเลือก “-R” และ “–ติดตั้ง” ตัวอย่างเช่น ฉันจะติดตั้งแพ็คเกจ “.deb” ทั้งหมดจากไดเรกทอรีชื่อ “debpackages“
[root@tecmint~]# dpkg -R --install debpackages/
(Reading database ... 465836 files and directories currently installed.)
Preparing to replace flashplugin-nonfree 1:3.2 (using .../flashplugin-nonfree_3.2_i386.deb) ...
Unpacking replacement flashplugin-nonfree ...
Setting up flashplugin-nonfree (1:3.2) ...
Processing triggers for man-db ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus ...
8. แกะแพ็คเกจแต่ไม่ต้องกำหนดค่า
การใช้การดำเนินการ “–unpack” จะเป็นการคลายแพ็กเกจ แต่จะไม่ติดตั้งหรือกำหนดค่า
[root@tecmint~]# dpkg --unpack flashplugin-nonfree_3.2_i386.deb
(Reading database ... 465836 files and directories currently installed.)
Preparing to replace flashplugin-nonfree 1:3.2 (using flashplugin-nonfree_3.2_i386.deb) ...
Unpacking replacement flashplugin-nonfree ...
Processing triggers for man-db ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus ...
9. กำหนดค่าแพ็คเกจที่แกะกล่องใหม่
ตัวเลือก “–กำหนดค่า” จะกำหนดค่าแพ็คเกจที่คลายแพ็กแล้วใหม่
[root@tecmint~]# dpkg --configure flashplugin-nonfree
Setting up flashplugin-nonfree (1:3.2) ...
10. เปลี่ยนข้อมูลแพ็คเกจที่มีอยู่
ตัวเลือก “–-update-avail” จะแทนที่ข้อมูลเก่าด้วยข้อมูลที่มีอยู่ในไฟล์แพ็คเกจ
[root@tecmint~]# dpkg –-update-avail package_name
11. ลบข้อมูลที่มีอยู่ของแพ็คเกจ
การดำเนินการ “–clear-avaial” จะลบข้อมูลปัจจุบันเกี่ยวกับแพ็คเกจที่มีอยู่
[root@tecmint~]# dpkg –-clear-avail
12. ลืมแพ็คเกจที่ถอนการติดตั้งและไม่พร้อมใช้งานไปได้เลย
คำสั่ง dpkg พร้อมตัวเลือก “–forget-old-unavail” จะลืมแพ็คเกจที่ถอนการติดตั้งและไม่พร้อมใช้งานโดยอัตโนมัติ
[root@tecmint~]# dpkg --forget-old-unavail
13. แสดงใบอนุญาต dpkg
[root@tecmint~]# dpkg --licence
14. แสดงเวอร์ชัน dpkg
อาร์กิวเมนต์ “–version” จะแสดงข้อมูลเวอร์ชัน dpkg
[root@tecmint~]# dpkg –version
Debian `dpkg' package management program version 1.16.10 (i386).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
15. รับความช่วยเหลือทั้งหมดเกี่ยวกับ dpkg
ตัวเลือก “–help” จะแสดงรายการตัวเลือกที่มีของคำสั่ง dpkg
[root@tecmint~]# dpkg –help
Usage: dpkg [<option> ...] <command>
Commands:
-i|--install <.deb file name> ... | -R|--recursive <directory> ...
--unpack <.deb file name> ... | -R|--recursive <directory> ...
-A|--record-avail <.deb file name> ... | -R|--recursive <directory> ...
--configure <package> ... | -a|--pending
--triggers-only <package> ... | -a|--pending
-r|--remove <package> ... | -a|--pending
-P|--purge <package> ... | -a|--pending
--get-selections [<pattern> ...] Get list of selections to stdout.
--set-selections Set package selections from stdin.
--clear-selections Deselect every non-essential package.
--update-avail <Packages-file> Replace available packages info.
--merge-avail <Packages-file> Merge with info from file.
--clear-avail Erase existing available info.
--forget-old-unavail Forget uninstalled unavailable pkgs.
-s|--status <package> ... Display package status details.
...
นั่นคือทั้งหมดที่สำหรับตอนนี้. เร็ว ๆ นี้ฉันจะกลับมาที่นี่อีกครั้งพร้อมกับบทความที่น่าสนใจอื่น ๆ หากฉันพลาดคำสั่งใด ๆ ในรายการ โปรดแจ้งให้เราทราบผ่านความคิดเห็น ในระหว่างนี้ โปรดคอยติดตามและเชื่อมต่อกับ Tecmint กดไลค์และแชร์เราและช่วยเราเผยแพร่ อย่าลืมพูดถึงความคิดอันมีค่าของคุณในความคิดเห็น