sudo apt-get 安装 snmp时command-not-found 和groupadd: cannot open /etc/group问题处理

在Ubuntu 14.04 LTS上尝试安装SNMPd及其相关包时遇到错误,错误提示涉及编码问题。首先,尝试通过修改profile文件解决,但未成功。然后,通过手动逐个安装命令解决了问题。接着,在第二次安装过程中又出现权限错误,原因是'/etc/group'等文件被属性锁定。通过使用`chattr`命令解除权限锁定后,成功安装SNMPd服务并确认其正在运行。
摘要由CSDN通过智能技术生成

1、准备在ubuntu上安装snmp进行管理 ,安装时就出错了:

root@**:~# sudo apt-get install snmpd snmp snmp-mibs-downloader
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.4.3 final 0
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
Exception information:

'utf-8' codec can't encode character '\udca0' in position 4: surrogates not allowed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 90, in main
    if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 265, in advise
    packages = self.getPackages(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 157, in getPackages
    result.update([(pkg, db.component) for pkg in db.lookup(command)])
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 85, in lookup
    result = self.db.lookup(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 41, in lookup
    key = key.encode('utf-8')
UnicodeEncodeError: 'utf-8' codec can't encode character '\udca0' in position 4: surrogates not allowed
root@CCWKtj001:~# apt-get install snmpd snmp snmp-mibs-downloader     
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.4.3 final 0
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
Exception information:

'utf-8' codec can't encode character '\udca0' in position 7: surrogates not allowed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
            if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 265, in advise
    packages = self.getPackages(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 157, in getPackages
    result.update([(pkg, db.component) for pkg in db.lookup(command)])
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 85, in lookup
    result = self.db.lookup(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 41, in lookup
    key = key.encode('utf-8')
UnicodeEncodeError: 'utf-8' codec can't encode character '\udca0' in position 7:

解决方法:

网上查看说是改了profile文件导致,但是按照网上的方法改为utf-8也发现解决不了问题,但是直接用手搞命令在系统中单个安装没有问题。暂不知道原因。

2、再次安装时报错如下:

root@CCWKtj001:~# apt-get install snmpd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libmysqlclient18 mysql-common
The following NEW packages will be installed:
  libmysqlclient18 mysql-common snmpd
0 upgraded, 3 newly installed, 0 to remove and 228 not upgraded.
Need to get 684 kB of archives.
After this operation, 3,867 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
WARNING: The following packages cannot be authenticated!
  mysql-common libmysqlclient18 snmpd
Install these packages without verification? [y/N] y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.62-0ubuntu0.14.04.1 [12.6 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.62-0ubuntu0.14.04.1 [598 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main snmpd amd64 5.7.2~dfsg-8.1ubuntu3.3 [73.4 kB]
Fetched 684 kB in 2s (332 kB/s) 
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 66036 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.5.62-0ubuntu0.14.04.1_all.deb ...
Unpacking mysql-common (5.5.62-0ubuntu0.14.04.1) ...
Selecting previously unselected package libmysqlclient18:amd64.
Preparing to unpack .../libmysqlclient18_5.5.62-0ubuntu0.14.04.1_amd64.deb ...
Unpacking libmysqlclient18:amd64 (5.5.62-0ubuntu0.14.04.1) ...
Selecting previously unselected package snmpd.
Preparing to unpack .../snmpd_5.7.2~dfsg-8.1ubuntu3.3_amd64.deb ...
Unpacking snmpd (5.7.2~dfsg-8.1ubuntu3.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up mysql-common (5.5.62-0ubuntu0.14.04.1) ...
Setting up libmysqlclient18:amd64 (5.5.62-0ubuntu0.14.04.1) ...
Setting up snmpd (5.7.2~dfsg-8.1ubuntu3.3) ...
groupadd: cannot open /etc/group
adduser: `/usr/sbin/groupadd -g 115 snmp' returned error code 10. Exiting.
dpkg: error processing package snmpd (--configure):
 subprocess installed post-installation script returned error exit status 1
E: Sub-process /usr/bin/dpkg returned an error code (1)

失败原因:

groupadd: cannot open /etc/group 因为有属性锁定了权限,需要放开权限:

进行以下操作:

root@**:~# lsattr /etc/group
----i--------e-- /etc/group
root@**:~# lsattr /etc/gshadow
----i--------e-- /etc/gshadow
root@*:~# lsattr /etc/shadow
----i--------e-- /etc/shadow
root@*:~# lsattr /etc/passwd
----i--------e-- /etc/passwd
root@*:~#  chattr -i /etc/gshadow

root@*:~# 
root@*:~#  chattr -i /etc/shadow
root@*:~# 
root@*:~#  chattr -i /etc/group

root@*:~# 
root@*:~#  chattr -i /etc/passwd

再次安装成功!

root@**:~# service snmpd status
 * snmpd is running

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值