The Archives

  • 21.Jul.11
    Printing sequential numbers in BSD shell | rafacas | (0)
    In Linux, the seq command is pretty useful in some scripts, because it prints a sequence of numbers: $ seq 1 5 1 2 3 4 5 It is usually used in for loops: for i in `seq 1 5`; do ... done But this command is not included in BSD-like OSes. It is contained in the sh-utils, so one option is downloading and compiling it. But I prefer using the commands that come by default with the OS, for portability. In the BSD case, I found the jot command that prints sequential or random data. The following example shows the seq behaviour with jot. $ jot 5 1 2 3 4 5 Other example ...
  • 06.Sep.09
    How to verify MD5 or SHA-1 digests security | rafacas | (2)
    MD5 and SHA-1 are cryptographic hash functions. They are deterministic procedures that take an arbitrary block of data as input and return a fixed-size bit string, the hash value (called message digest or fingerprint as well). Verifying MD5 or SHA-1 digest is highly recommended when you download new software for your system. In most of Linux distros the md5sum and sha1sum commands are available: $ md5sum ubuntu-9.04-desktop-i386.iso 66fa77789c7b8ff63130e5d5a272d67b ubuntu-9.04-desktop-i386.iso $ sha1sum ubuntu-9.04-desktop-i386.iso 19aabf327fdbde9e66db54dc04e3a83b92f70280 ubuntu-9.04-desktop-i386.iso Solaris (even version 10) doesn’t ship either with md5sum or sha1sum installed. However you can use digest: % /usr/bin/digest -a md5 GNUgcc.3.4.4.SPARC.64bit.Solaris.10.pkg.tgz 498c344fe2839631bb7cf4b869b7b830 % /usr/bin/digest -a sha1 GNUgcc.3.4.4.SPARC.64bit.Solaris.10.pkg.tgz a8da8247900dd06a7000fd0e6d41f834d6ab3e40 And in Mac OS X, ...
  • 22.Jun.09
    Cleaning port’s garbage shell | fernape | (0)
    portsclean cleans garbage from the directory tree of the ports collection. It is a utility of the base system that should be run from time to time to keep one's ports infrastructure as sane as possible. portsclean wipes old package files, unneeded libraries and such. There are several interesting option flags described in the man page. This is how I run portsclean from time to time: % portsclean -DD The command above cleans all the distfiles that are not referenced by any installed package in the system. I usually run this after rebuilding the complete userland from a new ports fetch. Enjoy!
  • 16.May.09
    Systat shell | fernape | (0)
    systat is a base system utility that displays system statistics. Information is updated automatically and shown in a pseudo-graphical way (based on ncurses). $ systat /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 Load Average || ...
  • 24.Apr.09
    Retrieving files from a URL (the BSD way) shell | fernape | (3)
    $fetch URL This ancient command (it appeared first in FreeBSD 2.1.5) retrieves files from URLs. It is simple and efficient. All its features are encapsulated in the libfetch library which can be accesed from a C program using a predefined API (man 3 fetch). Example: $fetch
  • 19.Apr.09
    iostat (BSD) shell | fernape | (0)
    iostat shows I/O statistics. The example below shows statistics of the copying process from an USB music player to my laptop's hard drive. It shows KB per transfer, transfers per second and MB per second, for each device specified in the first row in the statistics report). The last three columns show CPU statistics. You can avoid them with the -d flag. iostat -w 1 tty ad0 da0 ...
  • 26.Dec.08
    Updating freebsd shell | fernape | (1)
    freebsd-update is one of the ways available to update your FreeBSD system. In the simplest form, you can use it this way: % freebsd-update fetch % freebsd-update install These two commands above, fetch and install updates for your release. freebsd-update can also perform a rollback, be scheduled to fetch updates automatically and used to fetch new packages from a different release. freebsd-update's behaviour is ruled by the /etc/freebsd-update.conf. You can specify which components you want to be monitored by freebsd-update (base system, kernel, sources...) Though BSDs systems can be tough, this is an example of how easy things can turn out from time to time :)
  • 18.Nov.08
    iftop cmd, network, shell | fernape | (0)
    $ iftop On BSD systems, displays NIC statistics. Install from /usr/ports/net-mgmt/iftop
  • 15.Oct.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.
  • 05.Jul.08
    Summary of network traffic per interface cmd | pfortuny | (0)
    $ netstat -I en1 -w 1 input (en1) output packets errs bytes packets errs bytes colls 2 0 54 2 ...