दूषित फ़ाइलों के साथ (कुछ भी तोड़े बिना) खोजें (पुनर्स्थापित करें)


35

मैं आमतौर पर स्क्रैच से पुनर्स्थापित करने के बजाय लिनक्स सिस्टम को ठीक करना पसंद करता हूं। मेरे कंप्यूटरों ने कई वितरण उन्नयन और पीपीए या तृतीय-पक्ष रिपॉजिटरी की सूची देखी है। APT आमतौर पर यह सुनिश्चित करता है कि सब कुछ अंत में काम करता है। हालांकि, यह तथ्य कि पैकेज प्रबंधक को लगता है कि सभी आवश्यक पैकेज 'स्थापित' हैं, गारंटी नहीं देता है कि सभी फाइल फाइल सिस्टम पर मौजूद हैं।

इस तरह की स्थिति तब हो सकती है जब आपको साथ काम करने की निर्भरता की समस्या हो dpkg --force-*। कोई फ़ाइल /usrको रूट से हटाकर ऐसी स्थिति को पुन: उत्पन्न भी कर सकता है ।

क्या यह सत्यापित करने का एक सरल तरीका है कि क्या स्थापित पैकेज से संबंधित सभी फाइलें मौजूद हैं?

यदि ऐसा कोई समस्या पैकेज मिलता है, aptitude reinstallतो समस्या को हल करता है।

जवाबों:


47

से debsumsआदमी पेज:

apt-get install --reinstall $(dpkg -S $(debsums -c) | cut -d : -f 1 | sort -u)
       Reinstalls packages with changed files.

मैंने इसे अपने सिस्टम पर केवल इसलिए चलाया क्योंकि जब मैं बीटा OS के साथ प्रयोग कर रहा था, तब डिस्क सामग्री अनियमित रूप से दूषित हो गई थी। यहाँ मैंने क्या किया (और लगता है कि यह अच्छी तरह से काम किया है):

सबसे पहले, मैंने 'डेबसुम' स्थापित किया और यह देखने के लिए दौड़ा कि क्या मेरे सिस्टम पर कोई भ्रष्ट फाइल है:

$ sudo apt-get install debsums
$ sudo debsums_init
$ sudo debsums -cs
/usr/share/bash-completion/completions/ssh
/usr/share/icons/hicolor/scalable/actions/cheese-take-photo.svg
/usr/share/gnome/help/gnumeric/C/files-textopen.xml
/usr/share/dbus-1/services/indicator-sound.service
/lib/modules/3.11.0-12-generic/kernel/drivers/mtd/ubi/ubi.ko

जैसा कि आप देख सकते हैं, मेरे पास पाँच भ्रष्ट फाइलें हैं, इसलिए मुझे उन्हें पुनः स्थापित करने की आवश्यकता है। मैंने पाया कि किस पैकेज में भ्रष्ट फाइलें हैं:

$ sudo debsums -c | xargs -rd '\n' -- dpkg -S | cut -d : -f 1 | sort -u
bash-completion
cheese-common
gnumeric-doc
indicator-sound
linux-image-extra-3.11.0-12-generic

फिर मैंने क्षतिग्रस्त पैकेजों को पुनर्स्थापित करके भ्रष्टाचार की मरम्मत की:

