October 2008

The Archives

  • 10.31.08
    Adding line numbers to a file cmd | rafacas | (0)
    $ cat -b /etc/inittab 1 root:x:0:root 2 bin:x:1:root,bin,daemon 3 daemon:x:2:root,bin,daemon 4 sys:x:3:root,bin,adm 5 adm:x:4:root,adm,daemon 6 tty:x:5: 7 disk:x:6:root 8 lp:x:7:daemon,lp 9 mem:x:8: 10 kmem:x:9: 11 wheel:x:10:root 12 mail:x:12:mail 13 news:x:13:news 14 uucp:x:14:uucp ...
  • 10.29.08
    Opening a file with vi at specified position cmd | rafacas | (0)
    $ vi +10 /home/rafacas/test.txt Opens the file test.txt with the vi editor and positions the cursor on line 10.
  • 10.27.08
    Encryption the old-fashioned way: ccrypt security | pfortuny | (0)
    For 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.25.08
    Recursive grep in Solaris cmd | rafacas | (1)
    $ find . | xargs grep PATTERN In Solaris, the grep command does not have the -R (-r, --recursive) option which reads all files under each directory, recursively. The above command can be used to do the same in Solaris.
  • 10.23.08
    Nix all output cmd | pfortuny | (1)
    $ 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.21.08
    Hierarchic list of processes shell | rafacas | (0)
    You probably use the ps command a lot, but sometimes there is too much info, and somewhat disordered. It can be easily ordered with the forest option, as the following example shows: $ ps -e -o pid,args --forest PID COMMAND 2 [kthreadd] 3 \_ [migration/0] 4 \_ [ksoftirqd/0] 5 \_ [watchdog/0] [...] 1 /sbin/init 2742 /sbin/udevd --daemon [...] 6307 /usr/sbin/gdm 6310 \_ /usr/sbin/gdm 6313 \_ /usr/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7 6514 ...
  • 10.19.08
    Your Mac terminal can sing fun | rafacas | (0)
    Typing say something into your Mac's terminal will literally make your Mac say something. The UsingMac blog posts a quick tip with this Mac built-in voice, so you can make your Mac sing. Copy and paste the following to the command line to check out your terminal "singing" ability. say -v Good oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Get more terminal songs at Terminal sings songs (UsingMac) I know, this is not very useful, but it is fun :)
  • 10.17.08
    DHCP, inverted commas and ssh with RSA automated, security | pfortuny | (1)
    There 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 ...
  • 10.15.08
    Safe remove cmd | rafacas | (0)
    rm -P file.txt Overwrite regular files before deleting them. Files are overwritten three times, first with byte pattern 0xff, then 0x00, and last with 0xff, before they are deleted.
  • 10.11.08
    screen… ttys as window managers (1) shell | pfortuny | (2)
    You either know it (in which case you probably will not bother to read on) or you must know it (and here I come to the rescue). Open your terminal of choice (in my OS X interface I press Command-0, which invokes quicksilver and then 'it <ret>', with which I get an iTerm instance). Then type $ screen and a help text appears, showing the usual GNU license text; press Return to continue. The screen blanks out as if you had just started your session. You are in, this is the red pill. You will never want out. Screen is a fully-featured 'terminal' window ...