Remove a Range of Unwanted ZFS Snapshots from the Command Line
Remove a range of unwanted snapshots, from the command line, if necessary.
In the following example, all automatic snapshots in the bash shell are removed.
One could add a secondary pipe and grep statement to filter on individual file systems.
Create a pidof command to find PID numbers easily
Most UNIX environments include the pidof command which is put to use whenever one needs to quickly determine, by name, the pid of a running program. Apple's Mac OS X lacks the pidof command, however, one may approximate its function with the following shell script:
ps axc|awk "{if (\$5==\"$1\") print \$1}";
Save the script as /bin/pidof and be sure to set its executable bit:
Strip empty (null) lines from a file
sed meets the need; the recipe follows:
Disable Spotlight in Mac OS X 10.6 Snow Leopard
On occasion I need to process large volumes of text locally. Spotlight dutifully attempts to index this data, bringing my system to a crawl.
Proactively disabling Spotlight is a sure way to avoid such issues and here is how to do it:
Disabling Spotlight in Snow Leopard is pretty easy, launch the Terminal and type the following command:
This tells the Spotlight manager to disable all indexing on all volumes, the command will require your administrative password to execute.
Re-enabling Spotlight in Mac OS X 10.6 Snow Leopard is just as easy, just reverse the command to:
Now Spotlight indexing will be back on and work as usual.
NOTE: mds and mdsworker will persist in the process table; this is normal.
Device Manager does not display devices that are not connected to the Windows XP-based computer
Issue:
Device Manager displays only non-Plug and Play devices, drivers, and printers when you click Show hidden devices on the View menu. Devices that you install that are not connected to the computer (such as a Universal Serial Bus [USB] device or "ghosted" devices) are not displayed in Device Manager, even when you click Show hidden devices.
Workaround:
- Click Start, point to Run, and type cmd.
- Click Ok
- At the command prompt, type the following command and then press ENTER:
set devmgr_show_nonpresent_devices=1
- Type the following command at the command prompt and then press ENTER:
start devmgmt.msc
- Troubleshoot the devices and drivers in Device Manager. NOTE: Click Show hidden devices on the View menu in Device Managers before you can see devices that are not connected to the computer.
Note that when you close the command prompt window, Window clears the devmgr_show_nonpresent_devices=1 variable that you set in step 2 and prevents ghosted devices from being displayed when you click Show hidden devices.
If you are a developer or power user and you want to be able to view devices that are not connected to your computer, set this environment variable globally:
- Right-click My Computer.
- Click Properties.
- Click the Advanced tab.
- Click on the Environment Variables tab.
- Set the variables in the System Variables box.
NOTE: Use this method only for troubleshooting or development purposes, or to prevent users from accidentally uninstalling a required device that is not connected to the computer (such as a USB device or docking station that is not connected to a laptop computer).
Reference: http://support.microsoft.com/kb/315539
Clear Spotlight Index
From a terminal window:
That is, sudo (because you have to have admin rights to run this), mdutil (the program that does the work for you) -a for “work on all volumes”, -v for “be verbose in telling me what you’re doing”, and -E for “erase the data store and rebuild it”.
Disable disk checking during boot on Linux systems
Issue:
Linux (appropriately) checks filesystems after a number of boot cycles.
Cause:
This is by design. By default, ext[2,3,4] filesystems are automatically checked every 34 mounts or 180 days (whichever comes first).
Resolution:
In some cases (ephemeral machine instances in a cloud) this behavior is undesirable. It may be tuned with the following:
To disable it use the following at the terminal:
Set it to check after 30 system boots
Also ensure that your /etc/fstab file reflects a similar setting. The sixth column should contain a 0 (never check) rather than a 1 (check at boot).
Convert a .dmg to a .iso
Issue:
Mac formatted disk image (.dmg) cannot be directly burned on Windows or Linux systems.
Resolution:
One can convert a .dmg to a CD master via the Disk Utility application embedded in OS X, or by opening a terminal window and issuing the following command:
The output file will be named savefile.iso.cdr -- you may strip the .cdr and burn the .iso with any standard utility for doing so.
Mirror a Directory Structure Using the Command Line
Issue:
You need to mirror the directory structure (but not contents) for a tree.
Resolution:
Execute the following command from the root of your source directory. Adjust the destination variable to suit your tastes: %i will match the first token, %j the second, %k the third, and %l will match everything else.
Reference: http://www.dostips.com/DtTipsStringManipulation.php