Customize the Login on NetBSD

Last edited on 2026-11-02 • Tagged under  #netbsd   #bsd 

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 script. I also add uptime(1) output for good measure.

Create the bin directory in HOME:

mkdir ~/bin

Create mylastlogin:

vi ~/bin/mylastlogin

…with:

#!/bin/sh
#
if command -v last >/dev/null 2>&1; then
    lg=$(last -2 -T "$USER" | tail -n 1 | tr -s ' ')
    lgdate=$(echo "$lg" | cut -d ' ' -f3-7)
    lgtty=$(echo "$lg" | cut -d ' ' -f2)
    now=$(date +%T)
    up=$(uptime | tr -s ' ' | cut -d ' ' -f 3-)
    echo "Last login: $lgdate on $lgtty"
    echo "System: $now $up"
fi

Save changes and exit.

Make the script executable:

chmod 700 ~/bin/mylastlogin

Modify .profile:

vi ~/.profile

Add:

# Show last login information if available
command -v mylastlogin >/dev/null 2>&1 && mylastlogin

Save changes and exit.

You can like, share, or comment on this post on the Fediverse 💬

Thanks for reading! Read other posts?

» Next: Upgrading NetBSD from 11.0 to 11.1

« Previous: Syncthing on NetBSD