0

I'm running the following command:

sudo cp /srv/site/pro/config/test.env /srv/site/.env 

However, if the file /srv/site/.env already exists it does not seem to overwrite.

How can I make sure the command overwrites the existing file?

1
  • 2
    I'm voting to close this question as off-topic because it's not about programming. It might be a better fit for unix.stackexchange.com Commented Mar 5, 2015 at 16:55

1 Answer 1

4

cp --force or cp -f Please read the man page for cp as well: http://unixhelp.ed.ac.uk/CGI/man-cgi?cp

Sign up to request clarification or add additional context in comments.

2 Comments

This one isn't working for me. I'm trying sudo cp -f -r /home/ubuntu/production/ /srv/shiny-server/ and the files just do not show up
I'm encountering the same. With -r -f it is still not overwriting. In my situation, it's also not copying over new files. I should note that I'm using sudo -u (not that I'm sure it matters) and if I try to copy the file with the full path and not -r, it works fine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.