Block comments in Bash

#!/bin/bash echo before comment : <<‘END’ bla bla blurfl END echo after comment From http://stackoverflow.com/questions/947897/block-comments-in-a-shell-script


Create VirtualEnv and install Pyramid!

On ubuntu 13.10: (you should have python3.3 installed already, it comes default) wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python3.3 2. easy_install-3.3 virtualenv 3. virtualenv –no-setuptools –always-copy virtrepo/ 4. wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | virtrepo/bin/python3.3 5. cd virtrepo/ 6. ./easy-install pip 7. ./pip install Pyramid==1.5a4 8. virtualenv-3.3 –relocatable ../ Breakdown: We get the latest easy-setup, install it, install the virtualenv package, create our virtualenv in a directory “virtrepo”, grab easy-setup for this new env, install pip in it, and use pip to install pyramid.

Continue reading ↦

Mount disk in two locations, one being read only.

So most people know that to mount a disk to two different locations, they can do a simple mount –bind like: mount –bind /origlocation /newlocation However, what if you want that second location to be a read-only location to the filesystem? Try this: mount –bind /origlocation /newlocation mount -o remount,ro /newlocation ^that should properly work! More reasoning for this here.


Create iso and burn dvd via the cli

Assuming you have your VIDEO_TS folder in /mnt/data/dvd Create iso image: genisoimage -o /mnt/data/dvd.iso /mnt/data/dvd/ Burn iso image: growisofs -dvd-compat -Z /dev/sr0=/mnt/data/dvd.iso Note you may need to apt-get install these utils…I did.


sudo wont honor my aliases

To counteract this behavior, run it with a space after it. For instance, I have an alias like this: <br></br> alias sudo='sudo '<br></br> That way, whenever you type sudo, you are actually adding that extra space which enables aliases to be expanded in your current env!!!! More here!


lftp is great, except you can't mirror individual files

That’s why you have to use mget in place of mirror! Kinda annoying but it must be done….ohhh and the other downside is you lose any segmented downloading with mget as only mirror can do that. I posted a little snipped on this answering a question on stackoverflow.


A note on smartctl and how to interpret smart results

apt-get install smartmontools smartctl –all /dev/sdk RAW_VALUE: this is the only thing with real or physical meaning, generally these are the counts or the measurements VALUE, WORST and THRESH are all reported in the same arbitrary units, which normalize the raw value to 0-255, where bigger is better. VALUE is the current value, WORST is the worst that has been recorded while the disk is functioning, and THRESH is the floor that you want to stay above.

Continue reading ↦

Quickly create hard links for directories!

So that title isn’t exact…as most of you should know, you cant create hard links for directories…you also can’t create hard links across filesystems….there are pretty obvious and more technical reasons for that. So the alternative is to create the dirs and hard link the files in the dirs…which if done manually using ln continuously, would be painful. However, the cp command can do it for you in one fell swoop!

Continue reading ↦

Make alphabetical directories based on the files/folders in them

for i in $(ls | cut -c 1 | grep -v ‘[0-9]’ | uniq); do mkdir “$i”; done EDIT: So that ^ was my first thing. Then I decided to take this further…one line to rule them all and both create the single letter directory and then continue to move every other folder into the single letter directory: for i in $(ls | cut -c 1 | grep -v ‘[0-9]’ | uniq); do mkdir “$i” && for j in $(ls | grep ‘^’$i’.

Continue reading ↦

The story of defaulting to /dev/md127

So even after configuring my /etc/mdadm/mdadm.conf (im using ubuntu, its /etc/mdadm.conf if on deb), for some reason, at system boot, I was still getting a device name of /dev/md127. As per the ubuntu forums, this is a common problem with a change made in newer kernels. Here is my mdadm.conf: # mdadm.conf # # Please refer to mdadm.conf(5) for information about this file. # # by default (built-in), scan all partitions (/proc/partitions) and all # containers for MD superblocks.

Continue reading ↦