If, like me, you have a web server that you leave running in the corner of the room and don't touch for weeks at a time, and you discover to your horror one day that you can't log in to it, the chances are that all the user accounts have expired.
The thing to do is reboot into single user mode (with Lilo, press escape and type "linux single"), and use the chage command to set the password expiration dates far into the future.
chage <user> runs interactively, prompting for field values.
Many commands sport a -r or -R switch to recurse into subdirectories. I have found that with some of these, notably rm and grep, only subdirectories that match the wildcard specified in the file argument are descended into. So,
rm -rf *
will behave as expected, but
rm -rf *.html
will only delete files and (entire!) directories that end in .html. The solution is to use the output of find as the file argument instead (paying careful attention to the kinds of quotes used):
rm -rf `find . -name '*.html'`
I'm always piping the output of commands through grep to find specific words, but it can also be used to find files that contain a text string:
grep -lir "some text" *
The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.
To convert from DOS/Windows files that have carriage return/linefeed pairs, to normal files with just carriage returns, use the recode command:
recode ibmpc..lat1 < file.dos > file.unix
To convert back:
recode lat1..ibmpc < file.unix > file.dos
The fuser command is useful to find out which processes have a particular file open. For example, if you find you can't open the serial port, it is probably because some other program is using it.
fuser /dev/ttyS0
will do the trick. In addition, the -k switch will send the SIGKILL signal to all processes with the specified file open.