There are a few different ways. It depends on what OS your computer is on.
If you are on a Mac then you can use PWNage Tool or redsn0w.
If you are on Windows then you can use redsn0w, Sn0wbreeze, or ifaith. iFaith requires blobs but I'm sure you do not have 5.0.1 blobs. And since you just bought the phone i highly doubt that you have blobs for anything unless you jailbroke with jailbreakme.com from Safari browser.
I recommend Sn0wbreeze. It is a jailbreak tool, that restores you device to a pre jailbroken iOS. However you can choose not to have the IPSW pre jailbroken by choosing "Baseband Preservation Mode".
All modes preserve baseband. the only difference between "Baseband Preservation Mode" and the other 2 is that the other 2 modes pre jailbreak the IPSW and it will already be jailbroken after restore. Tho it will be a tethered jailbreak and you will have to run iBooty (extracted to desktop automatically by Sn0wbreeze) every time you reboot your device.