无法升级软件

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
spreadtrum
帖子: 51
注册时间: 2016-04-27 15:45
系统: Ubuntu 16.04

无法升级软件

#1

帖子 spreadtrum » 2016-05-17 13:56

第一步:sudo apt-get update
第二步:sudo apt-get dist-upgrade
结果弹出以下:

root@test:~# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 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 sudo (1.8.9p5-1ubuntu1.2) ...
chown: changing ownership of ‘/etc/sudoers’: Operation not permitted
dpkg: error processing package sudo (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
sudo
E: Sub-process /usr/bin/dpkg returned an error code (1)

求高人指点小白 :Adore
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 无法升级软件

#2

帖子 vickycq » 2016-05-17 14:10

spreadtrum 写了: 结果弹出以下:
Setting up sudo (1.8.9p5-1ubuntu1.2) ...
chown: changing ownership of ‘/etc/sudoers’: Operation not permitted
先查看 sudoers 现状

代码: 全选

ls -l /etc/sudoers
将结果全部复制贴上来

再尝试

代码: 全选

pkexec chmod 0440 /etc/sudoers
pkexec chown root:root /etc/sudoers
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
spreadtrum
帖子: 51
注册时间: 2016-04-27 15:45
系统: Ubuntu 16.04

Re: 无法升级软件

#3

帖子 spreadtrum » 2016-05-17 14:21

vickycq 写了:
spreadtrum 写了: 结果弹出以下:
Setting up sudo (1.8.9p5-1ubuntu1.2) ...
chown: changing ownership of ‘/etc/sudoers’: Operation not permitted
先查看 sudoers 现状

代码: 全选

ls -l /etc/sudoers
将结果全部复制贴上来

再尝试

代码: 全选

pkexec chmod 0440 /etc/sudoers
pkexec chown root:root /etc/sudoers

root@test:~# ls -l /etc/sudoers
-r--r----- 1 root root 1112 4月 16 2014 /etc/sudoers
root@test:~# pkexec chmod 0440 /etc/sudoers
/bin/chmod: changing permissions of ‘/etc/sudoers’: Operation not permitted
root@test:~# pkexec chown root:root /etc/sudoers
/bin/chown: changing ownership of ‘/etc/sudoers’: Operation not permitted
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 无法升级软件

#4

帖子 vickycq » 2016-05-17 17:04

spreadtrum 写了: root@test:~# ls -l /etc/sudoers
-r--r----- 1 root root 1112 4月 16 2014 /etc/sudoers
执行以下命令将结果全部复制贴上来

代码: 全选

lsattr /etc/sudoers
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
spreadtrum
帖子: 51
注册时间: 2016-04-27 15:45
系统: Ubuntu 16.04

Re: 无法升级软件

#5

帖子 spreadtrum » 2016-05-17 17:53

vickycq 写了:
spreadtrum 写了: root@test:~# ls -l /etc/sudoers
-r--r----- 1 root root 1112 4月 16 2014 /etc/sudoers
执行以下命令将结果全部复制贴上来

代码: 全选

lsattr /etc/sudoers
执行结果如下:
test@test:~$ lsattr /etc/sudoers
lsattr: Permission denied While reading flags on /etc/sudoers
spreadtrum
帖子: 51
注册时间: 2016-04-27 15:45
系统: Ubuntu 16.04

Re: 无法升级软件

#6

帖子 spreadtrum » 2016-05-17 17:56

执行 cat /etc/group | grep sudo,执行结果如下:

test@test:~$ cat /etc/group | grep sudo
sudo:x:27:test
spreadtrum
帖子: 51
注册时间: 2016-04-27 15:45
系统: Ubuntu 16.04

Re: 无法升级软件

#7

帖子 spreadtrum » 2016-05-17 18:00

最早我安装的是12.04,执行过以下一个.sh文件,功能是使用sudo命令不用再输密码,会不会是这个有影响
#!/bin/bash
chattr -i /etc/sudoers
chmod 777 /etc/sudoers
rm -rf /etc/sudoers
rsync -av --progress /mnt/IT/software/ubuntu/1204Ubuntu/sudoers /etc/
chmod 0440 /etc/sudoers
chattr +i /etc/sudoers
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 无法升级软件

#8

帖子 vickycq » 2016-05-17 18:06

spreadtrum 写了:以下一个.sh文件会不会是这个有影响chattr +i /etc/sudoers
是的。/etc/sudoers 被赐予免死金牌 (immutable)
需要设法执行 chattr -i /etc/sudoers
如果 root 都不能 chattr -i 只好动用 RecoveryMode 或单用户模式
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
rosynirvana
帖子: 893
注册时间: 2011-02-14 17:46

Re: 无法升级软件

#9

帖子 rosynirvana » 2016-05-17 18:34

:Hehe
spreadtrum
帖子: 51
注册时间: 2016-04-27 15:45
系统: Ubuntu 16.04

Re: 无法升级软件

#10

帖子 spreadtrum » 2016-05-19 8:53

vickycq 写了:
spreadtrum 写了:以下一个.sh文件会不会是这个有影响chattr +i /etc/sudoers
是的。/etc/sudoers 被赐予免死金牌 (immutable)
需要设法执行 chattr -i /etc/sudoers
如果 root 都不能 chattr -i 只好动用 RecoveryMode 或单用户模式
root下执行chattr -i /etc/sudoers,没有报错

root@test:~# chattr -i /etc/sudoers
root@test:~# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
fcitx-libs-gclient libgif4 libgnome-desktop-2-17 libmono-web4.0-cil
linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
libcgi-fast-perl libcgi-pm-perl libfcgi-perl
The following packages will be upgraded:
libparse-debianchangelog-perl
1 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 278 kB of archives.
After this operation, 604 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.zju.edu.cn/ubuntu xenial/main amd64 libcgi-pm-perl all 4.26-1 [185 kB]
Get:2 http://mirrors.zju.edu.cn/ubuntu xenial/main amd64 libfcgi-perl amd64 0.77-1build1 [32.3 kB]
Get:3 http://mirrors.zju.edu.cn/ubuntu xenial/main amd64 libcgi-fast-perl all 1:2.10-1 [10.2 kB]
Get:4 http://mirrors.zju.edu.cn/ubuntu xenial/main amd64 libparse-debianchangelog-perl all 1.2.0-8 [50.4 kB]
Fetched 278 kB in 0s (381 kB/s)
Selecting previously unselected package libcgi-pm-perl.
(Reading database ... 252668 files and directories currently installed.)
Preparing to unpack .../libcgi-pm-perl_4.26-1_all.deb ...
Unpacking libcgi-pm-perl (4.26-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../libfcgi-perl_0.77-1build1_amd64.deb ...
Unpacking libfcgi-perl (0.77-1build1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../libcgi-fast-perl_1%3a2.10-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.10-1) ...
Preparing to unpack .../libparse-debianchangelog-perl_1.2.0-8_all.deb ...
Unpacking libparse-debianchangelog-perl (1.2.0-8) over (1.2.0-1ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up sudo (1.8.16-0ubuntu1.1) ...
Removing obsolete conffile /etc/init.d/sudo ...
Setting up ubuntu-minimal (1.361) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libparse-debianchangelog-perl (1.2.0-8) ...
root@test:~#

更新完成

BTW,啥叫免死金牌
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 无法升级软件

#11

帖子 poloshiao » 2016-05-19 9:51

啥叫免死金牌
http://manpages.ubuntu.com/manpages/xen ... ttr.1.html
chattr - change file attributes on a Linux file system
The following attributes are read-only, and may be listed by lsattr(1) but not modified by chattr: compression error (E), huge file (h), indexed directory (I), inline data (N), compression raw access (X), and compressed dirty file (Z).

read-only 只能讀取 無法編輯 / 刪除 / 移動 / ...
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 无法升级软件

#12

帖子 vickycq » 2016-05-19 9:59

Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
4870
帖子: 1
注册时间: 2018-10-30 15:57
系统: Ubuntu 14.04

Re: 无法升级软件

#13

帖子 4870 » 2018-10-30 16:01

分享一个如果没有root权限执行如下命令的方法
chattr -i /etc/sudoers

如果执行以上命令报错
chattr: Permission denied while reading flags on /etc/sudoers


参考blog.csdn.net/heray1990/article/details/47803541
可以执行如下操作,然后再执行apt-get upgrade也不会报错了。

$ sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/info_old/
$ sudo mkdir /var/lib/dpkg/info/
$ sudo apt-get update
...
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up sudo (1.8.9p5-1ubuntu1.4) ...

$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old/
$ sudo rm -rf /var/lib/dpkg/info
$ sudo mv /var/lib/dpkg/info_old/ /var/lib/dpkg/info/
回复