How To Copy Files From One Directory To Another In Ubuntu 20.04

Sometimes we are forgetful to change our directory when creating files and ending up creating it in other directory. So here is the command used to copy and paste these files to the destined directory.

$ sudo cp -a Source_Folder Destination_Folder

An example of this is:

 $  sudo cp -a /tmp/wordpress/. /var/www/html

Where the /tmp/wordpress/ is the source folder of “wordpress” file and the /var/www/html is the destnation file.

The “-a” flag turns on recursive behaviour (which can also be done with the -R flag), and will also attempt to preserve metadata such as file ownership, permissions, timestamps, links, etc.

Leave a Comment

Your email address will not be published. Required fields are marked *