Linux

sudo !!

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

<br />
charles@lucifer$ make sandwich<br />
Permission Denied!<br />
charles@lucifer$ sudo !!<br />
sudo make sandwich<br />
echo "You seriously think I would write a sandwich recipe just to demonstrate bash shortcut?"<br />
You seriously think I would write a sandwich recipe just to demonstrate a bash shortcut?<br />

Subject: 

Walking a directory tree with bash

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.

[code lang=bash]md5sum * | md5sums.txt
[/code]

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

Subject: 

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<br />
track10.mp3  track12.mp3  track2.mp3  track4.mp3  track6.mp3  track8.mp3<br />
track11.mp3  track1.mp3   track3.mp3  track5.mp3  track7.mp3  track9.mp3

Subject: 

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

Subject: 

Pages

Subscribe to RSS - Linux

My Band

LinuxCounter.net

Creative Commons License
Except where otherwise noted, work is licensed under a Creative Commons Licence and is the work and opinion of the credited author(s).

Powered by Drupal

My Facebook


Charles Elwood's Facebook profile