How to reset tX2 to factory settings

My tx2 has too many libraries installed, now I want to reset it,how to do?

You would flash. If you wish to save what you have, then you could first clone the rootfs (takes a lot of time and disk space on the host PC). Clones cannot be used with different releases, but can be used as a backup if something goes wrong as a way to restore the same release.

The most recent version of L4T (Ubuntu with NVIDIA drivers) is R32.1 (there is a new release should be coming out in the near future, but no schedule) is R32.1. This is flashed by JetPack or SDK Manager (version 4.2). See:

You need an Ubuntu host PC with plenty of disk space. The TX2 is connected via the supplied micro-B USB cable (other cables might work, but quality is an extreme issue with others).