A Petition for Writ of Habeas Corpus (Sec. 2254) is a legal document used to challenge the legality of a person's detention. The petition is a request to a court to review the legality of a person's detention and determine if the detention is in violation of the person's constitutional rights. The petitioner must show that the detention is illegal or unconstitutional in order to be successful. There are two types of Petition for Writ of Habeas Corpus (Sec. 2254): 1) State Habeas Corpus: A state habeas corpus is a petition filed in a state court challenging the legality of a person's detention. The petitioner must show that the detention is in violation of the state constitution or other state laws. 2) Federal Habeas Corpus: A federal habeas corpus is a petition filed in a federal court challenging the legality of a person's detention. The petitioner must show that the detention is in violation of the United States Constitution or federal laws. The writ of habeas corpus is used to protect individuals from unlawful detention, as it allows them to challenge their detention in court and seek relief from the court.