  Motivated by flavor non-universality and anomalies in semi-leptonic B-meson
decays, we present a general and systematic discussion about how to construct
anomaly-free $U(1)'$ gauge theories based on an extended standard model with
only three right-handed neutrinos. If all standard model fermions are
vector-like under this new gauge symmetry, the most general family
non-universal charge assignments, $(a,b,c)$ for three-generation quarks and
$(d,e,f)$ for leptons, need satisfy just one condition to be anomaly-free,
$3(a+b+c)=-(d+e+f)$. Any assignment can be linear combinations of five
independent anomaly-free solutions. We also illustrate how such models can
generally lead to flavor-changing interactions and easily resolve the anomalies
in B-meson decays. Probes with $B_s-\bar{B}_s$ mixing, decay into $\tau^\pm$,
dilepton and dijet searches at colliders are also discussed.
