Customize the Login on NetBSD
Tested on NetBSD 10.1
The default user login on NetBSD can be a wee bit busy. I like to customize it with a different "last login" notification and a "Daily Dose of Wisdom" delivered courtesy of fortune(6) and cowsay
.
To quiet the default output create the empty .hushlogin
file:
$ touch ~/.hushlogin
Last Login
View the list of all logins, reboots, and shutdowns with the last(1) command:
$ last
Display at login the who/when/duration of the last login by modifying .profile
:
$ vi ~/.profile
Add:
# Last user login.
last | head -10 > /tmp/recentlogins; \
sed -i '/shutdown/d;/reboot/d' /tmp/recentlogins; \
cat /tmp/recentlogins | head -2 | tail -1 | \
awk '{ ORS=""; print "Last login: " $1 " on " $2; $1=$2=""; print $0 }'; echo ""
Save changes and exit.
Fortune
Install:
# pkgin install fortune cowsay
Run:
$ fortune
I'll defend to the death your right to say that, but I never said I'd
listen to it!
-- Tom Galloway with apologies to Voltaire
List the fortune files installed:
$ fortune -f
100.00% /usr/pkg/share/games/fortune
...
Daily Dose of Wisdom
Now to make my own fortune(s)!
NOTE
Be careful not to duplicate a file name from the above list outputted by fortune -f
.
I create a file containing bits of wisdom I collect from all over:
$ vi dailyDoseOfWisdom
Add blocks of text separated by the %
percent sign. Sample:
Barn's burnt down / now I can see the moon.
-- Mizuta Masahide
%
To belittle, you have to be little.
-- Kahill Gibran, The Prophet
%
If you don’t get everything you want, think of the things you don’t get
that you don’t want.
-- Oscar Wilde
%
Save changes and exit.
Convert this file to a format that fortune
can use with the strfile(8) command, which generates the necessary *.dat
file type:
$ strfile -c % dailyDoseOfWisdom dailyDoseOfWisdom.dat
Copy both files to the fortune
data location:
# cp dailyDoseOfWisdom* /usr/pkg/share/games/fortune/
Verify its availability:
$ fortune -f
100.00% /usr/pkg/share/games/fortune
...
0.44% dailyDoseOfWisdom
Run:
$ fortune dailyDoseOfWisdom
Get your wisdom straight from the cow:
$ fortune dailyDoseOfWisdom | cowsay
_________________________________________
/ If you don’t get everything you want, \
| think of the things you don’t get |
| that you don’t want. |
| |
\ -- Oscar Wilde /
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Add to Login
Display at login my cow-ified fortunes by modifying .profile
:
$ vi ~/.profile
Add:
# Daily dose of wisdom
myfortune="/usr/pkg/share/games/fortune/dailyDoseOfWisdom"
if command -v fortune 2>&1 >/dev/null
then
if command -v cowsay 2>&1 >/dev/null && [ -f "$myfortune" ]
then
fortune $myfortune | cowsay
else
fortune
fi
fi
Save changes and exit.
My file: .profile
You can like, share, or comment on this post on the Fediverse 💬
» Next: Customize the Login and Logout on FreeBSD
« Previous: Manual NetBSD Installation with Disk Encryption