None of these are really very clever, but they’re slightly creative abuses of the standard tools, and maybe someone will find them useful.
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.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