A lot of actors get jobs on television series, and once their bills are paid off they start to champ at the bit, rebelling at the long hours, the essential mediocrity of the material and the fear of being perpetually typecast as their TV persona. Not Hal Linden.

Even after eight years as "Barney Miller," the genial, compassionate 12th precinct police captain, Linden was sad to see it go last year and still talks about it with affection and enthusiasm. "I can't recall a single episode that I walked away from with my head hanging," he said.

Linden, at 52 a suavely handsome fellow with gray hair, is in town starring in "Room Service," a 1937 farce that represents his first major return to the theater since the advent of "Barney Miller." In it, he plays another Miller, this time Gordon, a ne'er-do-well Broadway producer with more plans than cash. It's a basic door-slamming farce--the Marx Brothers made a movie of it--for which Linden claims no pretenses.

"This play has no function other than to make people laugh," he said. "It's the kind of play that old saying was about: 'If you want a message, go to Western Union.' "

There is a possibility the play will move on to New York; a decision that Linden, director Michael Kidd and the Kennedy Center will make during its five-week run here. Linden is no stranger to New York, having spent an 18-show career there before being baked under the bright lights of TV-land. "All my shows on Broadway were bombs," he said, with only slight exaggeration. He did win a Tony award for his performance as the father in "The Rothschilds," which opened in 1970 and ran for 507 performances.

His route to the theater was through music. Linden, ne' Lipshitz, was born and raised in the Bronx, the son of a Lithuanian who emigrated to the United States at 14 and learned the printing trade, later becoming a partner in a small business. The Lipshitz family put a high premium on music lessons, "for culture," and Linden, his brother and various cousins were instructed so thoroughly that four of them became professional musicians. Linden spent 12 years playing the clarinet and the saxophone in big bands, started singing as well, and from there slid into musical theater. His first theater job was at the Cape Cod Melody Tent, a summer stock theater where he was in the chorus of 10 shows in 12 weeks.

"At the end of the summer I was sitting around one day wondering what I should do next. Go back to playing the clarinet? Assistant conductor Johnny Morris said, 'Stick with it.' So I did."

For a while Linden alternated band jobs with auditioning and small chorus parts, but when he got his first big job--as understudy to Sydney Chaplin in "Bells Are Ringing"--he decided to forgo his career as a clarinetist/saxophonist. "I guess I was afraid that if I went back, I'd stay back," he said. "I had offers to run bands, and there was a temptation to do that, but I did a lot of unemployment insurance instead."

He does keep his mouth in shape, however, by playing in his night club act and in occasional jam sessions, like one the other night at a restaurant opening in Baltimore that went on until early morning. "Maybe one of these days I'll put together a big band," he mused.

The worst show he was ever in, he said, was called "Strip for Action," and it closed in Pittsburgh. "But I didn't think it was terrible at the time . . . Maybe I was just an eternal child, but as bad as a job was, there was always something that got me involved."

Even the good shows would close too soon after he got into them. They were mostly chorus jobs or small parts and, at 27, when he took over the Chaplin part in "Bells," he did not think of himself as Leading Man material but as a character actor. "In those days all the leading men were pretty," he said. "Like Troy Donahue and Tab Hunter." Now his lean, ethnic good looks are very Leading Man, and that's what he plays.

When he was cast in ABC's "Barney Miller," he recalled, the omens were not great. "I was not a TV name, we were on the third network, and in a lousy time slot . . . The first 13 shows were a flop. The reruns on now draw more than we did in prime time."

The show gradually attracted a loyal following, which he attributes to the integrity of producer Danny Arnold. The emphasis was on realistic solutions rather than "instant gratification," he said, citing as an example one episode in which the black cop, Harris (played by Ron Glass), was shot at by another policeman.

"The assumption was that a black man in plain clothes with a gun had to be a bad guy," he said. "Harris took offense at our acceptance of that establishment point of view . . . The last scene called for him to apologize to me for getting angry. It was 3 a.m. and we were doing this scene, and suddenly Glass just stopped and said, 'Why should I apologize?'

"So with four cameramen and all the technicians there, on overtime, we sat down to thrash out how we could best accomplish this scene, so that he as an actor and as a human being could come up with something closer to life."

What they came up with was an exchange less definitive than an apology, with Harris asking Miller what he was going to do the next time it happened, and Miller saying he hoped he would know how to handle it better.

Linden's television fame, while briefly embarrassing to his three daughters, who couldn't understand why their friends blushed and giggled when introduced to Dad, has enabled him to advance to a point in the theater where the production is tied to his name. He has been offered several musicals, but turned them down, and is still looking for the right one. Meanwhile, he is doing "Room Service," conscious of the responsibility that comes with being the star, and awed by the exhausting demands of farce. "It's very hard work," he said. "It's relentless."