Prepare the spaghetti according to the package instructions, then drain and set aside.
In a large skillet, cook the ground beef over medium heat, breaking it into crumbles as it cooks. Add the chopped onion and minced garlic, cooking for 6 to 8 minutes or until the beef is no longer pink. Drain any excess fat, then incorporate the spaghetti sauce, salt, and pepper. Bring the mixture to a boil, then reduce the heat and simmer uncovered for 20 minutes, stirring occasionally.
In a small bowl, blend the cream cheese and sour cream until smooth, then stir in the chopped green onions. Grease an 11x7-inch baking dish, then layer with half of the spaghetti, spreading it evenly across the bottom. Top with the cream cheese mixture, followed by the meat sauce. Repeat layers if desired. Finish by sprinkling the shredded cheese over the top.
Cover and bake at 350°F for 25 minutes. Remove the cover and bake an additional 5 to 10 minutes, or until the cheese is melted and bubbly. Allow to cool slightly before serving.