
40 Cal.2d 572 (1953)
WILLIAM HANLEY, Respondent,
v.
DANIEL C. MURPHY, Individually and as Sheriff, etc. et al., Appellants.
S. F. Nos. 18674, 18675.
Supreme Court of California. 
Mar. 30, 1953.
 Dion R. Holm, City Attorney (San Francisco), and Bernard J. Ward, Deputy City Attorney, for Appellants.
 Charles P. Scully for Respondent Hanley.
 Alfred J. Hennessy for Respondent Reilly.
 SPENCE, J.
 These appeals are from judgments ordering the issuance of writs of mandate requiring the restoration of the two petitioners to their respective former positions of superintendent of jail under the sheriff of the city and county of San Francisco, and the payment to them of the salary fixed for those positions in lieu of the compensation received by them following their demotion. The cases were tried concurrently before the same trial judge and are presented together on these appeals.
 The trial court found that the removal of petitioners from their former positions did not conform with the procedural requirements of the civil service regulations and was done in bad faith. The record sustains these findings and the judgments based thereon. *575
 Prior to July 1, 1947, petitioners were the respective superintendents for county jails No. 1 and No. 2 operated by the city and county. They had occupied these positions since 1935 following their appointment upon the basis of civil service promotional examinations. In 1936 appellant Murphy was elected sheriff of the city and county and, as such, he became responsible for the overall supervision of the jails. In 1947, pursuant to his determination to abolish the two positions of superintendent of jail, he failed to include them in his request for salaries as submitted in the annual budget estimate for the fiscal year 1947-1948 (which began on July 1, 1947). The propriety of this action requires consideration of applicable provisions of the San Francisco charter.
 The sheriff is an elective officer ( 5) and as one "in charge of an administrative office," he has "the powers and duties of a department head" ( 20). The last cited section further provides: "He shall act as the 'appointing officer' under the civil service provisions of this charter for the appointing, disciplining and removal of such officers, assistants and employees as may be authorized. ... Non-civil service appointments and any temporary appointments in any department or subdivision thereof, and all removals therefrom shall be made by the department head or bureau head designated as the appointing officer only with the approval of the chief administrative officer or the board or commission in charge, as the case may be. ... Each department head may suggest the creation of positions subject to the provisions of this charter, and may reduce the forces under his jurisdiction to conform to the needs of the work for which he is responsible, any other provision of this charter to the contrary notwithstanding." (Emphasis added.)
 Section 140 provides for "a civil service commission ... charged with the duty of providing qualified" personnel based "solely upon merit and fitness, as established by appropriate tests." The commission has sole power to classify and reclassify positions in both civil services and exempt employment; but its "allocation or re-allocation of a position shall not adversely affect the civil service rights of an occupant regularly holding such position." ( 141.) "Immediate notice in writing shall be given to the civil service commission by the appointing officer ... of the creation or abolition of any position, or of any change in duties if the position is included in the classified civil service, or of any ... dismissal or other creation of vacancy therein, with the date of any such change." ( 143.) "No person employed under the civil service provisions *576 ... in a position defined by the commission as 'permanent' shall be removed or discharged except for cause, upon written charges, and after an opportunity to be heard in his own defense," pursuant to specified procedure. ( 154.)
 Section 69 provides that a budget estimate must be prepared each year by the department head and filed with the controller prior to February 15th. Not later than March 15th the controller must consolidate such budget estimates and transmit them to the mayor. The mayor may hold public hearings and increase, decrease or reject any item contained in the estimates, except that he shall not increase any amount or add any new item for personal services.
 Section 70 in providing for the form of budget estimates, specifies that the estimates shall include or be accompanied by "(4) a schedule of positions and compensations showing any increase or decreases requested in the number of positions. ..." Section 72 requires the mayor to transmit to the board of supervisors not later than May 1st the consolidated budget estimates and proposed budget, with a draft of the annual appropriation ordinance for the ensuing fiscal year prepared by the controller and based on the proposed budget. A detailed schedule of positions and compensations showing any increases or decreases for any department must be included in the proposed budget, and the board of supervisors shall not increase any amount or add any new item for personal services.
 [1] Under settled rules of statutory interpretation, these several sections must be construed together, giving effect and meaning so far as possible to all parts thereof, with the purpose of harmonizing them and effectuating the legislative intention as therein expressed. (23 Cal.Jur.  134, p. 760; 18 Cal.Jur.,  81, p. 769; Ohlhausen v. Mills, 101 Cal.App. 754, 761 [282 P. 394]; Gallagher v. Foerst, 128 Cal.App. 466, 471 [17 P.2d 1065].)
 [2] It is clear from these provisions that the charter vests in the department head broad power in effecting the reduction of the forces under his jurisdiction ( 20) and the budget-making procedure accords therewith. Thus, when the department head files a budget estimate which decreases the number of positions in his department as shown in the accompanying schedule ( 70, subd. (4)), such eliminated positions may not be added by the mayor ( 69) or by the board of supervisors ( 72), for both are forbidden "to add any new item for personal services." The only manner in which a *577 position omitted by the department head from his original budget estimate may later be added is the qualification permitting the board of supervisors to so act on request by the mayor and on the recommendation of the department head. ( 72.) This did not take place here.
 But at the same time the department head in removing employees from positions in his department, must act in conformity with applicable civil service regulations. ( 20.) So it was said in Childress v. Peterson, 18 Cal.2d 636, at page 639 [117 P.2d 336]: "While the executive officers of a city, acting under enabling legislation, have plenary power to exercise full administrative judgment and control over city employees and to promote a program of economy in good faith, they are required in the enforcement of their judgment to act in conformity with charter provisions and procedural requirements." [3] The civil service system rests on the principle of application of the merit system instead of the spoils system in the matter of appointment and tenure of office. (Barry v. Jackson, 30 Cal.App. 165, 169 [157 P. 828].) To that end the charter establishes a classified civil service system, with exclusive power in the civil service commission to provide qualified personnel for the various municipal departments and to classify or reclassify positions according to prescribed duties. ( 140-143.) Moreover, in protection of employees who have obtained permanent civil service status, the charter provides that they be given due notice in writing as to the cause of their removal from office. ( 154.) [4] Accordingly, although the department head, in the exercise of his administrative discretion, may effect a reduction of employees in his department pursuant to his judgment as to the needs of the work "any other provision of this charter to the contrary notwithstanding" ( 20), such quoted clause cannot reasonably be construed to mean that the department head is subject to no limitation under civil service regulations. Rather, under authority of section 20, he must have due regard for applicable civil service procedure on the subject of personnel classification and protected tenure in office for employees.
 [5] Since appellant Murphy did not proceed in conformity with the applicable civil service provisions, the situation is not one coming within the principle that "where there is a legal right to do a certain act, the motive which induces the exercise of the right is of no importance." (Monahan v. Department of Water & Power, 48 Cal.App.2d 746, 754 [120 *578 P.2d 730]; also Neuwald v. Brock, 12 Cal.2d 662, 675-676 [86 P.2d 1047].) It is only in cases where the public body pursues its authority in strict accordance with law or, in other words, in pursuance of a legal right, that the question of motive becomes immaterial. The trial court therefore correctly determined that the issue of bad faith on the part of appellant Murphy was a material issue in the disposition of these cases.
 The record shows that since 1936 and until July 1, 1947, petitioners Hanley and Reilly had held their respective positions of superintendent of jail and performed the classified duties in connection therewith--Hanley at county jail No. 2 and Reilly at county jail No. 1. Neither had ever been charged with misconduct or any dereliction of duty in the discharge of his work. The undersheriff testified that at the request of the sheriff, appellant Murphy, he made an investigation of the two jails in October or November, 1946, and recommended that their effective operation would not permit the abolition of the duties of a superintendent, though the position itself were eliminated. Following the termination of the respective positions as of July 1, 1947, the duties thereof were performed partly by the undersheriff, partly by the sheriff's secretary, and largely by captains of the watch stationed at each of the two jails.
 Appellant Murphy testified that efficient operation of the two jails requires a responsible person on the premises in charge during the entire day; that prior to the filing of his budget estimate in March, 1947, omitting the salaries for the two superintendents for the next fiscal year, he did not advise the civil service commission either of his intent to eliminate such positions or the reasons for their omission; that he never responded to the commission's letters of inquiry of March 19 and April 10, 1947, and that in so proceeding, he acted on his own counsel and was not being advised by any other city official. Both of these letters specifically called to appellant Murphy's attention the "provisions of section 143 of the charter under which appointing officers are required to give immediate notice in writing to the Civil Service Commission of the abolition of any position or of any changes in duties of positions included in the classified service" and expressly requested advice as to "the circumstances surrounding the abolition of these two positions and also ... who will perform the duties" thereof. Again on June 27 the commission wrote to appellant Murphy inquiring as to the "proposed *579 elimination" and stating that in the event such action was "a bona fide abolition of the duties of the position" and there were no charges filed against petitioners as cause for their removal from office ( 154), petitioners were entitled to return to the former positions they respectively held in the service. Appellant Murphy responded by letter of June 28, 1947, stating that "by virtue of the abolition of the positions of Superintendent of Jail," effective July 1, 1947, he was returning petitioners to "the next highest position which they occupied prior to their promotion to the position of Superintendent of Jail"--Hanley to a position of captain of the watch and Reilly to a position of writ server. This was accordingly done.
 Appellant Murphy also was questioned about a newspaper article published as the result of an interview that he had with reporters about the time in March, 1947, when his budget was submitted omitting the positions of superintendent of jail. In the article appellant Murphy had referred to his displeasure at petitioners' success a few months preceding in obtaining a salary increase through a change of classification with the commission, his belief that others in his department work "a lot harder ... and for a lot less money," and that there was "a lot of discord after the two 'superintendents' got their big raise." The article also noted appellant Murphy's statement that he was "just forgetting to include their salaries in the budget" and his comment on the likelihood that "there'll be a row and ... they'll go running to the Civil Service Commission." Appellant Murphy testified that these statements in the article were substantially correct. He further stated that the article's added reference to the purported claim that the superintendents' charges before the labor council was the cause for his suspension therefrom was not entirely accurate, as he had then told the reporters that he did not know whether "either or both" of such charges had anything to do with that particular matter.
 The personnel director and secretary of the commission testified that he could not see "how you could abolish a Superintendent's job if the institution remained in operation," and that he so informed the undersheriff prior to the latter's investigation of the two jails in the fall of 1946; that the commission was unable to make a ruling as to the propriety of appellant Murphy's action in attempting to abolish the superintendent positions because of the latter's failure to supply the necessary information for reclassification purposes, *580 although previously with respect to another classification in his department appellant Murphy, on advice from the commission as to the appropriate procedure, had submitted the needed information and reclassification occurred; and that the classification of superintendent was accordingly never abolished by the commission. He further testified that appellant Murphy had advised the commission that after July 1, 1947, he and his undersheriff would perform the duties previously assigned to the superintendents in the two jails; that shortly after the "reorganizations had been effected," the commission received a request from an employee organization in the department asking for an investigation of the manner of the operation of the two jails "as far as the assignment of duties was concerned"; that a member of the commission's staff undertook the investigation and pursuant to the report made in October, 1947, and questionnaires completed by the employees, the commission found that various other "inferior employees" at the respective jails were performing duties that belonged to the position of superintendent according to the scheduled classification of duties; that the questionnaires were reviewed and signed by appellant Murphy without change or comment; that thereafter in November, 1947, the commission met with appellant Murphy and advised the latter as to the result of the survey showing that the duties formerly performed by the superintendent were necessary in the operation of the jails and were then being performed by other "inferior employees"--jailers and captains of the watch--which procedure was not permissible under the classified civil service; that appellant Murphy said that such procedure would be discontinued in his department and he would so advise the commission in writing, but no such communication was ever received from him; and that no further investigation was undertaken by the commission to see if the promised changes were made as "the matter was then in litigation." This witness also stated what constituted a classified civil service, the duty of the commission to classify the positions in the service, the requirement of department heads to submit information for such purposes to the commission, and the inability of the commission to act properly in the classification of positions in a department unless such information is so furnished.
 Petitioners testified that from their experience as superintendents of jail and the performance of the classified duties attached to the position, they believed that efficient operation of the jails required such a responsible person to be in *581 charge. Petitioner Hanley stated that the first advice he had from the department as to the change in his position was the notice from the undersheriff about 4:30 p.m. on June 30, 1947, that he "would no longer be an employee of the Sheriff's office"; that at 5 o'clock that afternoon the undersheriff further notified him that he was to "be reduced to captain of watch" and was to report to county jail No. 1; that he never was given a reason for his demotion nor was he ever advised by the commission that his former position of superintendent was abolished; that upon reporting to his new assignment, he was placed under another captain of the watch who had less seniority status, and then transferred permanently to a night shift at county jail No. 1; that while there as a captain of the watch he, other captains of the watch, and even jailers had regularly performed duties previously assigned to the superintendent. Petitioner Reilly stated that the first notice he had from the department as to his change of position was a telephone call from appellant Murphy about 4:40 p.m. on June 30, 1947, ordering him to report the next morning to the city hall as a writ server; that he was never given a reason for his demotion nor did he receive any notice from the commission that his former position had been eliminated.
 [6] The evidence summarized above adequately supports the trial court's finding that the removal of petitioners did not conform with the procedural requirements of the civil service regulations and was done in bad faith. (See Childress v. Peterson, supra, 18 Cal.2d 636, 644.)
 As above indicated, the civil service system was adopted to protect governmental employees and society from the spoils system in the matter of appointment to office. (Barry v. Jackson, supra, 30 Cal.2d 165, 169.) [7] One of the chief purposes of civil service regulations is to safeguard honorable and efficient employees from arbitrary ouster, for the method of dismissal is as important as that of selection and appointment. (Winslow v. Bull, 97 Cal.App. 516, 523 [275 P. 974].) [8] Manifestly, civil service rules do not guarantee to officers or employees the tenure of positions which are no longer required (10 Am.Jur.  12, p. 933; annos. 4 A.L.R. 207, 37 A.L.R. 816, 172 A.L.R. 1369); and it is highly desirable from a standpoint of personnel efficiency, as well as in accord with considerations of public economy, that the department head may have the power to reduce his staff. [9] But since the record here supports the trial court's finding that appellant Murphy, in the purported exercise of his power to *582 effect a reduction of the forces, acted in disregard of the prescribed civil service procedural requirements and in bad faith, petitioners are entitled to be restored to their respective positions under civil service rating. (Powers v. Board of Public Works, 216 Cal. 546 [15 P.2d 156].)
 The judgments are, and each of them is, affirmed.
 Gibson, C.J., Shenk, J., Carter, J., and Traynor, J., concurred.
 SCHAUER, J.
 I dissent. The sheriff of the city and county of San Francisco is a department head and by the express provisions of section 20 of the San Francisco charter is authorized to "reduce the forces under his jurisdiction to conform to the needs of the work for which he is responsible, any other provision of this charter to the contrary notwithstanding" (italics added). Acting under this power the sheriff abolished two positions of superintendent of jail. Hanley and Reilly, respondents herein, who had held the two positions were not discharged from employment; they were merely returned to the next highest positions which they had occupied prior to their promotion to jail superintendent. The evidence is undisputed that no one else was appointed to occupy the two positions and no new positions to take over the duties of jail superintendent were created; rather, the duties of the abolished offices were absorbed by personnel already employed; such duties were assumed partly by the undersheriff, partly by the sheriff's secretary, and partly by captains of the watch stationed at the two jails. There was thus no pseudo, but an actual, abolishment of the two superintendent positions, and the finding of the trial court that the sheriff acted in bad faith must necessarily relate to a purely metaphysical concept. In respect to the conduct of the duties of his office the finding simply is not sustained by the evidence.
 It is my view that the efforts of governmental heads to reorganize their offices for purposes of efficiency and the saving of money for the taxpayers without any curtailment of the duties performed is highly commendable and should be supported and encouraged rather than unnecessarily, let alone arbitrarily, stricken down by the courts.
 Upon the undisputed law and facts, the judgment should be reversed.
