- Published:
- May 15, 2011 – 8:16 am
- Author:
- By Dave
At home I have an (admittedly small) ZFS array set up to experiment with this neat newish raid technology. I think it has been around long enough that it can be used in production, but I’m still getting used to the little bugs/features, and here is one that I just found.
After figuring out that I had 2 out of 3 of my 1TB Seagate Barracuda hard drives fail, I had to give the array up for a loss and test out my backup strategy. Fortunately it worked and there was no data loss. After receiving the replacement drives in from RMA, I rebuilt the ZFS array (using raidz again) and went along my merry way. After 6 months or so, I started getting some funky results from my other drive. Thinking it might have some issue as with the others, I removed the drive and ran Seatools on it (by the way, Seatools doesn’t offer a 64-bit Windows version – what year is this?).
The drive didn’t show any signs of failure, so I decided to wipe it and add it back into the array to see what happens. That, of course, is easier said than done.
Categories: Linux,Shell,System Administration
Tagged: arrays, RAID, zfs
- Published:
- April 29, 2011 – 12:13 pm
- Author:
- By Dave
The hald – Hardware Access Layer Daemon – runs several processes in order to keep track of what hardware is installed on your system. This includes polling USB Drives and ‘hot-swap’ devices to check for changes along with a host of other tasks. You might see it running on your system as follows: 12342474 ? S 0:00 \_ hald-runner 2481 ? S 0:00 \_ hald-addon-acpi: listening on acpid socket /var/run/acpid.socket 2487 ? S 0:00 \_ hald-addon-keyboard: listening on /dev/input/event0 2495 ? S 41:47 \_ hald-addon-storage: polling /dev/hdc If your system is static and the devices do not change, you can actually disable this service using a policy entry. Create a file in your policy directory, for example /etc/hal/fdi/policy/99-custom.fdi. Add the text: 123456789<?xml version="1.0" encoding="UTF-8"?>….
Categories: Configurations,Linux,Shell,System Administration
Tagged: daemon, hald, hardware access layer
- Published:
- December 21, 2010 – 9:49 am
- Author:
- By Dave
According to “official” system administrator rules and guidelines you shouldn’t be adding so-called vain scripts to the login prompt – only utilities that will add something useful to the system (for example, current system load, memory and disk usage, etc). However I have some systems that I frequently connect to and thought it would be neat to add a random quote script to my bash login. That being said, this should only be done on ‘non-production’ systems and adds a security vector so please be careful where you use this. The goal of this is to add a little quote, at random, every time you log into your system. My thoughts were to do it not only as a little source of inspiration but also to add perspective to what I’m doing sitting in front of the computer all of the time. Originally I was going to try to write….
Categories: Code Samples,Linux,PHP,Shell
Tagged: bash, PHP, quotes
- Published:
- June 18, 2010 – 6:05 pm
- Author:
- By Dave
We received a tip from blog readers Christian and Michael for alternatives to the command to delete all directories older than a certain period of time. These both work in bash and can be used in scripts to clean up old backup directories or any situation where you need to delete old directories from the command line. From Christian: find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec rm -r {} \; From Michael: find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec echo “Removing Directory => {}” \; -exec rm -rf “{}” \; The first one works quietly, while the second one will display what is being deleted. These are probably faster than putting it into a for loop, so feel free to use whatever works best in your particular situation!
Categories: Linux,Shell,System Administration
Tagged: bash, oneliner, tips
- Published:
- February 23, 2010 – 5:41 pm
- Author:
- By Dave
My professor sent us this little one liner (ok, I had to format it to 2 lines to fit in this blog. You know what I mean) which prints out the current directory tree: ls -R | grep “:$” | sed -e ‘s/:$//’ -e ‘s/[^-][^\/]*\//–/g’ \ -e ‘s/^/ /’ -e ‘s/-/|/’ What’s going on here?
Categories: Code Samples,Shell
Tagged: bash, sed
- Published:
- February 13, 2010 – 1:12 pm
- Author:
- By Dave
The Bash command environment, which is the namesake of this blog, is very flexible in that it allows you to manipulate the filesystem in many ways. Awk and sed are very powerful tools that allow you to do this rename with a simple one line command. This post will walk you through doing this with a Comma Separated Value (CSV) file and also using a simple regular expression to rename many files.
Categories: Code Samples,Linux,Shell,System Administration
Tagged: awk, bash, csv
- Published:
- January 31, 2010 – 9:53 pm
- Author:
- By Dave
It is very easy to create a random file using the linux command line. Much like the command to fill a file with all zeros, for example a 1 Meg file: dd if=/dev/zero of=zero.filename bs=1024 count=1000 You do the same using /dev/urandom: dd if=/dev/urandom of=random.filename bs=1024 count=1000 Resulting in a 1MB file: 1000+0 records in 1000+0 records out 1024000 bytes (1.0 MB) copied, 0.0294247 s, 34.8 MB/s This is transferring random data from the virtual device urandom to the output file. We use /dev/urandom instead of /dev/random because the /dev/random source generates random data very slowly. urandom is much faster at this but remains very random, if not quite a random as /dev/random. This should work with any system with dd and /dev/urandom.
Categories: Code Samples,Linux,Security,Shell
Tagged: command line, Linux, tips