$ xargs -rd '\n' -a <(sudo debsums -c | xargs -rd '\n' -- dpkg -S | cut -d : -f 1 | sort -u) -- sudo apt-get install -f --reinstall --
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  linux-image-generic
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 5 reinstalled, 0 to remove and 0 not upgraded.
Need to get 43.9 MB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ saucy/main bash-completion all 1:2.0-1ubuntu3 [173 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ saucy/main cheese-common all 3.8.3-0ubuntu1 [2,929 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ saucy/universe gnumeric-doc all 1.12.6-1 [7,295 kB]     
Get:4 http://us.archive.ubuntu.com/ubuntu/ saucy/main linux-image-extra-3.11.0-12-generic i386 3.11.0-12.19 [33.5 MB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ saucy/main indicator-sound i386 12.10.2+13.10.20131011-0ubuntu1 [55.7 kB]
Fetched 43.9 MB in 10min 23s (70.4 kB/s)                                                           
(Reading database ... 174913 files and directories currently installed.)
Preparing to replace bash-completion 1:2.0-1ubuntu3 (using .../bash-completion_1%3a2.0-1ubuntu3_all.deb) ...
Unpacking replacement bash-completion ...
Preparing to replace cheese-common 3.8.3-0ubuntu1 (using .../cheese-common_3.8.3-0ubuntu1_all.deb) ...
Unpacking replacement cheese-common ...
Preparing to replace gnumeric-doc 1.12.6-1 (using .../gnumeric-doc_1.12.6-1_all.deb) ...
Unpacking replacement gnumeric-doc ...
Preparing to replace linux-image-extra-3.11.0-12-generic 3.11.0-12.19 (using .../linux-image-extra-3.11.0-12-generic_3.11.0-12.19_i386.deb) ...
Unpacking replacement linux-image-extra-3.11.0-12-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
Preparing to replace indicator-sound 12.10.2+13.10.20131011-0ubuntu1 (using .../indicator-sound_12.10.2+13.10.20131011-0ubuntu1_i386.deb) ...
Unpacking replacement indicator-sound ...
Processing triggers for man-db ...
Processing triggers for libglib2.0-0:i386 ...
No such key 'auto-launch' in schema 'com.ubuntu.update-notifier' as specified in override file '/usr/share/glib-2.0/schemas/20_xubuntu-default-settings.gschema.override'; ignoring override for this key.
Processing triggers for hicolor-icon-theme ...
Setting up bash-completion (1:2.0-1ubuntu3) ...
Setting up cheese-common (3.8.3-0ubuntu1) ...
Setting up gnumeric-doc (1.12.6-1) ...
Setting up linux-image-extra-3.11.0-12-generic (3.11.0-12.19) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Not updating initrd symbolic links since we are being updated/reinstalled 
(3.11.0-12.19 was configured last, according to dpkg)
Not updating image symbolic links since we are being updated/reinstalled 
(3.11.0-12.19 was configured last, according to dpkg)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
run-parts: executing /etc/kernel/postinst.d/dkms 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
update-initramfs: Generating /boot/initrd.img-3.11.0-12-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.11.0-12-generic /boot/vmlinuz-3.11.0-12-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.11.0-14-generic
Found initrd image: /boot/initrd.img-3.11.0-14-generic
Found linux image: /boot/vmlinuz-3.11.0-12-generic
Found initrd image: /boot/initrd.img-3.11.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done
Setting up indicator-sound (12.10.2+13.10.20131011-0ubuntu1) ...

अंत में, मैंने यह सुनिश्चित करने के लिए जाँच की कि कोई भ्रष्ट फाइल न रहे:

$ sudo debsums -c

इस कमांड से कोई आउटपुट नहीं था, जिसका अर्थ है कि कोई त्रुटि नहीं मिली थी। :-)

एक अंतिम नोट: आपको यह सुनिश्चित करने के लिए अपने पैकेजों की कॉन्फिग फाइलों की जांच करनी चाहिए कि वे ठीक हैं। यह और अधिक कठिन हो सकता है क्योंकि कॉन्फ़िगर फाइलें अक्सर बदलती हैं, और परिवर्तन वैध हैं, इसलिए आपको यह निर्धारित करने के लिए प्रत्येक परिवर्तित कॉन्फ़िगरेशन फ़ाइल का मैन्युअल रूप से निरीक्षण करना होगा कि क्या यह वास्तव में भ्रष्ट है या नहीं। यह है कि आप कैसे परिवर्तित फ़ाइलों की एक सूची प्राप्त करते हैं:

$ sudo debsums -as
debsums: changed file /etc/gnome/defaults.list (from desktop-file-utils package)
debsums: changed file /etc/default/rcS (from initscripts package)
debsums: changed file /etc/subuid (from login package)
debsums: changed file /etc/subgid (from login package)
debsums: changed file /etc/sudoers (from sudo package)

मेरे पास न केवल फाइलें दूषित हैं बल्कि फाइलें भी गायब हैं। जब मैं इसे पुनः प्राप्त करने की कोशिश करता हूं, तो इसे निरस्त कर दिया जाता है क्योंकि dpkg त्रुटि देता है कि एक फाइल गायब है (फेसपालम)। उपयुक्त के साथ ही हटाएं, त्रुटि क्योंकि फ़ाइल गायब है।
मार्क जेरोनिमस

यदि आपके पास 1 से अधिक है। यह गुम फ़ाइल के लिए भी काम करता है। debsums -c | grep -P -o '/.*?\s' | xargs dpkg -S | cut -d : -f 1 | xargs apt-get install --reinstall
mikeytown2

11

पेनिविज द्वारा दी गई स्क्रिप्ट दूषित फ़ाइलों के लिए बहुत अच्छा काम करती है, लेकिन लापता फ़ाइलों के साथ पैकेजों का ध्यान नहीं रखती है, क्योंकि डिस्बम्स उन्हें stderr को रिपोर्ट करते हैं। अनुपलब्ध फ़ाइलों के साथ संकुल को पुनः स्थापित करने के लिए, इसने मेरे लिए काम किया:

xargs -rd '\n' -a <(sudo debsums -c 2>&1 | cut -d " " -f 4 | sort -u | xargs -rd '\n' -- dpkg -S | cut -d : -f 1 | sort -u) -- sudo apt-get install -f --reinstall --

3

इस सवाल का जवाब कहीं और दिया गया है:

क्या उबंटू की पवित्रता की जाँच है? : पैकेज डीबसम एमडी 5 हैश की गणना कर सकते हैं और डेब पैकेज के खिलाफ तुलना कर सकते हैं।

क्या पैकेज प्रबंधक के माध्यम से पुन : स्थापित करने का एक सुरक्षित तरीका है : हां, लेकिन अनुशंसित नहीं है।


यदि आपका उत्तर मूल रूप से किसी अन्य प्रश्न का संदर्भ है, तो इस प्रश्न को दूसरे के डुप्लिकेट के रूप में फ़्लैग करना बेहतर होगा । उत्तर के लिए वोट देना न भूलें जो आपको उपयोगी लगा!
मेलेबियस

-1

कुछ बैश स्क्रिप्टिंग के साथ dpkg प्रोग्राम का उपयोग करना आपके लिए इसके लिए सक्षम होना चाहिए। यदि कोई व्यक्ति "दुर्भावनापूर्ण" फ़ाइलों के "साफ़" संस्करणों को प्रतिस्थापित करता है तो केवल चेतावनी ही होगी। उसके लिए आपको एक प्राचीन पैकेज से वैध एमडी 5 चेकसम प्राप्त करना होगा। वैसे भी, यहां शेल कोड है जिसे आप प्राप्त करना चाहते हैं:

#!/bin/sh
PACKAGE_NAME="xterm"
for i in `sudo dpkg -L ${PACKAGE_NAME}`
do
    if ! [ -e $i ]; then
            echo "$i is a missing file in the $PACKAGE_NAME package."
    fi
done

स्क्रिप्ट तभी प्रिंट आउट करेगी जब पैकेज में परिभाषित कोई फ़ाइल या निर्देशिका गायब थी। इसके अलावा आपको 'PACKAGE_NAME' चर को उस पैकेज से बदलना होगा जिसे आप निरीक्षण करना चाहते हैं। उम्मीद है की यह मदद करेगा।


1
मुझे यकीन नहीं है कि यह सभी मामलों में काम करेगा। dpkg -Lवास्तव में सूची क्या है ? जवाब के रूप में कहीं और debsums एक अच्छा विकल्प की तरह दिखता है।
Jan
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.