Why 'cannot overwrite existing file'?

Solution 1:

If you are running bash, the noclobber option has been set. Use >| if you want to temporarily override this.

Solution 2:

Turn off noclobber in current shell session:

set +o noclobber

Turn on noclobber in current shelll session:

set -o noclobber

See all bash settings:

set -o

References:
https://www.victordodon.com/to-clobber-or-to-noclobber/ https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html

Solution 3:

It is possible that the file was set as immutable with chattr. It's rarely used, but it's a realistic possibility. In that case:

chattr -i [filename]

... should be able to remove that attribute.