Copy file to new file ubuntu 18.04

A simple task!

To copy a file to a new file in Ubuntu 18.04, you can use the cp command. Here are a few ways to do it:

Method 1: Copy a file to a new file with the same name

cp original_file new_file

This will create a new file named new_file with the same contents as original_file.

Method 2: Copy a file to a new file with a different name

cp original_file new_file_name

Replace new_file_name with the desired name of the new file.

Method 3: Copy a file to a new file with a different name and directory

cp original_file /path/to/new/directory/new_file_name

Replace /path/to/new/directory with the desired directory path and new_file_name with the desired name of the new file.

Method 4: Copy a file to a new file with a different name and directory, and overwrite if the file already exists

cp -f original_file /path/to/new/directory/new_file_name

The -f option forces the overwrite of the destination file if it already exists.

Method 5: Copy a file to a new file with a different name and directory, and preserve the original file's permissions and timestamps

cp -p original_file /path/to/new/directory/new_file_name

The -p option preserves the original file's permissions and timestamps.

That's it!