Usually you have to hold H1B or L1 visa and your employer sponser you for green card application. This takes for a few year (2-5). In the meantime, if you get laid off, you have to leave US immediately. H1B does not have a grace period technically, however, you might be able to stay a few more weeks if you can prove you already have a new offer.
If you have a green card, you have to stay 6 months each calender year in US unless you get acknowledge from INS. But still you have to re-new such kind of permission every year (two years in special case). One more thing you must be aware is that you always have to pay US tax no matter where you work and live, even you do not have a tie in US.Otherwise, you must have trouble someday. You know how tough US is and will be.
For some people hold E1B kind of visa, they are the first priority in the process of green card application so that they will get it probably less than 6 months. But this does not apply to most of the people.