Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Linux issues with cp: -r not specified; omitting directory

Writer Matthew Martinez

Can someone help me understand what that means?

cp: -r not specified; omitting directory

I am trying to use this command

sudo cp /home/$USER/Documents/myfile.10 /home

Error:

cp: -r not specified; omitting directory '/home/administrator/Documents/myfile.10'

What does it mean? Why did it happen? What can I do about it?

2

1 Answer

cp: -r not specified; omitting directory '/home/administrator/Documents/myfile.10'

This means myfile.10 is a directory. cp won't copy it, unless you explicitly use -r (or equivalent) flag.

For cp in my Debian these are equivalent: -r, -R, --recursive. POSIX, however defines -R only (-r is mentioned as obsolescent). It says:

If source_file is of type directory, the following steps shall be taken:

  • If the -R option was not specified, cp shall write a diagnostic message to standard error, do nothing more with source_file, and go on to any remaining files.

[...]

The conclusion is your cp does exactly what it's supposed to do. If you want to copy the whole directory, use -R. If you expected myfile.10 to be a non-directory then you need to investigate why the discrepancy.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy