While working in the terminal, you often have to copy files. Most often, the cp Linux command is used for this. It is supplied by default in all distributions and is able to copy files and folders, as well as save their attributes in Linux file systems.
About the cp team
The "cp" command in Linux is used to copy files and directories. The syntax of the command is as follows:
cp [options] <source file/directory> <target file/directory>
For example, to copy a file "file.txt " in the directory "/home/user/documents" you can use the following command:
cp file.txt /home/user/documents/
If you need to copy all files from the "dir1" directory to the "dir2" directory, you can use the following command:
cp -r dir1/* dir2/
Some of the most commonly used options of the "cp" command are:
-r or --recursive: copying directories recursively, including all files and subdirectories;
-v or --verbose: output information about the copying process;
-i or --interactive: request confirmation before copying files;
-u or --update: copying only those files that are newer than the existing ones in the target directory;
-p or --preserve: save file attributes (owner, access rights, timestamps, etc.).
More detailed information about the "cp" command and its options can be obtained by running the "man cp" command.