Boil the spaghetti in plenty of salted water, cook al dente. Gently warm the olive oil and add the garlic and rosemary. Strain the spaghetti and toss in the oil and herb mixture, season with salt.
Serve at once. If desired, Parmesan cheese can be served with this dish.