安装软件包时出现奇怪的问题

安装软件包时出现奇怪的问题

我不知道昨天我的 ubuntu 16.04 发生了什么,我对 /usr/lib 的权限做了一些事情,之后 sudo 不起作用,所以我通过进入恢复并使用在 stackoverflow 中找到的一些命令来修复 sudo。

现在我看到一些未知的错误,我不知道如何修复。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
libunity-scopes1.0
0 upgraded, 0 newly installed, 1 to remove and 19 not upgraded.
8 not fully installed or removed.
After this operation, 2,849 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 334690 files and directories currently 
installed.)
Removing libunity-scopes1.0:amd64 (1.0.4+16.04.20160402.4-0ubuntu1) 
...
Traceback (most recent call last):
File "/usr/bin/click", line 31, in <module>
import gi
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
<module>
from . import _gi
ImportError: cannot import name '_gi'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, 
in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in 
<module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
<module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 
<module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 
23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in 
<module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
File "/usr/bin/click", line 31, in <module>
import gi
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
<module>
from . import _gi
ImportError: cannot import name '_gi'
dpkg: error processing package libunity-scopes1.0:amd64 (--remove):
subprocess installed pre-removal script returned error exit status 1
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Errors were encountered while processing:
libunity-scopes1.0:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑后

  dpkg --configure -a
     dpkg: error: requested operation requires superuser privilege


             Setting up click (0.4.43+16.04.20170613-0ubuntu1) ...
    Traceback (most recent call last):
      File "/usr/bin/click", line 31, in <module>
        import gi
      File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
        from . import _gi
    ImportError: cannot import name '_gi'
    Error in sys.excepthook:
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
        from apport.fileutils import likely_packaged, get_recent_crashes
      File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
        from apport.report import Report
      File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
        import apport.fileutils
      File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
        from apport.packaging_impl import impl as packaging
      File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
        import apt
      File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
        import apt_pkg
    ModuleNotFoundError: No module named 'apt_pkg'

    Original exception was:
    Traceback (most recent call last):
      File "/usr/bin/click", line 31, in <module>
        import gi
         File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
        <module>
         from . import _gi
         ImportError: cannot import name '_gi'
         dpkg: error processing package click (--configure):
         subprocess installed post-installation script returned error exit 
        status 1
         Setting up click-apparmor (0.3.13.1) ...
        Traceback (most recent call last):
        File "/usr/bin/click", line 31, in <module>
        import gi
        File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in  
        <module>
        from . import _gi
        ImportError: cannot import name '_gi'
        Error in sys.excepthook:
        Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 
        63, in apport_excepthook
        from apport.fileutils import likely_packaged, get_recent_crashes
        File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, 
        in <module>
        from apport.report import Report
        File "/usr/lib/python3/dist-packages/apport/report.py", line 30, 
        in 
        <module>
        import apport.fileutils
         File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 
         23, in <module>
         from apport.packaging_impl import impl as packaging
          File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", 
          line 23, in <module>
         import apt
         File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, 
         in <module>
         import apt_pkg
         ModuleNotFoundError: No module named 'apt_pkg'

          Original exception was:
         Traceback (most recent call last):
         File "/usr/bin/click", line 31, in <module>
         import gi
          File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, 
          in <module>
          from . import _gi
          ImportError: cannot import name '_gi'
          dpkg: error processing package click-apparmor (--configure):
          subprocess installed post-installation script returned error 
          exit status 1
         Setting up url-dispatcher:amd64 (0.1+16.04.20151110-0ubuntu2) ...
         Traceback (most recent call last):
         File "/usr/bin/click", line 31, in <module>
         import gi
         File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
        <module>
        from . import _gi
         ImportError: cannot import name '_gi'
         Error in sys.excepthook:
         Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/apport_python_hook.py", 
         line 63, in apport_excepthook
         from apport.fileutils import likely_packaged, get_recent_crashes
         File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, 
         in <module>
         from apport.report import Report
         File "/usr/lib/python3/dist-packages/apport/report.py", line 30, 
         in <module>
         import apport.fileutils
         File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 
         23, in <module>
         from apport.packaging_impl import impl as packaging
         File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", 
         line 23, 
         in <module>
         import apt
         File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, 
         in 
         <module>
         import apt_pkg
         ModuleNotFoundError: No module named 'apt_pkg'

         Original exception was:
         Traceback (most recent call last):
         File "/usr/bin/click", line 31, in <module>
         import gi
         File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
        <module>
        from . import _gi
        ImportError: cannot import name '_gi'
        dpkg: error processing package url-dispatcher:amd64 (-- 
        configure):
        subprocess installed post-installation script returned error 
        exit status 1
        dpkg: dependency problems prevent configuration of ubuntu-app-l 
        aunch:
        ubuntu-app-launch depends on click-apparmor; however:
        Package click-apparmor is not configured yet.

       dpkg: error processing package ubuntu-app-launch (--configure):
       dependency problems - leaving unconfigured
       dpkg: dependency problems prevent configuration of ubuntu-system- 
       settings:
       ubuntu-system-settings depends on click | ubuntu-snappy-cli; 
       however:
       Package click is not configured yet.
       Package ubuntu-snappy-cli is not installed.

       dpkg: error processing package ubuntu-system-settings (-- 
       configure):
       dependency problems - leaving unconfigured
       dpkg: dependency problems prevent configuration of ubuntu-app- 
       launch-tools:
       ubuntu-app-launch-tools depends on ubuntu-app-launch (= 
       0.5+15.10.20150817-0ubuntu3); however:
       Package ubuntu-app-launch is not configured yet.

       dpkg: error processing package ubuntu-app-launch-tools (-- 
       configure):
       dependency problems - leaving unconfigured
       dpkg: dependency problems prevent configuration of ubuntu-system- 
       settings-online-accounts:
       ubuntu-system-settings-online-accounts depends on ubuntu-system- 
       settings; 
       however:
      Package ubuntu-system-settings is not configured yet.

      dpkg: error processing package ubuntu-system-settings-online- 
      accounts (-- 
     configure):
     dependency problems - leaving unconfigured
     Errors were encountered while processing:
     click
     click-apparmor
     url-dispatcher:amd64
     ubuntu-app-launch
     ubuntu-system-settings
     ubuntu-app-launch-tools
     ubuntu-system-settings-online-accounts

