The office of sheriff, rooted in medieval times and glorified in the Old West, is not what it used to be. The salary compares poorly to other highranking government jobs, the perquisites are minimal and the power is diminished.

Nonetheless, 10 candidates are running in Montgomery and Prince George's Counties-most with low budgets but high hopes-in Tuesday's Democratic primary for the $25,000 a-year job overseeing courtrooms and transporting prisoners. Running the jails, once an important function of the office, was delegated to a separate corrections department in Prince George's last year and in Montgomery years before that.

In Montgomery County, three Democrats are actively trying to unset incumbent Sherrif James A. Young, who was appointed to the job 30 months ago, and a fourth challenger has not campaigned actively.

In Prince George's, five Democrats are running for the office of incumbent Don Edward Ansell, who campaigned as a reformer in 1970 and is now retiring to run a restaurant after his acquittal earlier this year on charges he misappropriated $1,920 from a deputies' banquet.

In Montgomery, Young has the lacking of the Montgomery County Democratic slate composed of incumbents and party regulars and the strong Prince George's County organization has endorsed James V. Aluisi, the 32-year-old son of a former county commissioner.

For Aluisi, who says his main goal is to "return credibility" to the department, the role of establishment candidate has an ironic twist. As a captain in the sheriff's department, Aluisi became one of Ansell's most fitter foes. Once labeled a maverick, he is now alleged to be part of the machine."

As a beneficiary of "Dems 78" organization backing, Aluisi's name and picture appears in brochures the slate mails to voters, "you really can't beat the mailings," said Aluisi. The organization that endorsed him also assessed him $4,000, his largest campaign expense.

If elected, Aluisi promises to bring back many of the deputies Ansell fired, and to support their demand for collective bargaining, which Ansell opposed.

Aluisi's strongest opponent may be 43-year-old William N. McKeever, Jr., who ran twice before as a Republican against Ansell. This time around, he is running as a Democrat, with the support of Ansell, McKeever said.

"It's kind of ironic, isn't it?" said McKeever, a former D.C. policeman who is now a private detective. "Don is helping by the word of mouth, every way he can. He still has some friends out there. I accept any support I can get."

McKeever sounded the anti-machine theme. "People are sick of that crap," he said. Another candidate, former deputy sheriff Alvin M. Wall, unsuccessfully sought the organization's backing. Wall, a senior methods specialist for Western Electric Co., is now "fighting the machine" with a meager $1,700 campaign chest.

"'Dem '78' is a very formidable," said Donald Eisenger, 36, a systems analyst and part-time District Heights police officer seeking the sheriff's post. Eisenger hopes his endorsement by the insurgent Alliance of Independent Democrats will boost his shoestring campaign.

A fifth Prince George's candidate, George A. Underwood, is a Forestville scrap dealer whose other credentials include absolutely no law enforcement experience and a string of convictions for bulglary, armed robbery and using "false pretenses," stretching from 1956 to 1977.

These credential could be considered political handicaps, but Underwood shrugs, "I figure you got to start somewhere." He adds, "when you get down to it, 90 percent of politicians are crooks anyway."

"My criminal record is all behind me," he said. What's more, while other politicians with large war chests may find themselves beholden to campaign contributors, Underwood said, "I didn't accept money from nobody."

Meanwhile, in Montgomery County, the race for sheriff has been enlivened by one candidate's proposal to abolish the elected office. Instead, according to real estates agent Ruth Vurek who believes the job is purely administrative, the sheriff should be appointed.

The incumbent, Young, 54, opposes any change in the current arrangement because "the system works." A former president of the Maryland State Sheriffs Association, Young takes credits for the merit employe status enjoyed by Montgomery deputies.

In his campaign, Young has raised $8,145-the largest amount of any candidate for the job in both countries-and spent $7,970. He has also spent $1,847 for two fund-raisers at the Brooke Manor Country Club, which has contributed $400 to his campaign.

Vurek has raised questions about the contribution and Young's free membership at the club for six years when he was a deputy. "I very seldom used it," said Young in his defense. While Vurek, who has been endorsed by an opposing slate, and Young slug it out, two other candidates are hoping to beat the odds.

"I got a shot but it's difficult to beat the incumbent," said John C. Lammers, former acting director of the county police department who recently retired as security director for Leisure World."I think I'm most qualified," he said.

Bunny Johansen Galladora, a deputy sheriff, is running as much against Vurek as Young. "Ruth Vurek has hurt my campaign," he said. "She will split the women's vote. It's very unfortunate because I don't think she knows that much about being an administrator.

Nonetheless, Galladora believes she "just might be able to pull it off" with her family-centered campaign. Her father, a professional magician, and her brother and sister, who are puppeteers, entertained at Galladora's only fund-raiser-a $1 a ticket affair for children that netted $49.50. business or owing favors," she said. "This is my first time in politics."