Cleaning your chain is an essential part of bike maintenance that a lot of people neglect. Cleaning it will save you a lot of money in the long run and will make your bike run better. It will save you from wearing out your cog, cassette, and chainrings prematurely, and your drivetrain will run a lot smoother.
For this, you will need a rag, degreaser, and chain lube. It is important to use bike specific products.
Start by taking your degreaser and putting in on the chain on the derailleur. Spend your pedals backwards while slowly putting degreaser on your chain. Then, spend the pedals backwards again while wiping the chain with the rag. Do multiple rotations of this.
Next, it is the same process with the lubricant. Take your lube and place it on the same place on the derailleur while spinning the pedals backwards. Run your chain through your gear set to evenly distribute the lube.
Finally, take your rag and wipe through a couple rotations to get the excess off.