You can install packages using dpkg on Debian based systems such as Ubuntu. Dpkg is quite a useful command line tool. In addition to installing packages, dpkg also helps to remove packages and know the status of packages. While checking the status of packages using dpkg, you may come across the state rc.
rc corresponds to:
r: the package was marked for removal
c: the configuration files are currently present in the system
Click here for a full list
Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=================================-=====================-=====================-======================================================================= ii accountsservice 0.6.40-2ubuntu11.3 amd64 query and manipulate user account information ii acl 2.2.52-3 amd64 Access control list utilities
In nutshell, it means that the package is not completely removed. The configuration files are still present.
Let’s see all the packages marked as rc by dpkg:
dpkg --list |grep "^rc"
Let’s extract out the packages marked as rc:
dpkg --list |grep "^rc" | cut -d " " -f 3
Now let’s remove all the packages marked as rc:
dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge
(Reading database ... 109335 files and directories currently installed.) Removing letsencrypt (0.4.1-1) ... Purging configuration files for letsencrypt (0.4.1-1) ... Removing linux-image-4.4.0-92-generic (4.4.0-92.115) ... Purging configuration files for linux-image-4.4.0-92-generic (4.4.0-92.115) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-92-generic /boot/vmlinuz-4.4.0-92-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-92-generic /boot/vmlinuz-4.4.0-92-generic Removing linux-image-extra-4.4.0-92-generic (4.4.0-92.115) ... Purging configuration files for linux-image-extra-4.4.0-92-generic (4.4.0-92.115) ... Removing python-pbr (1.8.0-4ubuntu1) ... Purging configuration files for python-pbr (1.8.0-4ubuntu1) ...
Second letter -> current package state:
Third letter -> error state (you normally shouldn't see a third letter, but a space, instead):
xargs command is designed to construct argument lists and invoke other utility. xargs reads items from the standard input or pipes, delimited by blanks or newlines, and executes the command one or more times with any initial-arguments followed by items read from standard input. Blank lines on the standard input are ignored.
xargs functionality can be achieved using the backquote feature of shell. But, it offers more options. It can deal with blanks or special characters in file names easily. It is often used with find, grep and other commands.
For example following example will print 1 2 3 4 using xargs (echo command is default)
echo 1 2 3 4 | xargs echo
echo 1 2 3 4 | xargs
You can force xargs to use at most max-args arguments per command line. For example following will use first two argument per command:
echo 1 2 3 4 | xargs -n 2
Find all .bak files in or below the current directory and delete them.
find . -name "*.bak" -type f -print | xargs /bin/rm -f
Source & credit to: linuxprograms.wordpress.com
Have you ever wondered what life might be like if the Windows 10 OS somehow had a single folder that… Read More
There could be any number of reasons for needing to flash manufacturer stock OEM firmware on a Samsung Galaxy S9… Read More
Designing e-mail solutions on a large scale can be a complex and costly challenge for a business: you need to… Read More