How to Copy a File in Linux?

Use the `cp` command

Copy a file to another location: `cp source.txt destination.txt`

Copy a file into a directory: `cp source.txt /path/to/directory/`

Copy multiple files into a directory: `cp file1.txt file2.txt /path/to/directory/`

Preserve file attributes: `cp -p source.txt destination.txt`

Prompt before overwrite: `cp -i source.txt destination.txt`

Force overwrite: `cp -f source.txt destination.txt`

Copy recursively for directories: `cp -r source_dir/ destination_dir/`

Copy and show progress: `cp -v source.txt destination.txt`

Suggested for You

Trending Today