Nestlé, the Swiss food giant that helps bring the world Stouffer’s frozen dinners, Kit Kat candy bars and even L’Oréal hair coloring, is feeling pressure to change its corporate recipe.

Late on Sunday, the activist investor Daniel S. Loeb informed Nestlé that he had amassed about $ 3.5 billion of its stock and would like to see the company make big changes. Among them: for Nestlé to sell its stake in L’Oréal, because it has nothing to do with food, and to winnow its portfolio, which currently has more than 2,000 brands, by selling off those that do not add much to the bottom line.

The problem faced by Nestlé and other food giants is that many of their traditional brands are under intense pressure not only because of changing popular tastes but also because of the way people discover and buy the foods they like. Sales of classic brands have plateaued, and upstarts are grabbing market share, leaving companies like Nestlé struggling to adjust.

While Mr. Loeb’s stated interest is to increase returns to shareholders like himself — in a letter to Nestlé from his hedge fund, Third Point, that Mr. Loeb made public on Sunday, he said that selling the L’Oréal stake would be a good first step to “dramatically improve both the growth profile and earnings of the company” — his actions were also likely inspired by these tectonic shifts in the way people eat and shop.

Traditional grocery stores can no longer make or break brands. That works against legacy companies like Nestlé and Campbell Soup, which long used their lock on shelf space in the stores to secure their success.

Today, a growing number of people are buying their groceries online. The shelf has become a box, shipped from a meal-kit company, that delivers everything people need to make dinner for four right to their kitchens.

“Traditionally, consumer-product companies bought fast-moving little brands and pushed them through their vast sales forces and onto retail shelves,” said Jonathan Feeney, an investment analyst at ConsumerEdge. “But that distribution mechanism isn’t what it used to be.”

Nestlé has already taken some steps to combat the changes. It stripped carrageenan, a thickening agent that some consumers have soured on, out of some of its ice creams. It invented a new way to shape sugar crystals so that it can use less sugar in some products without sacrificing taste. It has invested in Freshly, a subscription meal-kit company, in hopes of finding a new route into people’s pantries.

And it is selling its United States confectionery business, which includes brands like Crunch and Raisinets, as snack lovers continue to migrate away from sugary treats to things like flavored popcorn, coconut chips and other options perceived as healthier. Last year, Nestlé’s confectionery business generated $ 922 million in sales, and analysts believe it could sell for as much as $ 3 billion.

And in a more prosaic money-saving move, Nestlé has relocated its United States headquarters to lower-cost Arlington, Va., from California.

Rivals are doing similar things. But no legacy company has yet managed to reverse a loss in market share.

Only the Kraft Heinz Company, after a merger engineered by the private equity firm 3G Capital and Berkshire Hathaway, has won favor with investors, and that is largely because of dramatic cost cuts. The combined company fired thousands of people and stopped stocking the refrigerators in Kraft’s corporate lunchrooms with free snacks from the company’s portfolio.

But even that company’s volume sales have been mixed at best, said Brittany Weissman, a consumer analyst at Edward Jones, a financial advisory firm.

Mr. Loeb has acknowledged some of Nestlé’s actions and has even applauded its decision to offload its candy business. But he believes many of those efforts have been “incremental” and will not help much.

“Nestlé has fallen behind over the past decade in an environment where growth has slowed due to changes in people’s tastes and shopping habits, as well as an influx of new competition from smaller, local brands,” Third Point wrote in its letter. “While its peers have adapted to the lower-growth world, Nestlé has remained stuck in its old ways.”

Nestlé released a statement on Monday saying: “As always, we keep an open dialogue with all of our shareholders, and we remain committed to executing our strategy and creating long-term shareholder value. Beyond that, we have no specific comment.”

But in a call with analysts in April, Ulf Mark Schneider, Nestlé’s chief executive, hinted that the company was feeling pressure from “activist investors” and said it was committed to improving its growth and cutting costs. On that call, Mr. Schneider said he was “encouraged” by investor meetings this year showing support for his steps. “Having said that, we do understand from these meetings that you want to see meaningful steps towards improved combinations of growth rates and margins,” he said.

Ms. Weissman said the results of the cost-cutting that took place when the H. J. Heinz Company merged with the Kraft Foods Group in 2015 have drawn interest to other big food companies, long regarded as dull by investors like Mr. Loeb.

Under 3G’s control, Kraft Heinz has drastically increased its profit margins by using a cost-management practice called zero-based budgeting, Ms. Weissman said. The practice requires managers to re-examine every cost each year and cut those that no longer produce profits. 3G is also famous for keeping a tight grip on administrative expenses — limiting the use of printers, for example, and requiring employees to sleep two to a hotel room when traveling.

Today, its profits before taxes, depreciation and other nonoperating expenses are the highest in the industry.

“Kraft Heinz has helped people understand how bloated these companies are,” Ms. Weissman said. “Especially at a time when sales are slowing, investors are going to begin looking to reduce costs.”

But even 3G has struggled to increase volume sales in the businesses it has bought. This year, Kraft Heinz made a $ 143 billion run at Unilever, another large European food and consumer products company.

That deal was unsuccessful, but it forced Unilever to take action — and fast. The company quickly announced it would buy back $ 5.3 billion worth of its shares and combine two large divisions, and it set a target for operating profit margins of 20 percent by 2020, all of which investors had wanted.

Unilever is also selling off its spreads business, which includes brands like Country Crock and I Can’t Believe It’s Not Butter, which was developed in 1979 as an inexpensive alternative for the food service industry. (Food lore has it that the husband of a secretary at the company exclaimed, “I can’t believe it’s not butter,” thus giving the retail version of the product its name.)

At the time, consumers were looking for ways to reduce fat in their diets, and the products were vast improvements on margarine. But times have changed, and people today know that some fats are good for them.

Nestlé is making similar adjustments, but Wall Street does not see those changes making a difference fast enough.

“Their answer to a lot of the issues they confront has so far been these kinds of incremental things,” Mr. Feeney, the investment analyst, said. “When real, technology-driven disruption happens like the disruption they’re facing today, I think a different philosophy to change is required.”