
862 So.2d 587 (2002)
Ex parte Gregory BOYKINS.
(In re Gregory Boykins v. State of Alabama).
1011152.
Supreme Court of Alabama.
December 20, 2002.
Gregory Boykins, pro se.
Andrew W. Redd, gen. counsel, for respondent Department of Corrections.
HARWOOD, Justice.
On September 17, 2001, Gregory Boykins, an inmate at the Bullock County Correctional Facility, filed a petition for a writ of certiorari with the Bullock County Circuit Court challenging the denial by the *588 Department of Corrections ("the DOC") of his request to receive incentive good time ("IGT"). On October 26, 2001, the district attorney's office filed a motion to dismiss the petition, which Boykins opposed. In an order issued on November 1, 2001, the trial court characterized Boykins's petition as a petition for a writ of habeas corpus and granted the motion to dismiss. On December 19, 2001, Boykins filed a notice of appeal to the Alabama Court of Criminal Appeals. That court affirmed the trial court's order of dismissal in an unpublished memorandum, Boykins v. State, (No. CR-01-0659, February 22, 2002) 854 So.2d 1228 (Ala.Crim.App.2002) (table).
Boykins petitioned this Court for a writ of certiorari to review the Court of Criminal Appeals' affirmance of the trial court's order. We granted Boykins's petition on May 28, 2002, to address the question whether the Court of Criminal Appeals properly affirmed the trial court's order of dismissal where the basis of the dismissal was the trial court's treatment of Boykins's petition for a writ of certiorari as a petition for a writ of habeas corpus.
The record reveals that in March 1973 Boykins was convicted of first-degree murder and was sentenced to 60 years' imprisonment.[1] In September 1974, while working on a "road camp," Boykins escaped. He remained a fugitive from 1974 until April 1995, when he was returned to the custody of the DOC. While on escape, Boykins pleaded guilty to another murder in Illinois. Subsequent to his return to the custody of the DOC, Boykins requested eligibility to earn IGT. His requests were denied by the DOC because of its determination that Boykins failed to meet the criteria for receipt of IGT.
In affirming the trial court's dismissal of Boykins's petition as a petition for a writ of habeas corpus, the Court of Criminal Appeals stated in its unpublished memorandum:
"Boykins argues that in light of the grounds raised in his petition, the circuit court erred in summarily dismissing his petition. We disagree.
"A petition for writ of habeas corpus is the proper method by which to test whether the State has correctly calculated the time an inmate must serve in prison. Breach v. State, 687 So.2d 1257 (Ala.Crim.App.1996); Swicegood v. State, 646 So.2d 158 (Ala.Crim.App. 1993). Therefore, the circuit court correctly treated Boykins's petition for writ of certiorari as a petition for writ of habeas corpus. However, Boykins's contention that he has a liberty interest in receiving IGT credit against his sentence is without merit. The State of Alabama gives inmates an opportunity to reduce their prison sentence through IGT deductions. See § 14-9-41, Ala. Code 1975. That statute provides, in pertinent part, that an inmate who has `faithfully observed the rules for a period of time ... may be entitled to earn a deduction' from his sentence. § 14-9-41(a). Accordingly, inmates are not entitled to receive, and thus do not have a liberty interest in receiving, IGT. See Coslett v. State, 697 So.2d 61 (Ala.Crim. App.1997); Parker v. State, 648 So.2d 653 (Ala.Crim.App.1994); Gullett v. State, 613 So.2d 400 (Ala.Crim.App. 1992).2 As we explained in Coslett:

