
235 Cal.App.3d 1344 (1991)
1 Cal. Rptr.2d 367
RAUL CORONA CARDENAS, Plaintiff and Appellant,
v.
ALFRED NOREN, as Sheriff, etc., Defendant and Respondent; DEAN R. MONTERO et al., Real Parties in Interest and Respondents.
Docket No. H007830.
Court of Appeals of California, Sixth District.
November 8, 1991.
*1345 COUNSEL
Gretchen Regenhardt for Plaintiff and Appellant.
Dwight L. Herr, County Counsel, Harry A. Oberhelman III, Assistant County Counsel, for Defendant and Respondent.
No appearance for Real Parties in Interest and Respondents.
*1346 OPINION
COTTLE, J.
Raul Corona Cardenas appeals the judgment of the trial court denying his petition for writ of mandate. (Code Civ. Proc.,[1] § 1085.) Appellant claims a writ should have issued to the sheriff ordering him to restore appellant to possession of certain real property because the sheriff wrongfully evicted him. Appellant contends his eviction was unlawful because although he was a tenant and a named defendant in an unlawful detainer action, he was never served with process or named in the default judgment. For the reasons stated below we affirm.

FACTS
Appellant and Mercedes Dominguez were in possession of premises at 30 Hawthorne Avenue (front house) in Watsonville in Santa Cruz County. Real parties in interest Dean and Jeanell Montero (landlords) owned the property. The tenancy was month-to-month and the rent was $700 per month. On August 16, 1990, landlords brought a complaint in unlawful detainer against both appellant and Dominguez, alleging nonpayment of $100 of the monthly rent. Landlords alleged that they had served a three-day notice to pay rent or quit on August 10, 1990.
Landlords served and then took the default of Dominguez only. A "notice to vacate" in five days, identifying Dominguez as the judgment debtor, was served on appellant's wife, Virginia Cardenas, at the premises on September 4, 1990. The notice to vacate and the writ of possession showed appellant as the first named defendant, but both documents were directed only to Dominguez.
The documents were referred to the civil division of respondent sheriff's department for service and execution. After the notice to vacate had been served, appellant and his wife consulted a Legal Aid attorney. They appeared ex parte at municipal court on September 7, 1990, to seek a stay of execution of the writ. The landlords' attorney told the appellant and his wife that the notice to vacate was not directed to them, so they did not obtain a stay.
Deputy Sheriff George Chekouras executed the writ of possession about noon on September 11, 1990. The deputy noted that appellant and Dominguez were named as defendants, and the eviction restoration notice shows that it was directed to Dominguez only. According to Chekouras's *1347 declaration, a woman with a child was present, and was removing belongings from the house. Appellant and his wife were not present. No one had made a claim of the right to possession pursuant to section 1174.3. One of the landlords was present while the deputy removed all the possessions from the house. The deputy left about five minutes after noon, after the landlord said that everything was under control. The sheriff's department was unaware that an hour earlier appellant's attorney had filed an answer on his behalf in municipal court, asserting as a defense to the unlawful detainer action a breach of the implied warranty of habitability. Appellant and his wife returned home that day to find the locks changed and their personal belongings on the front lawn.
Appellant filed in the superior court a petition for a peremptory writ of mandate against the sheriff on September 24, 1990. Appellant sought a writ ordering the sheriff to set aside its execution of the writ of possession against petitioner, and to restore him to possession of the premises. The trial court denied the petition, finding appellant should have presented a claim of right to possession pursuant to section 1174.3. Appellant assigns as error the denial of the petition for writ of mandate.

