In an overcrowded and chaotic city like Cairo, long on history but short on facilities, a short-notice visit by the president of the United States is not just a historic event, it's a logistical nightmare.

Egyptian and American officials were scrambling around the capital this morning, cursing the antiquated and overburdened telephone system, in a frantic rush to arrange hotel rooms, security and communications for the president, his entourage and the press.

And if the Egyptians prevail, the entire performance will have to be repeated in Alexandria, where they want President Carter to spend part of his stay. Alexandria is less crowded this time of year, but has even worse international communications than Cairo, and the Americans had reportedly tried to resist President Anwar Sadat's desire to have Carter travel to the port city in an open train.

Almost up to the minute that national security adviser Zbigniew Brzezinski and roving ambassador Alfred Atherton landed at Cairo airport today with an advance party of 65, it was uncertain where they would stay or when or where they would meet any Egyptian officials.

The Foreign Ministry, Sadat's presidential staff, the U.S. Embassy and the State Information Service were suddenly confronted with a need to produce in massive quantities commodities that are normally in short supply -- hotel rooms, telex lines, telephone connections and quick decisions.

The difficulty of their task was compounded by the city's heavy traffic, the distances between key points in the itinerary, and the balky telephone system, made even more unfathomable by the fact that some 15,000 numbers in the center of the city were changed this week and no directory of the new ones has been published.

For most of Carter's party, including the 200 members of the press corps accompanying him, the question of accomodations was solved when the government commandeered the entire 400-room Nile Hilton Hotel, which is in central Cairo near the U.S. Embassy and the Foreign Ministry.

Security guards were posted outside, communications workers installed telephone lines and the Hilton management gave the bad news to its guests -- out.

By midafternoon dislodged guests were already being put out into streets darkened by the year's first sandstorm, and all will have to go by Wednesday night. There were angry scenes at the reception desk as guests holding confirmed reservations arrived to be told they could not check in.

"We've asked the presidency to help us find room in other hotels," a Hilton spokesman said with a helpless shrug, "but it's the height of the season." Cairo has a chronic shortage of hotel rooms anyway, and all those above the grade of fleabag are usually booked weeks in advance.

The next biggest headache is the press -- not those coming from Washington with Carter but the estimated 300 who are not part of the official entourage, coming mostly from Europe, who are demanding accreditation, hotel rooms and telex facilities.

Accreditation is not a problem, except that the Egyptian presidential security staff was demanding that the names of all journalists accredited to cover the visit be submitted by tonight. Since most of them are not arriving until Wednesday or Thursday, it was not clear how they will get their names on the all-important list that gives access to the key events. As for hotel rooms, Nabil Osman, the director of the Cairo press center said, "I'll do what I can, but I can't guarantee anything."

While Brzezinski and Atherton are staying at the Hilton, Carter and Secretary of State Cyrus Vance will be housed at the opposite end of the city, in the ornate Kubbeh Palace, where Richard Nixon stayed in 1974.

By tonight, almost the entire schedule for Carter's visit, except his arrival and departure times, was still being negotiated. The government is organizing the kind of rousing popular turnout that is an Egyptain specialty, but it entails mammoth security problems, as does a ride in an open train to Alexandria. When Carter makes the train trip, he will pass, in the town of Benha, a sign reading, "Welcome Nixon, man of peace from the land of peace." There has not been time enough to change it.