5

I have by a mistake written this command on a CentOS server

xargs rpm -e|rpm -qa|grep test11

where I meant

rpm -qa|grep test11|xargs rpm -e

which should uninstall all packages matching "test11".

Can someone figure out what the first command do? I am afraid that it un-install ALL packages =(

Sandra
  • 9,973
  • 37
  • 104
  • 160

2 Answers2

7

No worries, it just executed 'rpm -e' which would not remove any package.

[root@web420 ~]# rpm -e
rpm: no packages given for erase

BTW, for verifying you have not removed all packages you could just run

rpm -qa

and see the list of installed packages.

grateful.dev
  • 388
  • 1
  • 2
  • 8
  • 1
    As long as you specified no input to xargs "rpm -e" should bail out with an error message and the rest of the chain "does nothing" (at least in terms of modification) – voretaq7 Feb 08 '10 at 18:23
  • 4
    For the future, specify `--test` to potentially-destructive RPM commands (like `-e`): It will tell you what it's going to do without actually changing your system so you can avoid unplesant surprises. – voretaq7 Feb 08 '10 at 18:24
  • @voretaq7 great point! – grateful.dev Feb 08 '10 at 18:29
  • @voretaq7: Excellent trick. I will clearly use that from now on =) – Sandra Feb 10 '10 at 12:11
  • By the way: if you removed all packages from RHEL, it wouldn't run at all! Everything is a package, right down to the filesystem layout. – Mei Jan 13 '11 at 22:25
0

The first command you gave will not remove all packages (phew!). Here is the command you gave:

xargs rpm -e|rpm -qa|grep test11

The command rpm -e does remove RPMs, but with xargs listed without a pipe, it takes its input from the terminal and waits for your input. The second command would essentially replace the output from rpm -e with rpm -qa (all RPMs) then find the RPM test11 (if it exists).

Not a command string worth running, but certainly one worth understanding...

Mei
  • 4,560
  • 8
  • 44
  • 53