The writ of habeas corpus is known as the "great and efficacious writ in all manner of illegal confinement". It is a summons with the force of a court order; it is addressed to the custodian (a prison official, for example) and demands that a prisoner be brought before the court, and that the custodian present proof of authority, allowing the court to determine whether the custodian has lawful authority to detain the prisoner. If the custodian is acting beyond their authority, then the prisoner must be released. Any prisoner, or another person acting on their behalf, may petition the court, or a judge, for a writ of habeas corpus. (PC 1473) One reason for the writ to be sought by a person other than the prisoner is that the detainee might be held incommunicado. Most civil law jurisdictions provide a similar remedy for those unlawfully detained, but this is not always called habeas corpus.
Habeas Corpus is a remedy for unlawful imprisonment in civil and criminal proceedings. (ex parte McCullough, 35 CA 97) The essence of the proceeding is to inquire into the right or legality under which a person is restrained.