"`The opportunity to earn "good time" is a privilege, not a right, in Alabama. Prisoners may earn higher classifications, and thus more "good *589 time," through good behavior. A higher classification is based on a prisoner's trustworthiness, willingness and ability to work, and behavior while in prison. Accordingly, a favorable evaluation of a prisoner's conduct may result in a move to a higher classification so that he can earn more "good time" for each day served. Because Alabama's system is an incentive system, prison officials must have the authority to place prisoners who do not follow the rules or who fail to meet the requirements of a higher classification in lower classifications.'
"697 So.2d at 64.
"Because Boykins had no liberty interest in earning IGT, the circuit court correctly denied his petition for writ of habeas corpus. That court's judgment is therefore affirmed.
2"We note, however, that once an inmate actually earns IGT, it may not be taken away without due process. See, e.g., Ex parte Hawkins, 475 So.2d 489 (Ala.1985); Gowers v. State, 766 So.2d 986 (Ala.Crim.App.2000); Summerford v. State, 466 So.2d 182 (Ala.Crim.App. 1985). Therefore, while an inmate does not have a liberty interest in earning IGT, he does enjoy a liberty interest in retaining what IGT he has accrued."
Boykins asserts that the conclusion by the Court of Criminal Appeals that the circuit court correctly treated his petition for a writ of certiorari as a petition for habeas corpus was incorrect. The basis for that conclusion was the Court of Criminal Appeals' recognition that a petition for habeas corpus is the proper means for testing whether the State has correctly calculated the duration of an inmate's incarceration. Breach v. State, 687 So.2d 1257 (Ala.Crim.App.1996); Swicegood v. State, 646 So.2d 158 (Ala.Crim.App.1993). However, Boykins argues that his petition does not question whether the State correctly calculated his sentence; instead, he argues that his petition sought to review an administrative determination by the DOC as to whether he was entitled to earn IGT. Boykins argues that because his petition sought review of an administrative decision rather than the vindication of a "liberty interest," the Court of Criminal Appeals erred in determining that his petition was properly dismissed as a petition for a writ of habeas corpus.
In his brief to this Court, Boykins relies on Cox v. State, 628 So.2d 1075 (Ala.Crim. App.1993), as authority supporting his argument that the trial court wrongfully treated his petition for a writ of certiorari as a petition for a writ of habeas corpus. In Cox, an inmate incarcerated in the Elmore Correctional Center challenged a trial court's dismissal of his petition for a writ of certiorari, which the court had treated as a petition for a writ of habeas corpus. The appellant, like Boykins, alleged that he was entitled to IGT and that the denial of IGT was contrary to the Legislature's intent in enacting Ala.Code 1975, §§ 14-9-20 through 14-9-25.[2] The Court of Criminal Appeals determined that the trial court had erred in treating a petition for a writ of certiorari as a petition for a writ of habeas corpus. The court stated:
"In Cox's response to the state's motion to dismiss, Cox asserted that his petition is not a petition for writ of habeas corpus, but a petition [for a] writ *590 of certiorari. As support, he cites Sellers v. State, 586 So.2d 994 (Ala.Cr.App. 1991), wherein the court affirmed the circuit court's denial of Seller's petition for writ of habeas corpus contesting the revocation of his parole by the Alabama Board of Pardons and Paroles. In so holding, the Sellers court stated the following:
"`While the trial court gave no reason for denying the petition other than the fact that it did so on the pleadings, its denial was proper, because review of an action by the Board is not by a habeas corpus proceeding. Generally, habeas corpus is inappropriate as a remedy to review the actions of an administrative board or commission, such as the Board. The appropriate remedy is an appeal pursuant to the Alabama Administrative Procedure Act, § 41-22-1 et seq., Code of Alabama 1975 (hereinafter "the Act"), if the administrative agency from which the appeal is taken comes within the purview of that Act. However, if the agency is exempted from the judicial review provisions of the Act and there is no other provision for statutory review, review is by petition for writ of certiorari. See Ellard v. State, 474 So.2d 743 (Ala.Cr.App.1984), aff'd, 474 So.2d 758 (Ala.1985)(in the absence of a right to appeal or other adequate remedy, the writ of certiorari lies to review the rulings of an administrative board or commission). See also Ex parte Baldwin County Comm'n, 526 So.2d 564 (Ala.1988)(an extraordinary writ will not lie if there is a right of appeal).'
"586 So.2d at 994-95.
"After a brief hearing, the circuit court dismissed the `Petition for Writ of Habeas Corpus,' specifically finding that `the denial of incentive good time does not raise a proper issue' because `inmates have no constitutional right to incentive good time.' By way of a `Motion for New Trial,' Cox objected to the circuit court's treatment of his petition as a habeas corpus petition, arguing that he `does not claim a constitutional right to incentive good time, but rather a procedur[al] right to have the statutory intent of the legislature applied to him as they intended it to.' The motion was denied.
"Cox's arguments on appeal are that the circuit court improperly considered his petition to be a habeas corpus petition and consequently failed to address the issue of whether the amendment to Admin. Reg. 420 contravenes the legislature's intent. The state has failed to respond to these arguments. Based upon the considerations before us, we hold that the circuit court erred in treating Cox's petition for writ of certiorari as a petition for writ of habeas corpus, particularly because the court had no jurisdiction to entertain a habeas corpus petition filed by Cox. See § 15-21-6[, Ala.Code 1975] (which requires that when the petitioner is confined in the penitentiary, the petition must be addressed to the nearest circuit court)."
628 So.2d at 1076-77 (emphasis added). The court in Cox concluded its opinion with the following statement in a footnote: "We note that the Alabama Administrative Procedure Act, § 41-22-1 et seq., Code of Alabama 1975, offers no appropriate remedy in the instant case. See § 41-22-3(9)(g)(1)(which excludes from the definition of `rule' `[a]ny rules or actions relating to ... [t]he conduct of inmates of public institutions')." 628 So.2d at 1077 n. 2.
The court in Cox determined that the treatment of Cox's petition for a writ of certiorari as a petition for a writ of habeas *591 corpus was an error, particularly because the trial court, not being the circuit court nearest the penitentiary in which Cox was confined, did not have jurisdiction over a petition for habeas corpus. Ala.Code 1975, § 15-21-6. In Cox, the Court of Criminal Appeals, as in the instant case, never addressed the issue whether the DOC's ruling on a request for IGT is a proper subject for a petition for a writ of habeas corpus, as opposed to a petition for a writ of certiorari, in instances in which the trial court does have jurisdiction to entertain a petition for habeas corpus under § 15-21-6.
The writ of habeas corpus is also known as the "Great Writ," and its purpose has been discussed at length by the United States Supreme Court. In Heflin v. United States, 358 U.S. 415, 421, 79 S.Ct. 451, 3 L.Ed.2d 407 (1959), a case considering the petition for a writ of habeas corpus of a petitioner who was convicted in Alabama under the Federal Bank Robbery Act, 18 U.S.C. § 2113 et seq., the Court described the only function of the writ:

