There are two types of taxis here. The first is the black and white cars with the sign on top. The second is just regular citizens who own a car and wanna make extra money/a living off of it (Libyans call them "private cars").
The black-and-white taxis are licensed by the government and are practically guaranteed to be safe. The "private cars" -while technically illegal- are very widespread (and here in Benghazi actually outnumber the real taxis -dunno if that's also the case in Tripoli) and are cheaper. They are usually safe during the daytime but it's not a good idea to ride one at night, especially if you're a foreigner.
Here are some common sense rules to follow when taking either type of taxi:
1. The first and most important rule is that no matter which type of taxi it is, NEVER, EVER get in when there is more than one person in the car. Don't think you're safe if you have them outnumbered - you'll most probably be taken to a dark alley where they have plenty of friends waiting.
2. At night, do not ride in private cars. It's better to pay more for a government taxi and get there safe than to take a private car and risk something nasty happening to you.
3. Try not to ride alone at night.
4. Negotiate your price BEFORE you get in the car.
5. Make a mental note of the car's license plate number before you get in, just in case. Try to be discreet about it.
6. Pay only after you get to your destination.
7. Don't act like a pushover. Most people here are cowards. They won't usually feel brave enough to attempt to rob you unless they perceive weakness or timidness. If you've been a timid person your whole life, your stay here in Libya would be a good time to change that and develop a stronger personality.
8. If you DO end up getting caught in a nasty situation, do not put up any form of resistance. First, mention in a very calm, emotionless voice that you have the car's license number memorized. Then do what you're asked without saying anything. If you're asked to hand over your money, phone, and watch, do it. Your valuables can be replaced; your life can't.
The exception is if you happen to be a karate black belt or ex-navy seal. In which case disregard all that and feel free to fight your way out.