Quick and dirty:
Restricted Line and Staff Corps are their own officer groups, as is Unrestricted Line. I’ve written numerous posts in this but at the moment don’t have the time to go grab one.
Unrestricted essentially means these officers may command afloat or ashore, in or out of their specialty, operationally and administratively. That covers all the big URL seagoing communities.
RL and Staff Corps work almost 100% within their own specialties and may command within their specialty. They may also go to sea, but will not command a ship, sub, squadron, battle group, SEAL or EOD unit.
Staff Corps provide specialized skills in their profession: law, medicine, dentistry, nursing, civil engineering, chaplaincy, etc.