Posts tagged linux
OpenDNS updater for linux/ubuntu
Nov 15th
The OpenDNS service is great — it provides anti-phishing and the ability to filter out some of the less desirable detritus from the internets.
OpenDNS needs to be periodically notified about what your IP address is, and I don’t have a windows or macintosh box that’s always on. I do have an ubuntu box, though, but there weren’t any instructions on OpenDNS’ site to do this properly.
Verifying file integrity with debsums
Apr 21st
After upgrading my Ubuntu server, some security applications grumped about changed contents of some common binaries.
Just to be safe, I wanted to verify them explicitly with debsums, but debsums looks for package names, not paths to binaries. Here’s a script that validates chattr, find, perl, and lsattr–the “-s” option to debsums is “silent”, so no news is good news:
for i in /usr/bin/chattr /usr/bin/find /usr/bin/perl /usr/bin/lsattr ; do echo $i debsums -as $(dpkg -S $i | cut -d':' -f1 | sort -u) done
Running a command for all files whose name matches…
Apr 20th
I found a stray image named “img_1234.jpg” on a laptop and wanted to see if I already had it on my server.
On my Mac I could use spotlight’s nifty “kind:image” filter along with quicklook. Macworld has a great article about advanced spotlight usage.
On Ubuntu, it’s almost as easy:
locate -i img_1234.jpg | xargs -d'\n' feh -F -d
- The
locate -isays “find img_1234.jpg without case sensitivity. Locate likes to separate filenames (that might have spaces) with a newline. - The
xargs -d'\n'says “expect filenames that are are separated by newline - The
feh -F -dtells feh, a great little image viewer, to reduce the image to fit to the screen and draw the filename.
DegradedArray event on /dev/md0:gronk
Apr 3rd
Due to an unscheduled powercycle on my linux server, I got a very troubling page from mdadm, the multi-disk administrator, saying it had marked one of the disks as failed.
This, presumably, was due to a flaky SATA controller that didn’t make /dev/sda available by the time the kernel was mounting /dev/md0, so software raid turned it off.
It was easy enough to get the drive back into play:
sudo mdadm /dev/md0 --add /dev/sda1
And easy enough to monitor progress:
mrm@gronk:~$ cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sda1[3] dm-2[1] dm-1[0] 580074880 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_] [====>................] recovery = 22.0% (63875072/290037440) finish=178.1min speed=21154K/sec
Recursive sort-by-modification-time
Oct 4th
This certainly isn’t rocket science, but it also is certainly not something you want to type more than once.
find . -type f -printf '%T@\t%p\n' | sort -n | cut -f2
And an application using feh:
find . -type f -printf '%T@\t%p\n' | sort -n | cut -f2 | xargs feh -F
And if you want the newest-written-to .log files, searching from the current working directory:
find . -name \*.log -type f -printf '%T@\t%p\n' | sort -rn | cut -f2 | head -30 | xargs -n 1 ls -lh