"The very office of the Great Writ, its only function, is to inquire into the legality of the detention of one in custody. It is unnecessary to paraphrase here Mr. Justice Stone's penetrating discussion in McNally v. Hill, 293 U.S. 131, 55 S.Ct. 24, 79 L.Ed. 238 [(1934), overruled in part on other grounds, Peyton v. Rowe, 391 U.S. 54, 88 S.Ct. 1549, 20 L.Ed.2d 426 (1968)], or to incorporate the thorough review of legal history there contained. It will suffice to note only the Court's conclusion: `Without restraint of liberty, the writ will not issue. * * * Equally, without restraint which is unlawful, the writ may not be used. A sentence which the prisoner has not begun to serve cannot be the cause of restraint which the statute makes the subject of inquiry.'(Citations omitted.) 293 U.S. at page 138, 55 S.Ct. at page 27."
358 U.S. at 421, 79 S.Ct. 451 (emphasis added). See also Parker v. Ellis, 362 U.S. 574, 575, 80 S.Ct. 909, 4 L.Ed.2d 963 (1960)("`Without restraint of liberty, the writ will not issue.'" (quoting McNally v. Hill, 293 U.S. 131, 138, 55 S.Ct. 24, 79 L.Ed. 238 (1934)), reversed on other grounds, Carafas v. LaVallee, 391 U.S. 234, 88 S.Ct. 1556, 20 L.Ed.2d 554 (1968)).
The courts of this State have long recognized that the only purpose of the writ of habeas corpus is to afford relief against actual restraints upon liberty. State v. Speake, 187 Ala. 426, 427, 65 So. 840, 841 (1914)("The writ of habeas corpus has been defined, or rather described, as `that legal process which is employed for the summary vindication of the right of personal liberty when illegally restrained.'"); Powell v. State, 726 So.2d 735, 737 (Ala.Crim. App.1997)("The sole function of habeas corpus relief is to provide relief from unlawful imprisonment or custody, and it cannot be used for any other purpose."); Stinson v. State, 43 Ala.App. 257, 258, 188 So.2d 287, 288 (1966) ("The writ of habeas corpus is concerned solely with the lawfulness of the present holding of the petitioner." (citing Adams v. State, 30 Ala.App. 487, 8 So.2d 219 (1942))); Williams v. State, 42 Ala.App. 140, 140, 155 So.2d 322, 323 (1963)("`It should always be borne in mind that the applicant for the writ of habeas corpus is not entitled to the writ unless he is actually restrained of his liberty.... Mere moral restraint (such as a military arrest, confinement to quarters, or parole, for example), as distinguished from actual confinement, is generally insufficient to warrant issuance of the writ.'" (quoting Walter B. Jones, Habeas Corpus, State and Federal, Ala. Law., Oct. 1952, at 384)).
*592 In this case, Boykins is not challenging the duration of his sentence. Neither is he asserting that he is unlawfully imprisoned because he has completed all of the time he was sentenced to serve. The facts in this case do not raise the question whether a sentence has been correctly calculated, as did Breach and Swicegood, supra, and those cases, relied upon by the Court of Criminal Appeals, are not applicable to this case. Rather, in this case, Boykins is challenging the propriety of the DOC's ruling on his request for IGT. We agree with the determination of the Court of Criminal Appeals, relying on Ala.Code 1975, § 14-9-41, Coslett v. State, 697 So.2d 61 (Ala.Crim.App.1997), Parker v. State, 648 So.2d 653 (Ala.Crim.App.1994), and Gullett v. State, 613 So.2d 400 (Ala.Crim. App.1992), that Boykins does not have a liberty interest in the DOC's ruling on his request to qualify for IGT. Boykins is not asserting that the DOC deprived him of IGT he had previously earned, as to which he would have a liberty interest. Just as a writ of habeas corpus has no application to a sentence a prisoner has not begun to serve, Heflin, supra, neither does the writ have application to IGT Boykins has not begun to earn. Because Boykins does not have liberty interest in the DOC's ruling on his application for IGT, the Court of Criminal Appeals erred in concluding that the circuit court correctly treated his petition for a writ of certiorari as a petition for a writ of habeas corpus.
We distinguish this case from Ex parte Deramus, [Ms. 1010923, June 7, 2002] ___ So.2d ___ (Ala.2002), in which the petitioner, an inmate at the Kilby Correctional Facility, challenged his custody classification by the DOC. While serving a 45-year sentence, Deramus qualified for, and successfully participated in for approximately 5 years, a "work-release" program. The DOC subsequently reclassified him as a "heinous offender"; that reclassification rendered him ineligible to participate further in the work-release program. Thus, Deramus's reclassification required him to remain incarcerated at the penitentiary rather than leaving that facility for the purpose of the work-release program. Deramus sought review of the reclassification and styled his petition to the Limestone County Circuit Court as a petition for a writ of certiorari; the petition should have been styled as a petition for a writ of habeas corpus. Nevertheless, the trial court treated his petition for a writ of certiorari as a petition for a writ of habeas corpus and denied it.
The Court of Criminal Appeals did not address the merits of Deramus's argument; it simply affirmed the trial court's judgment because Deramus had mislabeled his petition. We noted in Deramus that the Court of Criminal Appeals has held that a petition for a writ of habeas corpus is the proper means for an inmate to challenge the DOC's change of custody classification. See Drayton v. State, 600 So.2d 1088, 1090 (Ala.Crim.App.1992), overruled on other grounds, Maddox v. State, 662 So.2d 915 (Ala.1995). The application of that rule to Deramus's situation was perfectly appropriate because by being physically restrained from participating in the work-release program Deramus had plainly lost a liberty interest. However, the only issue before this Court was the effect of a mislabeled motion. We concluded that as a result of the language presented in the petitioner's petition, it was clear that he was seeking relief from a change in his custody classification. Accordingly, we held that merely mislabeling a motion would not render it unreviewable, and we reversed the judgment of the Court of Criminal Appeals and remanded the cause for that court to treat Deramus's petition as a petition for a writ of habeas corpus and to consider the merits of the *593 petition. Thus, Deramus is distinguishable from the case at hand because Deramus addressed only the effect of mislabeling a petition as a petition for certiorari when in fact that petition sought relief from a restraint against liberty and was therefore correctly viewed as a petition for a writ of habeas corpus. However, Deramus is consistent with the settled law that the purpose of a petition for a writ of habeas corpus is to obtain relief from an unlawful restraint on liberty. In this case, Boykins's petition was correctly labeled as a petition for a writ of certiorari, but incorrectly reviewed as a petition for a writ of habeas corpus. It cannot be reviewed as a petition for a writ of habeas corpus because it does not seek relief from a restraint on any liberty Boykins has at present.
Moreover, we note that the DOC, as stated in Ala.Code 1975, § 14-1-1.2, is an "administrative department responsible for administering and exercising direct and effective control over penal and corrections institutions throughout this state." (Emphasis added.) Ala.Code 1975, § 41-22-3(1), defines "agency" as "[e]very board, bureau, commission, department, officer, or other administrative office or unit of the state." (Emphasis added.) Accordingly, the DOC is an administrative agency that is within the scope of the Alabama Administrative Procedure Act, Ala.Code 1975, § 41-22-1 et seq. ("the Act"). The appropriate remedy to review the actions of administrative agencies is an appeal made in accordance with § 41-22-20(a) of the Act. However, pursuant to § 41-22-3(9)(g)(1), as noted in Cox, Boykins has no right to avail himself of such judicial review.
Thus, we conclude that Sellers v. State, 586 So.2d 994 (Ala.Crim.App.1991), cited in Cox, supra, is more analogous to this case. In Sellers, the petitioner appealed the trial court's denial of his petition for a writ of habeas corpus, pursuant to which he sought review of the revocation of his parole by the Alabama Board of Pardons and Paroles ("the Board"). The Court of Criminal Appeals held that the actions of the Board could not be reviewed under the Act because Ala.Code 1975, § 41-22-3(3) exempts the Board from review. Thus, the court determined that the appropriate means for the petitioner to seek review of the Board's action was by petition for a writ of certiorari.
Here, Boykins, an inmate in a public institution, has sought review of the action of an administrative department, i.e., the DOC, regarding its denial of his request to receive IGT. Like the petitioner in Sellers, Boykins does not enjoy the statutory right of judicial review provided by § 41-22-20(a), a part of the Act, because he is excluded under § 41-22-3(9)(g)(1).
"Alabama law is clear that, in the absence of a right of appeal, a party seeking review of a ruling by an administrative agency may petition the circuit court for a common law writ of certiorari." State Personnel Bd. v. State Dep't of Mental Health & Retardation, 694 So.2d 1367, 1371 (Ala. Civ.App.1997), citing Ellard v. State, 474 So.2d 743 (Ala.Crim.App.1984), affirmed, 474 So.2d 758 (Ala.1985). See also Alabama Dep't of Mental Health & Mental Retardation v. Kirby, 579 So.2d 675 (Ala. Civ.App.1991). "Certiorari will not issue, however, if a right of appeal is available." State Personnel Board, 694 So.2d at 1371. "[W]here an applicable statute provides no right of appeal and no statutory certiorari review, the only means of review is the common law writ of certiorari." Hardy v. Birmingham Bd. of Educ., 634 So.2d 574, 576 (Ala.Civ.App.1994). Hence, Boykins's only means to seek review of the actions of the DOC is by a petition for a writ of certiorari. Consequently, the Court of *594 Criminal Appeals erred in affirming the trial court's treatment of Boykins's petition for a writ of certiorari as a petition for a writ of habeas corpus and its denial of that petition. Accordingly, the judgment of the Court of Criminal Appeals is reversed and the cause remanded for the Court of Criminal Appeals to reverse the judgment of the trial court and remand the cause for the trial court to review Boykins's petition for a writ of certiorari reviewing the DOC's denial of his request to be allowed to earn IGT.
REVERSED AND REMANDED.
HOUSTON, SEE, LYONS, BROWN, JOHNSTONE, and WOODALL, JJ., concur.
NOTES
[1]  The record does not show the specific date on which Boykins was convicted or the court of conviction.
[2]  Sections 14-9-20 through 14-9-25, Ala. Code 1975, were repealed effective May 19, 1980. The Alabama Correctional Incentive Time Act, effective May 19, 1980, and codified at §§ 14-9-41 through -44 replaced those provisions. See Act No. 80-446, Ala. Acts 1980.
