Searches are under way in Advanced LIGO and Virgo data for persistent gravitational waves from continuous sources, e.g. rapidly rotating galactic neutron stars, and stochastic sources, e.g. relic gravitational waves from the Big Bang or superposition of distant astrophysical events such as mergers of black holes or neutron stars. These searches can be degraded by the presence of narrow spectral artifacts (lines) due to instrumental or environmental disturbances. We describe a variety of methods used for finding, identifying and mitigating these artifacts, illustrated with particular examples. Results are provided in the form of lists of line artifacts that can safely be treated as non-astrophysical. Such lists are used to improve the efficiencies and sensitivities of continuous and stochastic gravitational wave searches by allowing vetoes of false outliers and permitting data cleaning.