我发出的命令的历史记录,此后一切都出错了,主要罪魁祸首

sudo chown -R /usr/lib
sudo chown -R `id -un` /usr/lib
sudo chown -R `id -un` /usr/bin 

我在上述命令之后执行的其他命令

 npm install -g vue-cli
 sudo npm install -g vue-cli
 chown root:root /usr/bin/sudo
 sudo chown root:root /usr/bin/sudo

 su root
 chmod 644 /usr/lib/sudo/sudoers.so
 chown -R root /usr/lib/sudo
 sud ochown -R root /usr/lib/sudo
 sudo chown -R root /usr/lib/sudo
 pkexec su
 sudo apt-get update
 pkexec chmod u+s,g-x /usr/bin/sudo
 sudo echo "sudo works again! Yay! :D"
 sudo -s
 su -
 sudo -i
 ls -ld /etc
 pkexec chmod 755 -R /usr/lib

之后我的 wifi 就坏了

   sudo lshw -class network
   sudo service network-manager restart
   killall nm-applet && nm-applet &
   sudo systemctl restart network-manager
   sudo systemctl start network-manager
   sudo rm /var/lib/apt/lists/lock
   sudo rm /var/cache/apt/archives/lock
   sudo rm /var/lib/dpkg/lock
   sudo apt-get install rfkill
   rfkill unblock all
   sudo nano /var/lib/NetworkManager/NetworkManager.state
   rfkill list
   sudo chown -R $USER /usr/lib/
   chown -R root /usr/lib
   sudo chown -R root /usr/lib
   sudo
   exit
   pcd
   cd
   pkexec chmod 755 /etc
   pkexec chmod 755 /usr/lib

之后我的桌面和所有地方的字体都变大了

sudo apt install unity8-desktop-session-mir
sudo apt-get -f install
sudo apt install gnome-tweak-tool
sudo apt-get remove unity8
dpkg --configure -a
dpkg --configure -a\napt autoremove\napt -f install\napt update\napt 
upgrade
sudo apt-get install -f
sudo apt autoremove
sudo rm /etc/apt/sources.list
sudo software-properties-gtk
sudo apt-get autoremove
apt-get -f install
sudo apt-get -f install
sudo apt-get clean
sudo apt-get update
sudo dpkg --audit | more
sudo dpkg --configure click click-apparmor
sudo dpkg --configure -a
sudo apt-get install -f

相关内容