No lease termination notice is required in certain situations, such as where the lease has expired. Or where the occupant is a subtenant and an incurable breach has occurred. Other times, a notice is required, but "service" of a lease termination notice does not necessarily mean that the notice was personally served on the occupant. If the occupant is not available, the notice may be served on another occupant and mailed, or posted in a conspicuous place on the leasehold property and also mailed. In these instances, the legal question is not whether the occupant received the notice, but whether the landlord followed the rules for serving it.
A summons and complaint should have been served on you before the Sheriff's notice. But again, if you were not available to be served, there are alternatives to personally serving you, such as "sub-service" (serving an adult affiliated with you, such as a spouse or co-tenant, plus mailing a copy to you) or serving you by publication. Again, the issue here is not whether you actually received the summons and complaint, but whether the landlord followed the rules in serving you.
That being said, if you actually did not have notice of the lawsuit in time to prevent entry of default, you have the right to apply to the court for orders to stay the eviction, set aside your default, and permit you to file an answer or other responsive pleading in the unlawful detainer action. You will need to act immediately or it will be too late. I highly recommend that you hire an attorney right away if you wish to avoid being evicted by the Sheriff and/or wish to avoid the damage to your credit rating. It is also possible that you are exposed to a money judgment if you don't get the judgment set aside.
Your question seems to suggest that there has been a UD action litigated to a judgment for possession. By the time the Sheriff posted the 5-Day Notice To Vacate on your door, your presence on the property is no longer legal. The next thing that's going to happen is that there will be a lockout date. Sheriff usually will not tell you when it would be. But quite often they will show up a little after the 5 days that they gave you. To answer your question, yes, that's legal.