
71 Cal.2d 1021 (1969)
In re CARLOS HARO on Habeas Corpus.
Crim. No. 12782. 
Supreme Court of California. In Bank.  
Sept. 15, 1969.
 Carlos Haro, in pro. per., and John A. Montag, under appointment by the Supreme Court, for Petitioner.
 Thomas C. Lynch, Attorney General, Doris H. Maier, Assistant Attorney General, and Nelson P. Kempsky, Deputy Attorney General, for Respondent.
 TOBRINER, J.
 In 1957 Carlos Haro (hereinafter referred to as defendant) pleaded guilty to possession of heroin (Health & Saf. Code,  11500) and admitted a September 20, 1955, misdemeanor conviction of use of, or being under the influence of, marijuana (Health & Saf. Code,  11721). The court sentenced him to imprisonment in the state prison for the term prescribed by law. Because of the prior misdemeanor conviction, defendant's sentence, pursuant to former Health and Safety Code section 11712, is automatically increased from a maximum of 10 years to 20 years. In this habeas corpus proceeding defendant challenges the validity of his prior misdemeanor conviction and the resultant increased penalty. *1023
 The 1955 complaint was filed against defendant in Los Angeles County charging defendant with violation of Health and Safety Code section 11721, a misdemeanor, and alleging that "the accused did willfully and unlawfully use and [was] addicted to the unlawful use of narcotics." We do not have the benefit of a transcript of the proceedings at arraignment or sentencing at this time because those records have been destroyed. The municipal court docket sheet states: "Sep. 1, 1955 Cause called. Judge John G. Barnes presiding. Both parties ready.people represented by J. C. Denny (D.C.A.). Defendant represented by Lothair Schoenheit [a deputy public defender]. Defendant in court, duly arraigned, informed of the charges against him and of his legal rights. Defendant gives true name as charged and enters his plea of not guilty to the offense charged. Defendant in open court personally demands jury trial. Trial set for September 20, 1955, at 9 A.M. in Division 7. Bail fixed in the sum of $2,500.00. Defendant committed."
 When defendant appeared on the date set for jury trial, the docket sheet indicates that he was "represented in pro per." At that time defendant withdrew his plea of not guilty and entered his plea of guilty. A letter incorporated in the file from Judge Parks Stillwell, presiding in that department, states: "As I recall, it was not my practice to advise defendants at this stage of their right to be represented by counsel, and this would be true whether I was aware of prior representation or not. The defendants had been advised of their rights at arraignment, and we accepted anyone's plea of guilty, whether represented or not, without any further advice re his right to counsel. There was, at that time, no thought that such representation was required in misdemeanor cases." On that date the court sentenced defendant on his plea of guilty to five years probation with the first 180 days to be spent in county jail.
 Subsequently, in 1957, as we have noted, defendant pleaded guilty to the charge of possession of heroin. He admitted the 1955 prior conviction; on June 3, 1957, the court sentenced defendant to the state prison for the term prescribed by law. On July 1, 1957, he commenced his term of two to twenty years. Without the prior conviction defendant could not have been subjected to imprisonment for more than 10 years and his term would have expired July 1, 1967.
 On May 9, 1968, defendant petitioned the Superior Court for the County of Sacramento, the county of confinement, for *1024 habeas corpus; on July 11, 1968, the court issued such a writ, returnable on July 26, 1968. On that date the court held its hearing; defendant testified that at the time of the misdemeanor prosecution in 1955 he did not have the benefit of representation by counsel, that the court did not appoint counsel to represent him, and that he did not tell the court that he waived representation by counsel. Upon defendant's plea of guilty he received a six months jail sentence. Defendant further testified that he did not learn of the effect of the prior misdemeanor conviction until he arrived at the state prison; he then discovered that the prior conviction added 10 years to his sentence, i.e., that the maximum term increased from 10 years to 20 years.
 Upon questioning by his counsel, defendant, a Mexican-American, testified that he had received only a fifth-grade education. The judge then questioned him as follows:
 "The Court: Now, you have told the Court that you were arrested for a violation of 11721, you went to court and entered a plea of nor [sic] guilty. You knew enough to do that, didn't you?"
 "Witness: Yes, sir, right."
 "The Court: I suppose you put up bail, didn't you?"
 "Witness: I did that because they were giving years, not--"
 "The Court: What's that?"
 "Witness: They were giving years, instead of six months. They were giving years, so--"
 "The Court: So you did put up bail, didn't you?"
 "Witness: Yes."
 "The Court: Then you entered a plea of not guilty?"
 "Witness: Yes."
 "The Court: Then you were at large for some time, weren't you?"
 "Witness: At large?"
 "The Court: Well, you came back two weeks later and entered a plea of guilty, didn't you?"
 "Witness: Yes."
 "The Court: And you knew precisely what you were doing all of the time."
 "Witness: No, I didn't know what I was doing. I wanted county jail time and go through with it."
 "The Court: The motion for Writ of Habeas Corpus is denied."
 In our decision in In re Caffey (1968) 68 Cal.2d 762, 765, fn. 3 [69 Cal.Rptr. 93, 441 P.2d 933], we indicated that a defendant properly applied for a writ of habeas corpus in the *1025 county in which he was imprisoned. We further stated that when the defendant had alleged facts which, if true, would entitle him to resentencing, the court should transfer the case to the court rendering the judgment of conviction for a hearing on the merits (In re Woods (1966) 64 Cal.2d 3 [48 Cal.Rptr. 689, 409 P.2d 913]; In re Luce (1966) 64 Cal.2d 11 [48 Cal.Rptr. 694, 409 P.2d 918]; In re Tucker (1966) 64 Cal.2d 15 [48 Cal.Rptr. 697, 409 P.2d 921]).
 The Attorney General questions the desirability of a ruling compelling the court in which a prisoner files a writ that challenges the validity of his confinement to transfer the action to another county. He cites the traditional jurisdiction of the court in the county of confinement to handle habeas corpus and argues for the exercise of discretionary power of that court as to the transfer of the case rather than a compulsory requirement that it do so.
 [1] We see no reason to change the Caffey rule.  [fn. 1] In cases involving the validity of prior convictions which would affect the sentence originally ordered, we believe that once the court of the county of confinement makes a preliminary determination that the prisoner has alleged facts which, if true, would entitle him to resentencing, that court must transfer the case *1026 to the county of sentencing for an evidentiary hearing to determine the truth of the alleged facts. If defendant demonstrates the invalidity of a prior conviction, the same court must then reconsider and redetermine the sentence. The sentencing court, rather than the court of the county of confinement, normally is more familiar with the facts of the case, including the basis of sentencing and the prior convictions that may affect that sentence.
 In the present case, the Superior Court for Sacramento County, instead of transferring the action to the County of Los Angeles upon defendant's allegations of these facts, conducted its own hearing on the merits of defendant's petition. Although the Sacramento court theoretically erred in failing to transfer the case to Los Angeles for an evidentiary hearing, the parties have stipulated that we may review the record to determine whether the Sacramento court properly concluded that defendant's prior conviction was valid. Moreover, if defendant's showing is correct, he is now eligible for release; nothing remains for the sentencing court upon which to rule.
 [2] As we shall hereinafter explain in more detail, the evidence submitted to the Sacramento Superior Court indicates that defendant was not represented by counsel at the time of his change of plea and sentencing in 1955, that he did not intelligently and understandingly waive his right to counsel, and that, therefore, the prior conviction was invalid. Under such circumstances, defendant, having at this date served the maximum term for conviction of possession of heroin for a defendant without any prior valid narcotics conviction, should be discharged.
 The cases hold that defendant is entitled to representation by counsel at the time of arraignment, plea, and sentencing, and that any waiver of counsel at such times must be an intelligent and understanding one. Thus in In re Johnson (1965) 62 Cal.2d 325 [42 Cal.Rptr. 228, 398 P.2d 420], we passed upon a situation in which defendant pleaded guilty to five charges of driving with knowledge that his license had been revoked (Veh. Code,  14601). At the time of the arraignment, plea, and sentencing, all of which occurred on the same day, defendant did not have the benefit of representation by counsel. This court reviewed and rejected the argument that defendant impliedly had waived his right to counsel by failing to request it and by pleading guilty to the charges. *1027
 In Johnson we said: "To begin with, 'it is settled that where the assistance of counsel is a constitutional requisite, the right to be furnished counsel does not depend on a request.' (Carnley v. Cochran (1962) 369 U.S. 506, 513 [82 S.Ct. 884, 8 L.Ed.2d 70] and cases there cited.)petitioner's failure to make such a request, accordingly, cannot be deemed a waiver of this constitutional right. Nor is the entry of a guilty plea conclusive of a waiver; the holding of a state court that by pleading guilty a defendant will be conclusively presumed to have waived counsel has been expressly disapproved by the United States Supreme Court as 'inconsistent with our interpretation of the scope of the Fourteenth Amendment. ... A defendant who pleads guilty is entitled to the benefit of counsel, and a request for counsel is not necessary. It is enough that a defendant charged with an offense of this character [i.e., burglary] is incapable adequately of making his defense, that he is unable to get counsel, and that he does not intelligently and understandingly waive counsel.' (Rice v. Olson (1945) 324 U.S. 786, 788-789 [65 S.Ct. 989, 89 L.Ed. 1367].)" (Italics added.) (62 Cal.2d at pp. 333-334.)
 We further stated, " 'Presuming waiver from a silent record is impermissible. The record must show, or there must be an allegation and evidence which show, that an accused was offered counsel but intelligently and understandingly rejected the offer. Anything less is not waiver.' " (In re Johnson, supra, 62 Cal.2d at p. 334, quoting from Carnley v. Cochran (1962) supra, 369 U.S. 506, 515-516 [8 L.Ed.2d 70, 76-77].)
 In Johnson the only evidence of waiver consisted of (1) defendant's plea of guilty, (2) the docket entry reflecting the proceedings that " 'Defendant [was] in court, duly arraigned, informed of the charges against him and of his legal rights' " (62 Cal.2d at p. 330), and (3) the judge's declaration that " 'it was my custom and practice at the opening of each morning and afternoon court session to make a detailed statement of constitutional rights, including the right of a defendant to be represented by legal counsel at all stages of the proceedings, and if a defendant in custody did not have an attorney, the right to be represented by the Public Defender, to all of the defendants collectively, including those in custody; That on November 19, 1963, a Deputy Public Defender was in the said courtroom or available on call in said courtroom at all times that Division 51 was in session.' " (62 Cal.2d at p. 331.) *1028
 Likewise, in In re Woods, supra, 64 Cal.2d 3, 11, we ordered the sentencing court to conduct an evidentiary hearing on the issue of waiver. We reemphasized our position as stated in Johnson that the defendant's silence and plea of guilty upon being advised of his right to counsel did not necessarily amount to an affirmative waiver of his right to counsel. We directed the court hearing the matter to determine whether there had been an "intelligent waiver of the right to counsel" based upon " 'the particular facts and circumstances surrounding that case including the background, experience, and conduct of the accused.' " (P. 8.) (See also In re Luce, supra, 64 Cal.2d 11, 14, and In re Tucker, supra, 64 Cal.2d 15, 21, both of which ordered the court of sentencing to make determinations upon all the facts and circumstances of the individual case as to whether the defendant intelligently and understandingly waived his right to counsel.)
 [3] The fundamental issue of this case must therefore turn on whether defendant intelligently and understandingly waived his right to counsel. Respondent bifurcates this issue: (1) did defendant suffer a denial of his right to counsel at arraignment; and (2) did defendant suffer a denial of his right to counsel when he was permitted to plead guilty and receive the sentence of the court without being represented by counsel. In both instances respondent argues that defendant's rights were protected.
 The court records reflect that at the arraignment the public defender's office represented defendant. At that time he entered his plea of not guilty, and the court set the case for jury trial. Defendant denies that counsel represented him or that the court advised him of his right to counsel. The docket entry, however, indicates the public defender did represent defendant. Moreover, the affidavit of a former deputy city attorney states that the presiding judge, Judge Stillwell, followed the practice of advising all defendants of their right to an attorney and to the appointment of a public defender to represent an indigent. If defendant requested counsel, the court directed the public defender to confer with the defendant, advise him, and answer legal questions. In view of the affidavit and the docket entry, we conclude that defendant was represented at the time of his arraignment. Defendant entered a plea of not guilty at that time.
 Respondent admits that on the date defendant changed his plea to guilty and received his sentence the deputy public defender, although still attorney of record, did not appear to *1029 represent him, that defendant was not substituted as attorney in propria persona in place of the deputy public defender, and that the court did not advise defendant of his right to counsel. We stated in In re Martinez (1959) 52 Cal.2d 808 [345 P.2d 449], that, under similar circumstances, the court erred in accepting a guilty plea in the absence of the accused's attorney and in failing to observe the requirements of Code of Civil Procedure sections 284  [fn. 2] and 285  [fn. 3] as to substitution of attorneys. Sections 284 and 285 do not distinguish between civil and criminal cases (see Smith v. Superior Court (1968) 68 Cal.2d 547, 558 [68 Cal.Rptr. 1, 440 P.2d 65]) or between misdemeanors and felonies; the trial court's noncompliance with these provisions constitutes error.
 In Martinez we found additional error in the failure of the trial court to follow Penal Code section 1018, which states in part that no plea of guilty to a noncapital felony shall "be accepted from any defendant who does not appear with counsel unless the court shall first fully inform him of his right to counsel and unless the court shall find that the defendant understands his right to counsel and freely waives it and then, only if the defendant has expressly stated in open court, to the court, that he does not wish to be represented by counsel."
 We expressed in In re Johnson, supra, 62 Cal.2d 325, the concern of the courts for the protection of defendant by representation by counsel at all applicable and crucial stages of the proceedings. Johnson stated that under section 13 of article I of the California Constitution, "there can be no doubt that the fundamental constitutional right to the assistance of counsel at all stages of the proceedings ... is, in California at least, not limited to felony cases but is equally guaranteed to persons charged with misdemeanors in a municipal or other inferior court." (Italics added.) (62 Cal.2d at p. 329.) As to Penal Code section 1018, we declared in Johnson that "[a]lthough this section is applicable on its face only to felony cases ..., it is declaratory of the solicitude of the Legislature *1030 that the constitutional right to counsel shall not become a dead letter through a possible lack of understanding by defendants. Since, as shown at the outset, that constitutional right is equally guaranteed to persons charged with misdemeanors, we may not presume that the Legislature intended to deny similar protection to the latter by enacting this section. It is noted, moreover, that section 1018 concludes by declaring that its provisions 'shall be liberally construed to effect these objects and to promote justice.' " (P. 335, fn. 7.) (See also In re Luce, supra, 64 Cal.2d 11.) Because of our solicitude for defendant's right to counsel as expressed in Johnson we cannot condone in the present case the failure of the trial court to reinform defendant of his right to counsel when he appeared for the first time without his counsel for sentencing, nor can we countenance the trial court's failure to require defendant's waiver of his right to counsel in open court before the rendition of sentence.
 In Martinez, however, we held that despite a trial court's erroneous noncompliance with Code of Civil Procedure sections 284 and 285 and Penal Code section 1018, habeas corpus would not issue if the defendant freely and intelligently waived his right to counsel. In Martinez, when defendant appeared without counsel and changed his plea to guilty the court and the prosecuting attorney carefully interrogated defendant as to whether he wished to proceed without counsel, and defendant affirmatively declared his desire to proceed.  [fn. 4] The record thus showed an express waiver of the right to counsel. Mr. Martinez contended that at the time of the waiver he had been under the influence of narcotics, and further that the waiver had been coerced by threats from the district attorney. Accordingly, this court ordered a hearing to determine whether the waiver was freely and intelligently made. Upon receiving findings from the referee upholding the waiver, we denied habeas corpus.
 In the present case no waiver appears of record,  [fn. 5] and consequently we see no need for a factual hearing; absent any *1031 waiver there cannot be a free and intelligent waiver. We conclude that defendant's 1955 misdemeanor conviction was invalid. In sentencing defendant in 1957 to a term of from two to twenty years the court improperly considered the 1955 conviction. The correct term, upon exclusion of the prior conviction, is two to ten years. Since defendant has already served more than the ten-year maximum sentence, he is entitled to immediate discharge.
 The writ is granted and defendant is discharged from custody.
 Traynor, C. J., McComb, J., Peters, J., Mosk, J., Burke, J., and Sullivan, J., concurred.
 In recent years the courts have increasingly turned to habeas corpus as a means of enforcing post-conviction rights of incarcerated defendants. This expansion of habeas corpus relief has resulted from the continued emphasis placed upon individual rights by the United States Supreme Court. Indeed that court requires us to provide such avenues of relief to state prisoners (e.g., Anders v. California (1967) 386 U.S. 738 [18 L.Ed.2d 493, 87 S.Ct. 1396]; People v. Feggans (1967) 67 Cal.2d 444, 447 [62 Cal.Rptr. 419, 432 P.2d 21]).
 New Penal Code section 1508 (Stats. 1969, ch. 38, to become effective after adjournment of the 1969 session of the Legislature), cited by the Attorney General, adds nothing that bears upon the procedural problem. Section 1508 will simply restate the familiar rule that this court can order the writ of habeas corpus returnable before itself or a Court of Appeal or a superior court; a Court of Appeal can order the writ returnable before itself or a superior court in its district; and a superior court can order the writ returnable before itself.
