Skip to Content

stopsoftwarepatents.eu petition banner

Linux

sudo !!

Posted in

A time-saver for those that forget to sudo, bash substitutes !! for the last command entered, for example

charles@lucifer$ make sandwich

Permission Denied!

charles@lucifer$ sudo !!

sudo make sandwich

echo "You seriously think I would write a sandwich recipe just to demonstrate bash shortcut?"

You seriously think I would write a sandwich recipe just to demonstrate a bash shortcut?

Walking a directory tree with bash

Posted in

I'm doing the hard-drive shuffle thing. I have a lot of data and I'm paranoid about losing it. I've been let down once or twice by bad copies so I thought I should take checksums before copying. I had a lot of fun arguing with wildcards and string escaping so I thought I'd share my adventure, as I've already worked out how to do this and forgotten at least once.

My first attempt. It dies when fed directories.

md5sum * | md5sums.txt

I try again, and it occours to me to use tee in append mode so I get output to the screen as well

for foo in `ls -R` do
md5sum $foo | tee -a md5sums.txt
done

This doesn't work, md5sum complains. I have a look at  ls -R

Quote:
some.file
another.file

Directory1/
Directory2/

Directory1:
inDirectory1.file
inDirectory1again.file

Directory2:
inDirectory2.file
inDirectory2again.file

I RTFM and can't find an option to list full paths. I consider using find.

for foo in `find -type f` do
md5sum $foo | tee -a md5sums.txt
done

This fails when anything has a space in the filename. I RTFM on find. find -ls does the escaping i need but has all the useful info that ls -l spits out. Not too handy and I don't feel like resorting to sed, or awk. Further through the fine manual I find

man find wrote:
-exec command ;
Execute command; true if 0 status is returned. All following arguments to find are taken to be
arguments to the command until an argument consisting of ‘;’ is encountered. The string ‘{}’ is
replaced by the current file name being processed everywhere it occurs in the arguments to the
command

To cut a long story short that's not quite the whole truth, as the shell works its magic on {} and ; so we need to add quotes and a slash.

find -type f -exec md5sum '{}' \; | tee md5sums.txt  

Of course as I watch the damn thing run I start wondering about how to perform the md5sums in parallel to get it done faster. I start the same command on the copy of the files and notice that find lists the files in a different order, so I'm going to need to apply sort and whilst I'm at it I should probably use the list to strip out any of the inevitable duplicate files I have kicking around.

Or I could have just installed md5deep.

renameutils: preserving my sanity

Ever been faced with a collection of files that need renaming and nearly gone mad from trying to do it manually? Lots of typing mv, or lots of right click -> rename. Enter qmv, part of renameutils. Suppose we have a bunch of mp3s that require renaming:

$ ls
track10.mp3  track12.mp3  track2.mp3  track4.mp3  track6.mp3  track8.mp3
track11.mp3  track1.mp3   track3.mp3  track5.mp3  track7.mp3  track9.mp3

qmv allows us to edit the names in a text editor, defaulting to your $EDITOR, but you can specify a different editor if you prefer.

Idiotproofing

Ever shutdown/rebooted the wrong machine through ssh+carelessness? molly-guard comes to the rescue, asking you to type the hostname of the machine you intend to shut down if it detects you are connected by ssh. It's packaged for and available in the main repositories Debian and Ubuntu, I don't know about any other distros.

An example:

[sudo] password for charles:
W: molly-guard: SSH session detected!
Please type in hostname of the machine to reboot: lucifer

Broadcast message from charles@lucifer
(/dev/pts/0) at 17:44 ...

The system is going down for reboot NOW!

Adding Google software to linux

To cut a very long explanination short, google have some linux repositories for a number of the more packaging systems inclusing APT (debian, ubuntu etc), YUM, RPM, urpmi and YaST2.

http://www.google.com/linuxrepositories/index.html

Currently only contains google-desktop-linux and picasa

Death to the Muckrakers

Posted in

Forget 'holy war' articles. Linux.com found the big red button.The article entitled Ten sticking points for new Ubuntu usersis a shortsighted attempt at fueling the kind of flame war that drives users away from linux.

Tux

Posted in

The world as we know it is ending. Reading Linux Format in bed is now met with requests for a cuddly Tux.

Tudrunktu

Charles:

This is the acid test: can I install *buntu when I'm this fsckd

Dave:

Tudrunktu: Ubuntu with WINE pre-configured for alcholic windows users....



/me just aquired laptop as it's owner jsut got a new one. *We do the more tech dance*

 

 

Tesco now selling PCs running Ubuntu

Posted in

Ever fond of the bargain basement, Tesco are selling bottom end PCs running Ubuntu. They cost less than a retail copy of MS Office 2007

http://direct.tesco.com/q/R.200-3224/btnResultSort.x=509/btnResultSort.y...

http://direct.tesco.com/q/R.200-6129/btnResultSort.x=509/btnResultSort.y...

Smiles all round? I want to get my hands on one of thses just to see if they're any good.

BBC acknowledges some of us don't use windows

Posted in

The BBC quietly let slip that they do intend (eventually) for mac and linux users to be able to use its TV-catch up service.

Of course some of us have MythTV and never miss a program to beging with, unless the beeb can't keep to schedule.

Syndicate content