1

Sometimes, I need to create a login session (create windowserver instance, run login items / launchagents) of an admin user, because a lot of software cannot be run under root (but can be run as another user using sudo -u <admin user> <path to app executable> (which requires a windowserver instance of that user or else it will hang every few seconds)), and I don't want to spend a minute logging into another user, waiting for everything to load, and then log back to root. How would I simulate a real user login in command-line?

8
  • You should never need to run anything as root. To quickly switch to a pure admin account I usually use Fast User Switching (without logging out). – nohillside Dec 29 '20 at 7:25
  • Most applications actually ask for permission if they need additional privileges and are run from a standard account. Is there a typical use case which isn‘t covered by this? – nohillside Dec 29 '20 at 7:26
  • 1
    JoyJin: Just curious, what "software cannot be run under root"? – David Anderson Dec 29 '20 at 9:15
  • @DavidAnderson Most of Rogue Amoeba's application (sudo -u works), OneDrive (sudo -u don't work so a login is required), Microsoft OneNote and Outlook (sudo -u don't work), opening online documents and accessing recently opened documents for Microsoft Word/Excel/PowerPoint (sudo -u don't work, partially works if app sandboxing is turned off), App Store (network failure if sandbox is not switched off), iBooks (just won't work). – Joy Jin Dec 30 '20 at 8:39
  • @DavidAnderson Also touch bar (apple.stackexchange.com/questions/401630/…), heif (apple.stackexchange.com/questions/399610/…). – Joy Jin Dec 30 '20 at 8:46
1

To quickly switch between accounts/logins, enable and use Fast User Switching. First login will (of course) take a while as usual, but afterwards switching is very quick. And unless you run big CPU-hogging applications in several accounts at once the additional resource needs are minimal.

1
  • 1
    @JoyJin This seems to be a rather specific problem, for most users who need to quickly switch between GUI sessions it works rather fast. – nohillside Dec 30 '20 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .