cp -ip ${file_name}

-i option: to confirm when overwriting is necessary
In contrast to the -f option, sometimes you want to check whether it will be overwritten. When dealing with important files, overwriting is a fatal injury.

$cp -i after original copy

“yes or no” confirmation will come out.

cp -i

In recent distributions this is the default as well. If it is not set it may be set with alias.

-p opiton(-parents): copy each directory structure
With the usual cp command, you can not copy in subdirectories. In that case, use the “-P” option.

Running without options in the example will normally just let file.txt go into the directory. Using the –parents option you will find that you can copy the directory structure as is.

[vagrant@localhost ~]$ cp -ip /etc/lsyncd.conf{,.org}
cp: cannot create regular file `/etc/lsyncd.conf.org’: 許可がありません
[vagrant@localhost ~]$ sudo cp -ip /etc/lsyncd.conf{,.org}