Ubuntu Copy File Command

Ubuntu Copy File Command

On Ubuntu Linux, you can use the cp command to copy a file from one location to another. The cp command is a utility that is used to copy files and directories.

To copy a file using the cp command, you can use the following syntax:

cp source_file destination
Sour‮c‬e:www.lautturi.com

Replace source_file with the path to the file you want to copy, and destination with the path to the destination location.

For example, to copy the file file1.txt from the current directory to the /tmp directory, you can run the following command:

cp file1.txt /tmp

If the destination is a directory, the file will be copied into that directory. If the destination is a file, the file will be overwritten if it already exists.

You can also use the -r option to copy directories and their contents recursively. For example, to copy the directory mydir and its contents to the /tmp directory, you can run the following command:

cp -r mydir /tmp

Keep in mind that the cp command does not preserve the ownership and permissions of the source file or directory. If you want to preserve these attributes, you can use the cp -p command instead.

Created Time:2017-10-30 14:27:24  Author:lautturi