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

When I run

sudo apt install sysstat

I get the following error message on Debian/Ubuntu Linux:

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

Can you paste full command and it’s output?

For “sar” command I run:

sudo apt install sysstat
[sudo] password for milad: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sysstat is already the newest version (11.2.0-1).
0 upgraded, 0 newly installed, 0 to remove and 4 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 sysstat (11.2.0-1) ...
dpkg: error processing package sysstat (--configure):
 subprocess installed post-installation script returned error exit status 10
Errors were encountered while processing:
 sysstat
E: Sub-process /usr/bin/dpkg returned an error code (1)

Cd to following dir:

cd /var/lib/dpkg/info/
ls -l *sysstat*

What output do you get?

sudo apt clean
sudo apt autoclean
sudo apt install sysstat
ls -l *sysstat*

Outputs

-rw-r--r-- 1 root root   113 Jan 28  2016 sysstat.conffiles
-rwxr-xr-x 1 root root   785 Jan 28  2016 sysstat.config
-rw-r--r-- 1 root root  1646 Jun 18 09:22 sysstat.list
-rw-r--r-- 1 root root  2452 Jan 28  2016 sysstat.md5sums
-rwxr-xr-x 1 root root  2644 Jan 28  2016 sysstat.postinst
-rwxr-xr-x 1 root root   936 Jan 28  2016 sysstat.postrm
-rwxr-xr-x 1 root root   110 Jan 28  2016 sysstat.prerm
-rw-r--r-- 1 root root 18220 Jan 28  2016 sysstat.templates

did’nt work…but tnx

Edit the file sudo vi sysstat.postinst and you will see something as follows:

set -e

Delete that line and try installing it again with

sudo apt install sysstat
sudo apt install sysstat

Reading package lists... Done
Building dependency tree       
Reading state information... Done
sysstat is already the newest version (11.2.0-1).
0 upgraded, 0 newly installed, 0 to remove and 4 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 sysstat (11.2.0-1) ...
update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode

and when execute command ’ sar ’

Cannot open /var/log/sysstat/sa19: No such file or directory
Please check if data collecting is enabled

Turn on service

systemctl enable sysstat
systemctl start sysstat.service
systemctl status sysstat.service

It takes time to collect data:

sar -u 3 10

tnx alot…:heart_eyes:


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki