Some random interactive shell hacks

| No Comments

None of these are really very clever, but they’re slightly creative abuses of the standard tools, and maybe someone will find them useful.

  1. Browsing lots of small files. Suppose you’re looking at something like a Qmail configuration directory or settings in /proc or /sys. where there are lots of one- or two-line files. You could try to get a handle on them by using cat(1) but I find that the right answer is

    grep ^ files

    For trees of stuff, like in /proc/sys/net/*/conf, say, GNU grep’s -r flag is useful.

  2. Clobbering files as root. I try to run as a non-root user most of the time, and elevate to root as needed, using sudo(8). (The vulnerability history of sudo makes for exciting reading, but I like that it maintains a log. I’m much less impressed with the security theatre of typing passwords, and its tendency to send loud SECURITY mail is very annoying.)

    So, there’s a file you want to hack: it’s owned by root, and the easiest way to hack it is with a shell rune. But if you redirect something’s stdout to the file, that’ll be done in your shell, with your privileges, so it won’t work. I use tee(1) here.

    | sudo tee output >/dev/null

    (This at least leaves a log that I hacked the file, and even if it doesn’t say exactly how, it’s no less informative than sudoedit.)

I’m sure there were going to be more of these. Maybe some of them will come to me later.

Leave a comment

About this Entry

This page contains a single entry by Mark Wooding published on March 14, 2012 12:33 PM.

Inter-view updates and notifies in BIND9 was the previous entry in this blog.

OCSP stapling, and other stupid ideas is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.2.13