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
when you're a little too careless about virtualizing your domain controllers, cloning, migrating, backing up and restoring, returning from vacation… Read More
systemd is new service manager for linux. it's a replacement for all previous init systems (sysv/sysvinit & ubuntu's upstart) and… Read More