Package-Management

無法升級或修復(Kali)

  • April 17, 2021
┌──(istiak㉿kali)-[~]
└─$ sudo apt-get upgrade
[sudo] password for istiak: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
nodejs : Depends: libnode72 (= 12.21.0~dfsg-1) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

當我嘗試修復

┌──(istiak㉿kali)-[~]
└─$ sudo apt --fix-broken install                                                                                                                                  100 ⨯
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
 libjs-highlight.js nodejs-doc xdg-desktop-portal-gtk
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
 nodejs
The following packages will be upgraded:
 nodejs
1 upgraded, 0 newly installed, 0 to remove and 56 not upgraded.
Need to get 0 B/24.6 MB of archives.
After this operation, 119 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 339678 files and directories currently installed.)
Preparing to unpack .../nodejs_14.16.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (14.16.1-deb-1nodesource1) over (12.21.0~dfsg-1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_14.16.1-deb-1nodesource1_amd64.deb (--unpack):
trying to overwrite '/usr/share/doc/nodejs/api/cli.json.gz', which is also in package nodejs-doc 12.21.0~dfsg-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_14.16.1-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

當我安裝 debian 軟體包時。

┌──(istiak㉿kali)-[~]
└─$ sudo dpkg -i /var/cache/apt/archives/nodejs_14.16.1-deb-1nodesource1_amd64.deb
[sudo] password for istiak: 
(Reading database ... 339678 files and directories currently installed.)
Preparing to unpack .../nodejs_14.16.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (14.16.1-deb-1nodesource1) over (12.21.0~dfsg-1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_14.16.1-deb-1nodesource1_amd64.deb (--install):
trying to overwrite '/usr/share/doc/nodejs/api/cli.json.gz', which is also in package nodejs-doc 12.21.0~dfsg-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_14.16.1-deb-1nodesource1_amd64.deb

/etc/apt/

┌──(istiak㉿kali)-[/etc/apt]
└─$ ls
apt.conf.d   preferences.d  sources.list~   trusted.gpg
auth.conf.d  sources.list   sources.list.d  trusted.gpg.d

我沒有找到任何名為sources.d. 而且,sources.list.d是我擁有的目錄google-chrome.list nodesource.list

sources.list:

# See https://www.kali.org/docs/general-use/kali-linux-sources-list-
repositories/
deb http://http.kali.org/kali kali-rolling main contrib non-free

# Additional line for source packages
# deb-src http://http.kali.org/kali kali-rolling main contrib non-free

os-release:

┌──(istiak㉿kali)-[/etc/apt]
└─$ cat /etc/os-release      
PRETTY_NAME="Kali GNU/Linux Rolling"
NAME="Kali GNU/Linux"
ID=kali
VERSION="2021.1"
VERSION_ID="2021.1"
VERSION_CODENAME="kali-rolling"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="https://www.kali.org/"
SUPPORT_URL="https://forums.kali.org/"
BUG_REPORT_URL="https://bugs.kali.org/"

我也嘗試通過清潔(sudo apt clean)。我不知道現在該怎麼辦..?我無法安裝npm的原因。但是,我能夠update正確地……你可能會注意到我正在使用 Kali。版本為 2020.1。而且,我不是專家也不是中級。我對 Linux 有一些想法。

我發現了一些與我的問題相似的問題,但是沒有對我有用的答案。

  1. dpkg:錯誤處理存檔
  2. apt-get 升級期間錯誤處理包 mysql-community-server
  3. 處理時遇到錯誤:/var/cache/apt/archives/apport_2.20.1-0ubuntu2.6_all.deb

我正在閱讀文件。當我列印出來時:grep -v '#' /etc/apt/sources.list | sort -u

我的輸出實際上是匹配的。

從文件:

deb http://http.kali.org/kali kali-rolling main non-free contrib

我的輸出(我之前也添加了它。我想我在閱讀 Unix SE 或 askubuntu 中的一些答案後更新了分支〜我實際上忘記了。):

deb http://http.kali.org/kali kali-rolling main contrib non-free

“我認為這可能不是問題”。

您進行了離線安裝(例如在安裝過程中缺少網路連接)。

你已經切換了你的分支。

使用不同的(硬編碼)鏡像。

在安裝某些東西時,我實際上已經失去了很多次網路連接。從該文件中,我還列印了兩個命令。

cat /etc/apt/sources.list

我之前也給出了它的輸出。

sudo apt-cdrom add

實際上我沒有任何 cdrom,這就是它返回錯誤的原因。

E: 無法掛載光碟機。E: 使用預設掛載點無法自動檢測或找到任何 CD-ROM。

我按照@roaima 所說的做了。雖然我正面臨這個問題。然後,我直接再次嘗試升級。

sudo apt-get upgrade or, sudo apt upgrade

但是,我遇到了錯誤。然後,我想以 root 使用者身份執行這些命令(sudo su sudo也代表 root)。

sudo su
apt --fix-broken install
apt upgrade

現在,一切都在一一升級..

從中刪除google-chrome.list和。如果你很幸運,你沒有破壞太多的 Kali 發行版,這兩個命令會讓你回到正確的軌道上nodesource.list``/etc/apt/sources.d

apt update
apt full-upgrade

有關上下文,請閱讀 Kali 自己的關於儲存庫的文件,特別是標題為“非 Kali 儲存庫”的部分,

通過將 Kali 的儲存庫添加到非 Kali 作業系統(例如嘗試將 Kali 添加到 Ubuntu),這將大大增加您的系統無法工作的機會。它可能不會立即發生,但沒有任何警告,它可能會破裂。

引用自:https://unix.stackexchange.com/questions/645526