The Archives
-
10.27.08Encryption the old-fashioned way: ccryptFor encrypting small text files, I use ccrypt, a nifty utility which uses Rijndael-256 (aka AES-256) and just does it work as it is supposed to do. $ ccrypt -e my_file Asks you for a password twice, encrypts my_file (naming the new encrypted file my_file.cpt) and overwrites the old my_file (however, notice that journaling filesystems like ext3 or non-block filesystems might keep some or all the data elsewhere). $ ccrypt -d my_file.cpt Asks for the password and, if correct, decrypts my_file.cpt as my_file (and deletes my_file.cpt). A more useful option for small text files is: $ ccrypt -c my_file.cpt which, after asking for the password, sends the ...
-
10.23.08Nix all output$ cat /var/mail/* >/dev/null 2>&1 The first redirect sends stdout to /dev/null, the second one sends stderr to stdout, thus making all the output disappear. Useful in cron jobs if you want no mail sent.
-
10.17.08DHCP, inverted commas and ssh with RSAThere is a server I manage (called alex) which has not a fixed IP. As you know, I have a shell at the best Unix server out there (by the way, it is almost free. The problem is to keep an up-to-date record of the first server's IP address. I do it as follows (and yes, I know timtowtdi). What I did was: Create an RSA public/private key pair at alex: alex $ ssh-keygen -N'' -f 'id_alex' -t rsa which creates the files id_alex and id_alex.pub. Create a cron job for my account at alex which looks like 5,10,15,20,25,30,35,40,45,50,55,0 * * * * /usr/bin/ssh -i ...
-
09.17.08Time$ time for i in `ls` ; do cat $i ; done Shows the 'real', 'user' and 'sys' time invested in the task.
-
08.15.08Looking at the EndFrom time to time we want to see only a few lines near the end of a file. We often use cat or more, but this can be tedious when the file is big (like a very long log file). You can use these commands to read from the end of the file: tac. It works exactly as cat but reading from the end of the file tail. It reads from the end of the file. It has more features than tac. The one I found to be more interesting is the -f flag. It makes tail to continue reading from the ...
-
06.17.08comm, common lines in two filesGiven two ordered files, like $ cat foo abbreviation carnivore meal topology and $ cat bar aristide meal nap scout topology zero comm prints, in succession and in a three-column format, the lines corresponding exclusively to the first file (first column), exclusively to the second file (second column) and to both of them (third column). Thus, $ comm foo bar abbreviation aristide carnivore meal nap scout ...