Sometimes you may need to copy files from one location to another while also renaming them. This can be useful for various reasons, such as creating a backup, duplicating a configuration file for editing, or generating a new version of a file with a different name. The easiest way to accomplish this task is by using the cp command in Linux.
It is fairly straightforward. By default, the cp command copies the file specified in the first argument to the location of the second argument. For instance, let's copy the /etc/group file into your home directory and renaming it as group_back:
sudo cp /etc/group ~/group_back
In this case, the command includes sudo to grant administrative privileges. This may be necessary for some files, like the group configuration file in the /etc/ directory, which are protected and require elevated permissions for access or modification.
When executed, the command will copy the group configuration file from the /etc/ directory to your home folder, renaming it as group_back.