Live data from Hacker News

Top Unix Command Line Utilities

blog.coldflake.com

1–10 of 65 posts

Re: Top Unix Command Line Utilities

#3
These obviously aren't related to 2012 at all.

Some issues:

- don't forget that /dev/random blocks

- It's easier to use dd_rescue to track progress than to signal dd

- Using dd to zero out a hard drive repeatedly doesn't increase security[1]. Using ATA secure erase does[2]

- an alternative for summing file sizes is

    du -ch **/*.png
[1] http://en.wikipedia.org/wiki/Data_erasure#Number_of_overwrit...

[2] https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase

Re: Top Unix Command Line Utilities

#4
post #2

Got a feeling they ran out of utilities to mention by the end. Even very new users of *nix will likely have heard of and used `find` and `zip`.

Probably dd and df too. But, he's just listing what commands he found the most useful, not just the esoteric ones.

Re: Top Unix Command Line Utilities

#6
My 2012 top, in order of usage:

joe, ls, cd, time, cdbdump, tail, more, cat, rm, grep, wc, apachectl restart, find, curl, chmod, history, mv, locate, cpan, apt-get, pwd

But the most useful one is a command line Perl utility I called "flt" that executes a block of perl code for each in the stdin.

cat file.txt | flt ' $line=~ s|\s+| |gsi; print $line."\n"; '

That would compact free spaces

find . | flt ' if (-f $line) { print (-s $line)."\n"; } '

This would print the size of all files in the current folder and subfolders.

So it works like awk, but with full Perl, no need to learn awk syntax. You can do conditionals, loops and whatnot. I write 30% of my one time throw away scripts directly in the command line.

Re: Top Unix Command Line Utilities

#8
post #6

My 2012 top, in order of usage: joe, ls, cd, time, cdbdump, tail, more, cat, rm, grep, wc, apachectl restart, find, curl, chmod, history, mv, locate, cpan, apt-get, pwd But the most useful one is a command line Perl utility I called "flt" that executes a block of perl code for each in the stdin. cat file.txt | flt ' $line=~ s|\s+| |gsi; print $line."\n"; ' That would compact free spaces find . | flt ' if (-f $line) {…

Are you familiar with perl's -n and -p switches?

http://perldoc.perl.org/perlrun.html#*-n*

Those "flt" lines could be written

  perl -lpe 's|\s+| |gsi' file.txt
  find . | perl -ne 'if (-f) { print -s }'
(-l chomps the incoming newlines, and puts them back on the output)

Of course, "perl -ne" is longer than "flt", and I appreciate all this implicit use of $_ is not to everyone's tastes.

Re: Top Unix Command Line Utilities

#9
post #3

These obviously aren't related to 2012 at all. Some issues: - don't forget that /dev/random blocks - It's easier to use dd_rescue to track progress than to signal dd - Using dd to zero out a hard drive repeatedly doesn't increase security[1]. Using ATA secure erase does[2] - an alternative for summing file sizes is du -ch **/*.png [1] http://en.wikipedia.org/wiki/Data_erasure#Number_of_overwrit... [2] https://ata.wik…

I think the only "secure" way to erase the contents of a hard drive is to repeatedly overwrite the disk surface with a mix of random/patterened data (like Darik's Boot & Nuke does).

Also, for those wondering about the blocking of /dev/random, it will restrict the number of bits you can copy using dd, but this won't be apparent unless you attempt to copy more bits from the entropy pools than there are available for random number generation. For more information, see this question on Super User: http://superuser.com/questions/520601/why-does-dd-only-copy-...

Post reply on HN