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?
MacOS – Simulate user login using command-line utilities
command lineloginmacosuiwindow-manager
Related Question
- MacOS – How to reload an OS X “bash” user-environment
- MacOS – Which is the correct way to obtain administrator access for the installation of Homebrew
- MacOS – Using Command Line how to make the user an Administrator
- MacOS – cannot create a user account on mac using command line
- User cannot login using AD credentials, others can
- MacBook – How to debug an extremely slow login
- MacOS – Login trouble after upgrading from Catalina to Big Sur
Best Answer
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.