NOTES
[fn. 1]  1. The Attorney General, in urging this court to change the Caffey rule, relies upon Zeigler v. Superior Court (1933) 134 Cal.App. 88 [24 P.2d 899], and Bartlett v. Superior Court (1930) 108 Cal.App. 755 [292 P. 545]. Both of those cases merely state that the superior court in the county of confinement is the only superior court which can issue a writ of habeas corpus. We make no attempt to establish, nor has anyone proposed, a rule requiring a superior court to issue its order to show cause on a petition for habeas corpus returnable in another county. We merely decide that once the superior court in the county of confinement reaches a prima facie determination that the facts alleged by the petitioner, if true, would entitle him to resentencing, that court must transfer the case to the county of sentencing for a redetermination of that sentence.
[fn. 2]  2. "The attorney in an action or special proceeding may be changed at any time before or after judgment or final determination, as follows: 1. Upon the consent of both client and attorney, filed with the clerk, or entered upon the minutes; 2. Upon the order of the court, upon the application of either client or attorney, after notice from one to the other ...."
[fn. 3]  3. "When an attorney is changed, as provided in the last section, written notice of the change and of the substitution of a new attorney, or of the appearance of the party in person, must be given to the adverse party. Until then he must recognize the former attorney."
[fn. 4]  4. The prosecuting attorney, Mr. Holzauer, after pointing out that counsel had previously represented Mr. Martinez, stated that if Mr. Martinez nevertheless desired to proceed in the absence of counsel the prosecuting attorney could "see no objection to that." The record then reads: "The Court: Are you willing to proceed now? The Defendant: That's right. Mr. Holzauer: It is your desire to proceed now? The Defendant: That's right." (52 Cal.2d at p. 813.)
[fn. 5]  5. Neither court nor prosecuting counsel called to the attention of defendant that he had previously been represented by counsel; neither asked defendant if he nevertheless wished to proceed; defendant did not state a desire to proceed in the absence of counsel.
