23 minutes ago · Tech · hide · 0 comments

After entering a username and password, the NetBSD default login generates multiple lines of output, some of it more useful (Last login) than others (copyright dates). To quiet this output, I create an empty hushlogin file in HOME: touch ~/.hushlogin However, this removes the Last login output, which I do want to display. I re-create the information using last(1) in a custom script. Create the bin directory in HOME: mkdir ~/bin Create mylastlogin: vi ~/bin/mylastlogin …with: #!/bin/sh # # Show last login information if available if command -v last >/dev/null 2>&1; then last | grep $USER > /tmp/logins sed -i.bak '/boot/d;/shutdown/d;/reboot/d;/tmux/d' /tmp/logins head -2 /tmp/logins | tail -1 | tr -s ' ' > /tmp/last logdate="$( cat /tmp/last | cut -d ' ' -f 3- )" logtty="$( cat /tmp/last | cut -d ' ' -f 2 )" echo "Last login: $logdate on $logtty" fi Save changes and exit. Make the script executable: chmod 700 ~/bin/mylastlogin Modify .profile: vi ~/.profile Add: # Show last login…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.