Can you sell a stock for a gain and then buy it back

HomeCryptoCan you sell a stock for a gain and then buy it back