Another little sysadmin twitch or two

July 29, 2006

One of my little sysadmin twitches is that when I am using mv to move things into a different directory, I try to always write it as:

mv foo bar/

(Note the the trailing slash on the directory.)

This is a safety measure: if I typo the directory name, mv will error out with a no-such-directory error message instead of renaming the file to 'br' or the like. Speaking from personal experience, tracking down just what happened to your file when you make this mistake and don't notice right away is immensely frustratingly difficult.

(The difficulty is compounded by two of my habits: my shell history is per-shell, not global, and I discard shells/windows once I'm done with the particular thing I was using them for, which of course destroys that shell's history. Thus if I typo the mv and don't notice before I discard the shell, the history that would let me back up and see the typo vanishes.)

Of course I am also a strange mutant who likes having rm, mv, and cp aliased so that they have '-i' on. (My personal aliases for them turn off this behavior if I explicitly use '-f', so that things like 'rm -rf blah' are not annoying.)

(As an aside, the habit of advising new sysadmins that they should on no account do this for their own accounts because they'll screw themselves up when they work as root or whatever without it has always struck me as an exercise in masochism. The right solution is to fix your root environment so that it also has things set this way. Nor is it terribly difficult to arrange for different people to have different root environments in most situations, to accommodate co-workers with different preferences.)


Comments on this page:

From 74.12.143.77 at 2006-07-29 13:02:07:

I tend to use the <tab> automatic completion of the shell (bash or tcsh) to make sure the destination is there

mv foo ba<tab>r/

If <tab> does not complete the directory name (including the trailing /) I suspect I already mistyped something or I use the double-tab (bash) or ctrl-d (tcsh) to see if there are multiple matches.

Oscar

Written on 29 July 2006.
« A plug for blastwave.org
Link: Ten Risks of PKI »

Page tools: View Source, View Normal.
Search:
Login: Password:

Last modified: Sat Jul 29 00:47:23 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.