DISCUSSION
A writ of mandate "may be issued by any court ... to any inferior tribunal, corporation, board, or person, to compel the performance of an act which the law specially enjoins, as a duty resulting from an office, trust, or station; or to compel the admission of a party to the use and enjoyment of a right or office to which he is entitled...." (§ 1085.)
(1a) The question on appeal is whether the trial court erred in denying the petition for a writ of mandate. A corollary issue is whether mandate lies to compel the sheriff to reinstate a tenant he evicted, even though the tenant was a named defendant in an unlawful detainer action but not served with process or named in the default judgment. While we find that appellant's rights were enforceable against the landlords, we conclude that mandate directed toward the sheriff is not the proper remedy.
The landlords sued and named two tenants, appellant and Dominguez, in their complaint for unlawful detainer. For reasons which do not appear from the record, the landlords elected to serve Dominguez and not appellant. The landlords took Dominguez's default, and the deputy sheriff served on her a notice to vacate and ultimately evicted her and appellant. The sheriff is charged with the duty of serving "all process and notices in the manner prescribed by law." (Gov. Code, § 26608.) (2) When an order or process appears regular and valid on its face, and appears to have been executed by *1348 a court having jurisdiction, it is the duty of the sheriff to execute it. (Vallindras v. Massachusetts etc. Ins. Co. (1954) 42 Cal.2d 149, 154 [265 P.2d 907]; First Nat. Bank v. McCoy (1931) 112 Cal. App. 665, 670 [297 P. 571].) When the lack of authority is apparent from the process, an officer is justified, and it is his duty, not to serve illegal process, and if he does so it is at his own peril. (Pankewicz v. Jess (1915) 27 Cal. App. 340, 342 [149 P. 997].)
In Arrieta v. Mahon (1982) 31 Cal.3d 381, 383-384 [182 Cal. Rptr. 770, 644 P.2d 1249], a taxpayer challenged the policy of the Los Angeles County marshal to evict all the occupants of premises, whether or not they were named in the writ of possession. A Los Angeles marshal came to the apartment of Arrieta, and served a notice to one Ernesto Falcon to vacate the apartment in five days, or to be forcibly evicted. Falcon had lived in the apartment with Arrieta, but had moved, and Arrieta had been making the monthly rental payments. Neither Arrieta nor any of her family members were served with any process until the notice to vacate was served. (Id. at p. 384.)
The policy of the marshal's office in executing a writ of possession against a tenant was to evict the named tenant and all other occupants of the apartment. Arrieta sought injunctive and declaratory relief, alleging the marshal's practice of evicting unnamed adults on the premises violated her rights to procedural due process. She also brought a taxpayer's suit to enjoin the marshal from expending public funds to carry out this policy. The landlords agreed not to evict Arrieta, and the suit proceeded as a taxpayer's action. (Arrieta v. Mahon, supra, 31 Cal.3d at p. 385.) The trial court held that in the future the marshal should not evict unnamed parties who made a claim of a right to possession of the premises. The notice-to-vacate form was modified so that an unnamed party with a claim of possession could call the marshal's office to object to the eviction. (Id. at p. 386.)
The appellate court found that the marshal's policy violated the firmly established right to a preeviction hearing in unlawful detainer actions. (Arrieta v. Mahon, supra, 31 Cal.3d at p. 389, citing Mendoza v. Small Claims Court (1958) 49 Cal.2d 668, 672-673 [321 P.2d 9].) Notice reasonably calculated to apprise interested parties of the action, and an opportunity to be heard constitute the process required. (Arrieta, supra, 31 Cal.3d at p. 389, citing Mullane v. Central Hanover Tr. Co. (1950) 339 U.S. 306, 314 [94 L.Ed. 865, 873, 70 S.Ct. 652].) One evicted from his home by a writ of possession against another receives no notice and no hearing, and such an eviction violates fundamental constitutional principles. (Arrieta, supra, 31 Cal.3d at p. 389.)
*1349 The procedures contemplated by the Arrieta court were codified beginning in 1982. (See §§ 715.010 et seq., 1174.3, 16 Cal. Law Revision Com. Rep. (1982) pp. 1158-1159.) Section 1174.3 was enacted in 1986. Designed to protect tenants like Arrieta who are not named in the unlawful detainer judgment, the statute sets out a formal procedure for making a claim of right to possession, either to the court or to the sheriff levying the writ of possession. The statute provides in part: "... any occupant not named in the judgment for possession who occupied the premises on the date of the filing of the action may object to enforcement of the judgment against that occupant by filing a claim of right to possession as prescribed in this section.... Filing the claim of right to possession shall constitute a general appearance...." (§ 1174.3, subd. (a), italics added.) If the court determines the claim of right to possession is valid, it shall "deem the unlawful detainer Summons and Complaint to be amended on their faces to include the claimant as defendant...." (§ 1174.3, subd. (e)(2).) The complaint would then be served and defendant given an opportunity to respond. (Ibid.)
(1b) The difference between Arrieta, supra, and the instant case is that a statutory procedure for persons in possession but not named in the judgment for possession was in place when appellant was evicted. The sheriff argues that appellant should have availed himself of the procedure outlined in section 1174.3; that is, he should have presented a claim of right to possession to the court or the levying officer. We agree.
Appellant argues that filing a claim of right to possession was unnecessary because all he would have achieved was to be named as a defendant, and he was already named as a defendant. We reject this contention, and conclude that the statute literally and logically applies to appellant's case. The statute specifies the procedure for a tenant in possession who is not named in the landlords' judgment for possession to make a claim of right to possession. Appellant was such a tenant. If appellant had engaged in the statutory procedure, he would have gained more than just becoming named as a defendant; the filing of the claim of right to possession also constitutes a general appearance. A general appearance by a defendant is tantamount to an answer, which controverts the allegations of the complaint, and here would place at issue which party had the superior right to possession. Once he made a general appearance, appellant would have had the right to be heard, with counsel. (§ 1174.3, subd. (b); Mendoza v. Small Claims Court, supra, 49 Cal.2d 668.)
It is clear that the statutory scheme of unlawful detainer actions contemplates that service on a named defendant will be made if the action is *1350 pursued. A tenant actually in occupation, and a subtenant if there is one, are necessary parties defendant. (§ 1164.) A summons must be issued based on the complaint (§ 1166), and served and returned in the same manner as in other civil actions, except that the time to answer is shorter. (§ 1167.) After he is served with the summons and complaint, defendant may appear by answer or demurrer (§ 1170), and he has the right to a trial of the action. (§§ 1170.5; 1171.) A default may be taken only after a defendant served with summons does not appear to defend. (§ 1169.) As in other civil actions, the landlord-plaintiff can only obtain a default judgment, here a judgment for possession, after defendant has been served with process and fails to respond. (§§ 1177, 585.)
Appellant's rights were violated, but before eviction he could have protected himself by presenting a claim of right to possession. After eviction appellant could have sought an injunction or filed an action for declaratory relief against the landlords regarding their respective rights and duties under the lease, or he might have sought extraordinary relief from the court which issued the writ of possession. The landlords' alleged misrepresentation that there was no need for appellant to obtain a stay of the eviction may be actionable as well. Appellant had remedies from which to choose, but mandate was not one of them.
Mandate lies to compel an officer to perform his ministerial duty. (See 8 Witkin, Cal. Procedure (3d ed. 1985) Extraordinary Writs, § 70, p. 709.) Where the sheriff had a preexisting duty pursuant to the Government Code to return property seized upon an individual's arrest, issuance of a writ of mandate, ordering the sheriff to perform his duty, was appropriate. (Holt v. Kelly (1978) 20 Cal.3d 560, 564 [143 Cal. Rptr. 625, 574 P.2d 441].) Here, the sheriff properly executed a writ of possession, which was regular on its face. (Vallindras v. Massachusetts etc. Ins. Co., supra, 42 Cal.2d 149, 154.)
The landlords wrongfully deprived appellant of possession. Even if the sheriff had improperly evicted appellant, he was not under a present, ministerial duty to restore appellant to possession. Mandate does not lie. (Cf. Janson v. Brooks (1865) 29 Cal. 214, 216-222 [an action for forcible entry and detainer does not lie against person in possession by one wrongfully dispossessed, when sheriff in good faith although mistakenly turned out the one dispossessed].)
The trial court was correct in ruling that when appellant failed to present a claim of right to possession of the premises pursuant to section 1174.3, he *1351 was lawfully evicted by the sheriff and mandate was not an available remedy.
The judgment is affirmed.
Agliano, P.J., and Elia, J., concurred.
NOTES
[1]  Further statutory references are to the Code of Civil Procedure unless otherwise indicated.
