处理时遇到错误:postfix E:子进程 /usr/bin/dpkg 返回错误代码 (1)

处理时遇到错误:postfix E:子进程 /usr/bin/dpkg 返回错误代码 (1)

将 Ubuntu 18.04 更新至 20.04 再更新至 21.04 后,我遇到了这个问题,无法安装也无法卸载软件包。

[sudo] password for commaderwolfer: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
git is already the newest version (1:2.32.0-1~ppa0~ubuntu18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up postfix (3.5.6-1) ...

Postfix (main.cf) configuration was not changed.  If you need to make changes, 
edit /etc/postfix/main.cf (and others) as needed.  To view Postfix 
configuration values, see postconf(1).

After modifying main.cf, be sure to run 'systemctl reload postfix'.

Running newaliases
newaliases: warning: valid_hostname: misplaced delimiter: CommanderWolfer..
newaliases: fatal: file /etc/postfix/main.cf: parameter myhostname: bad parameter value: CommanderWolfer..
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 75
Processing triggers for libc-bin (2.33-0ubuntu5) ...
Errors were encountered while processing:
postfix
E: Sub-process /usr/bin/dpkg returned an error code (1)```

after running sudo dpkg --configure -a

sudo dpkg --configure -a
Setting up postfix (3.5.6-1) ...

Postfix (main.cf) configuration was not changed.  If you need to make changes, 
edit /etc/postfix/main.cf (and others) as needed.  To view Postfix 
configuration values, see postconf(1).

After modifying main.cf, be sure to run 'systemctl reload postfix'.

Running newaliases
newaliases: warning: valid_hostname: misplaced delimiter: CommanderWolfer..
newaliases: fatal: file /etc/postfix/main.cf: parameter myhostname: bad parameter value: CommanderWolfer..
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 75
Processing triggers for libc-bin (2.33-0ubuntu5) ...
Errors were encountered while processing:
 postfix

答案1

E: Sub-process /usr/bin/dpkg returned an error code (1)

上述错误消息可能是由于 dpkg 数据库损坏或软件包损坏(postfix)造成的。使用以下命令解决。打开终端执行命令。

使用命令重新配置 dpkg 数据库

sudo dpkg --configure -a

修复损坏的软件包

sudo apt install--fix-broken

上述命令可能会解决问题。如果不能,请尝试在清除旧后重新安装 postfix。清除旧后缀

sudo apt remove --purge postfix

使用命令清理旧的和不必要的包

sudo apt clean
sudo apt autoremove

更新和升级软件包

sudo apt update
sudo apt upgrade

重新安装包

sudo apt-get install postfix

相关内容