How can I copy files to a specified path in Ubuntu?

To copy files to a specific directory, you can use the cp command. The command format is as follows:

cp [options] source destination

Source is the file or directory path to be copied, while destination is the target path after copying.

To copy the file.txt from /home/user/ to /home/user/backup/ directory, you can use the following command:

cp /home/user/file.txt /home/user/backup/

To copy an entire directory and its contents, you can use the -r option, which signifies recursive copy. For example:

cp -r /home/user/directory /home/user/backup/

This will copy the directory /home/user/directory and its contents to /home/user/backup/.

You can also use the -v option to display a detailed copying process. For example:

cp -v /home/user/file.txt /home/user/backup/

This will display the name of each duplicated file.

In addition to the basic functions mentioned above, the cp command also offers numerous other options and parameters that can be adjusted according to your needs. You can use the “man cp” command to view the detailed usage of the cp command.

bannerAds