Shells for a particular purpose

Last edit

Removed: 11d10

< # Show the last hundred lines of the web server log


When you're developing, it's sometimes really useful to peek into the logs on a (*nix) server. However, the administrator of that machine has a policy of not handing out shell accounts. You might want to ask him for an extremely limited account; namely, one that peeks into the logs...

To configure this, the administrator should take the following steps:
First, a user should be created (let's say 'dev'):

  # useradd dev
  # passwd dev
  Enter new UNIX password:
  Retype new UNIX password:
  passwd: password updated successfully

Then, a little shell script (say, 'show_appserver_log.sh') should be created in that users' directory which shows the log file that the developers are interested in. An example of the contents:

  #!/bin/sh
  tail -100 -f /path/to/application_server.log

The script should be set as a valid shell; add the full filename plus path to the file /etc/shells. The user its shell must then be set to the script:

  # usermod -s /home/devshow_appserver_log.sh dev

Now when the user logs into the machine, the script is run and the user is immediately logged out when they press CTRL-C.