![mac os bash logged in user mac os bash logged in user](https://i.redd.it/099l91fmq7pz.jpg)
#Mac os bash logged in user how to
My computer has no /usr/local/bin, so I have no idea how to save the script, if I knew how to make one. BBEdit is the other major editor but it's expensive IMO.Ģ. In a plaintext editor like TextEdit, or my favourite TextMate. You can also completely disable the ability for guests to login via file sharing, as explained in this hint. You can also track who logs into your computer via file sharing over your network, as explained in this hint. To remove these changes, type the following commands in Terminal: The first time somebody logs in or out the log file will be created. When you want to view the log, just open the Console application, go to the /var/log section, and click on the usertracking.log file. That's it! Now you have a way to see everyone's login and logout times. Run the following two Terminal commands to create the login and logout hooks:.$ sudo chown a+x /usr/local/bin/logoutscript $ sudo chown a+x /usr/local/bin/loginscript Run the following Terminal commands to give the scripts execute permissions:.Save the scripts in /usr/local/bin as loginscript and logoutscript, respectively.Here's the login script:Įcho $username," "$timestamp," "$computer," login" > "$logfile"Įcho $username," "$timestamp," "$computer," logout" > "$logfile" Create the login and logout scripts as follows.If you keep your log file in the /var/log directory, then you can easily view the file using the Console application. With these scripts, any time anyone logs into or out of the computer, a log entry will be created. I was also curious about their usage habits, such as what time of day they login and how long they typically are on the computer, so I needed a way to track that data.Īfter reading about login hooks in OS X, and doing a little more research on the web, I came up with a few simple scripts that can be run at login and logout to solve my problem. This gives me a lot of control, but does not tell me everything I want to know. I've given each of them their own account and use parental controls to control what they can access.