Posts Tagged ‘HowTo’

Compile LaTeX to PDF

Tuesday, January 30th, 2007

A quick script to compile a LaTeX file to a PDF:

#!/bin/bash
FILE=$1
if [ -a $FILE.tex ]; then
        latex $FILE && dvipdf $FILE.dvi && rm -f $FILE.log $FILE.aux $FILE.dvi
else
        echo $FILE.tex does not exist!
        exit 1
fi

Halt-less Linux, How-To Prohibit a Linux Box from Halting

Friday, January 5th, 2007

There are some cases that you need a Linux box to never halt—never ever. Even if you specifically request it…

To protect yourself from yourself one could do the following:

cd /sbin/
mv halt halt.real
chmod 000 halt.real
ln -s reboot halt
mv poweroff poweroff.real
chmod 000 poweroff.real 
ln -s reboot poweroff

It would also be wise to modify /etc/init.d/halt. Find the following section:

# See how we were called.
case "$0" in
   *halt)
        message=$"Halting system..."
        command="/sbin/halt"
        ;;

and turn it into

# See how we were called.
case "$0" in
   *halt)
        echo $"$0: this system may not be halted!"
        exit 1
        message=$"Halting system..."
        command="/sbin/halt"
        ;;

.

Also, you may want to set up an exception in sudoers (always use visudo to edit it). Here’s a simple way of prohibiting users to “sudo shutdown -h now” or “sudo halt“:
Cmnd_Alias HALT = /sbin/shutdown, /sbin/halt
%wheel ALL=(ALL) ALL, !HALT

Should you need to reboot, sudo reboot should suffice.

Warning: If your box is connected directly to a UPS you might want to refrain from messing up with halt.


^