A writ of habeas corpus can be filed by the person who is held in detention or custody. It can also be filed on behalf of the prisoner by a friend or relative if the prisoner is not able to file it on their own.