Howto: Create TTY User to view logs via TTY in Ubuntu Linux

We all have various log files on our Ubuntu system, and sometimes it is nice to be able to easily view a log file within a tty. Here is a simple howto, to create a tty user that's only purpose is to watch a log file
First lets create the logging script after sudo -s:
cat >>/usr/bin/logwatch
Paste this, then control-c when its pasted in the terminal, alternatively you can use a text editor..
#! /bin/bash
watch tail -n 80 /var/log/messages

Note: You can replace /var/log/messages with any log you choose, like a firewall log for instance.
Make /var/log/messages Readable and our script executable, for this I'll use chmod:
chmod 644 /var/log/messages
chmod +x /usr/bin/logwatch

Now append /usr/bin/logwatch to /etc/shells then save/exit
gedit /etc/shells

Now lets create the user that we can login via the TTY
adduser logwatch --shell /usr/bin/logwatch
Set a password, like "logwatch"

Now lets try this out, all you need to do now is simply press ALT-CTRL-F1 or any other TTY from F1-F6 then login as "logwatch" with password "logwatch", what will happen is the user will be logged into our /usr/bin/logwatch script and only be able to watch the log, so we can cycle between tty's and X

Clicky Web Analytics