Adventures As Me


why -i is good for you

Written 10 Feb 2004

Sunday I dorked my website configuration. While in the process of pruning old directories, files and programs I performed the following:

[datasrc - root - ~/www/htdocs/dir ]
# cp .htaccess ..
This of course copied the .htaccess file to my document root. This proceeded to confused Apache, which then refused to run anything except static html pages.

Why did this happen? Because by default cp will overwrite existing files without warning. If I used the -i the program would prompt me before overwriting the existing file. like this:

[datasrc - root - ~/tmp/ ]
# cp -i temp ..
cp: cannot stat `temp': No such file or directory
[datasrc - root - ~/tmp/ ]
# cp -i list ..
cp: overwrite `../list'?

Eventually I fixed the problem and my site now works properly. A good reminder, and likely the reason some define the following:

alias cp='cp -i'
in their .bashrc files.

Related Posts