{"id":2536,"date":"2023-06-10T09:00:35","date_gmt":"2023-06-10T09:00:35","guid":{"rendered":"https:\/\/draculaservers.com\/tutorials\/?p=2536"},"modified":"2023-06-13T15:48:54","modified_gmt":"2023-06-13T15:48:54","slug":"copy-files-and-directory-linux","status":"publish","type":"post","link":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/","title":{"rendered":"How to Copy Files and Directory in Linux?"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">File handling is one of the most crucial responsibilities of a Linux System Administrator. One important concept in file handling is to copy files and directories to the same and other directories.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you have trouble copying directories or files in <a href=\"https:\/\/ubuntu.com\/\" target=\"_blank\" rel=\"noopener\">Linux<\/a> or Unix-based OS like macOS, this post will guide you. <\/span><\/p>\n\n<p><span style=\"font-weight: 400;\">Let\u2019s begin with the first one!<\/span><\/p>\n<h2 id=\"how-to-copy-a-file-using-the-cp-command-in-linux\"><span style=\"font-weight: 400;\">How to Copy a File Using the cp Command in Linux<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The cp \u201ccopy\u201d command is used to copy files and directories in Linux. To use this command, you need to follow the given syntax:<\/span><\/p>\n<pre>cp source_file target_file<\/pre>\n<p><span style=\"font-weight: 400;\">Let\u2019s try some examples of this file regarding copying files in Linux.<\/span><\/p>\n<h3 id=\"copying-a-file-in-the-same-directory-creating-a-duplicate\"><span style=\"font-weight: 400;\">Copying a File in the Same Directory (Creating a Duplicate)<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">If you want to duplicate the file within the same folder, then you have to pass in the file&#8217;s name to be copied and the name of the duplicate file. For example, we have the following in a directory:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/1-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2537\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/1-2.png\" alt=\"\" width=\"875\" height=\"273\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/1-2.png 875w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/1-2-300x94.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/1-2-768x240.png 768w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">To create the duplicate of the file \u201c<\/span><b>myData.zip<\/b><span style=\"font-weight: 400;\">\u201d as \u201c<\/span><b>dupData.zip<\/b><span style=\"font-weight: 400;\">,\u201d open a terminal and head inside the directory where the file is placed. After that, run the following command:<\/span><\/p>\n<pre>cp myData.zip dupData.zip<\/pre>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/2-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2538\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/2-2.png\" alt=\"\" width=\"967\" height=\"133\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/2-2.png 967w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/2-2-300x41.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/2-2-768x106.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Afterward, you can verify that the file has been copied into the same directory. You can run the \u201c<\/span><b>ls<\/b><span style=\"font-weight: 400;\">\u201d command or view the directory in the explorer:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/3-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2539\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/3-2.png\" alt=\"\" width=\"885\" height=\"165\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/3-2.png 885w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/3-2-300x56.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/3-2-768x143.png 768w\" sizes=\"auto, (max-width: 885px) 100vw, 885px\" \/><\/a><\/p>\n<h3 id=\"copying-a-file-in-a-different-directory\"><span style=\"font-weight: 400;\">Copying a File in a Different Directory<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">In case you want to copy the file in a different directory than the pwd, then you simply pass in the path of the directory and the target file in the <\/span><b>cp <\/b><span style=\"font-weight: 400;\">command. The command template is given as:<\/span><\/p>\n<pre>cp sourceFilePath targetFilePath<\/pre>\n<p><span style=\"font-weight: 400;\">To showcase the working of this command, let\u2019s copy the \u201c<\/span><b>dupData.zip<\/b><span style=\"font-weight: 400;\">\u201d from the previous example onto the Desktop. To do this, the command will become:<\/span><\/p>\n<pre>cp dupData.zip ~\/Desktop\/dup2.zip<\/pre>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/4-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2540\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/4-2.png\" alt=\"\" width=\"963\" height=\"114\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/4-2.png 963w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/4-2-300x36.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/4-2-768x91.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Verify that the copy process was a success by running the ls command on the Desktop:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/5-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2541\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/5-2.png\" alt=\"\" width=\"961\" height=\"168\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/5-2.png 961w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/5-2-300x52.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/5-2-768x134.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/a><\/p>\n<p><b>Note:<\/b><span style=\"font-weight: 400;\"> Remember to use the tilde symbol (<strong>~<\/strong>) if you are passing the complete path from the root. Otherwise, the Linux Kernel will try to locate the directory in the <\/span><b>targetPath <\/b><span style=\"font-weight: 400;\">as a sub-directory of the pwd.<\/span><\/p>\n<h3 id=\"copying-multiple-files-into-a-directory-in-linux\"><span style=\"font-weight: 400;\">Copying Multiple Files Into a Directory in Linux<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To copy multiple files into the same with the same name as the source, you need to specify all the files to be copied on by one in the <\/span><b>cp<\/b><span style=\"font-weight: 400;\"> command and pass the destination directory at the end.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To demonstrate this, we have the following files on the Desktop:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/6-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2542\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/6-2.png\" alt=\"\" width=\"1199\" height=\"197\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/6-2.png 1199w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/6-2-300x49.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/6-2-1024x168.png 1024w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/6-2-768x126.png 768w\" sizes=\"auto, (max-width: 1199px) 100vw, 1199px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s copy the files \u201c<\/span><b>dup2.zip<\/b><span style=\"font-weight: 400;\">\u201d, \u201c<\/span><b>helloWolrd.txt<\/b><span style=\"font-weight: 400;\">\u201d and the \u201c<\/span><b>compress1.zip<\/b><span style=\"font-weight: 400;\">\u201d into the directory \u201c<\/span><b>CopyIntoMe<\/b><span style=\"font-weight: 400;\">\u201d by using the following command:<\/span><\/p>\n<pre>cp dup2.zip helloWolrd.txt compress1.zip ~\/Desktop\/CopyIntoMe\/<\/pre>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/7-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2543\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/7-2.png\" alt=\"\" width=\"1209\" height=\"105\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/7-2.png 1209w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/7-2-300x26.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/7-2-1024x89.png 1024w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/7-2-768x67.png 768w\" sizes=\"auto, (max-width: 1209px) 100vw, 1209px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Verify that the files have been copied into the \u201c<\/span><b>CopyIntoMe<\/b><span style=\"font-weight: 400;\">\u201d directory:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/8-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2544\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/8-2.png\" alt=\"\" width=\"886\" height=\"168\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/8-2.png 886w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/8-2-300x57.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/8-2-768x146.png 768w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">You have successfully copied files into a specific directory.<\/span><\/p>\n<h2 id=\"how-to-copy-a-directory-using-the-cp-command-in-linux\"><span style=\"font-weight: 400;\">How to Copy a Directory Using the cp Command in Linux<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The cp command can be used to copy one directory into another directory. However, most people make the mistake of using the command \u201ccp dirSource dirTarget.\u201d That <strong>doesn\u2019t work<\/strong> because the Linux Kernel will not copy the sub-directories and the files inside the directory.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You need to use the flag \u201c<\/span><b>-r<\/b><span style=\"font-weight: 400;\">,\u201d which stands for \u201c<\/span><b>recursive<\/b><span style=\"font-weight: 400;\">.\u201d This flag executes the copy command for every subdirectory and file inside the directory that is to be copied.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To illustrate the working of the cp command with the \u201c<\/span><b>-r<\/b><span style=\"font-weight: 400;\">,\u201d we have the following directories on the Desktop:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/9-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2545\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/9-2.png\" alt=\"\" width=\"973\" height=\"178\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/9-2.png 973w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/9-2-300x55.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/9-2-768x140.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">To copy the \u201c<\/span><b>CopyIntoMe<\/b><span style=\"font-weight: 400;\">\u201d directory in the \u201c<\/span><b>MyDir<\/b><span style=\"font-weight: 400;\">,\u201d use the following command:<\/span><\/p>\n<pre>cp -r CopyIntoMe\/ MyDir\/<\/pre>\n<p><span style=\"font-weight: 400;\">After the execution of this command, you can verify if the file has been copied or not:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/10-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2546\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/10-2.png\" alt=\"\" width=\"880\" height=\"197\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/10-2.png 880w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/10-2-300x67.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/10-2-768x172.png 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">You have successfully copied the directory into another directory.<\/span><\/p>\n<h2 id=\"affordable-vps-hosting-with-dracula-servers\"><span style=\"font-weight: 400;\">Affordable VPS Hosting With Dracula Servers<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Dracula Servers offers high-performance server hosting at entry-level prices. The plans include Linux VPS, Sneaker Servers, Dedicated Servers &amp; turnkey solutions. If you&#8217;re looking for quality self-managed servers with high amounts of RAM and storage, look no further.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Dracula Server Hosting is also Perfect for Hosting Telegram.Forex App with built-in support for MT4 with trade copier. Check the plans for yourself by clicking <\/span><a href=\"https:\/\/draculaservers.com\/#pick-plan\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Here<\/span><\/a><span style=\"font-weight: 400;\">!<\/span><\/p>\n<h2 id=\"how-to-copy-files-with-the-cp-command-without-overwriting-files\"><span style=\"font-weight: 400;\">How to Copy Files With the cp Command Without Overwriting Files<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The default behavior of the cp command is to copy the files from the source to the target. And if the files already exist with the same name in the target destination, then the file will be overwritten even without a prompt.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To know when an overwrite is about to happen, use the \u201c<\/span><b>-i<\/b><span style=\"font-weight: 400;\">.\u201d This flag is known as the interactive flag, and its alternative is \u201c<\/span><b>&#8211;interactive<\/b><span style=\"font-weight: 400;\">.\u201d When a cp command is executed with an overwrite about to happen, you will get a similar prompt:<\/span><\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/11-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2547\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/11-2.png\" alt=\"\" width=\"973\" height=\"138\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/11-2.png 973w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/11-2-300x43.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/11-2-768x109.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">If you wish to continue with the overwrite, you must type \u201cy\u201d and then press the Enter key.\u00a0<\/span><\/p>\n<h2 id=\"wrap-up\"><span style=\"font-weight: 400;\">Wrap up<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">You can use the built-in <strong>cp<\/strong> command to copy a file or a directory in Linux and in a Unix-based operating system like macOS. The cp command itself stands for \u201c<strong>copy<\/strong>.\u201d <\/span><\/p>\n<p><span style=\"font-weight: 400;\">The cp command takes the path of the source file to be copied and the path of the destination file. You can use the command to create a duplicate of a file as well. However, if you want to copy a directory and its content, you will have to use the \u201c<strong>-r<\/strong>\u201d flag with the cp command. The \u201c<strong>-r<\/strong>\u201d flag stands for recursive, and it causes the cp command to be executed for every sub-directory and file within the directory to be copied.<\/span><\/p>\n<p><strong><a href=\"https:\/\/draculaservers.com\/tutorials\/\" target=\"_blank\" rel=\"noopener\">Check out more useful Linux\/Ubuntu Tutorials Here!<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>File handling is one of the most crucial responsibilities of a Linux System Administrator. One important concept in file handling is to copy files and directories to the same and other directories.\u00a0 If you have trouble copying directories or files in Linux or Unix-based OS like macOS, this post will guide you. Let\u2019s begin with [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":2549,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,2],"tags":[139,138,141,140,142],"class_list":["post-2536","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-getting-started","category-linux-basics","tag-copy-directory","tag-copy-files","tag-copy-in-unix","tag-cp-command","tag-cp-in-macos"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"featured_image_urls_v2":{"full":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png",1280,720,false],"thumbnail":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux-150x150.png",150,150,true],"medium":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux-300x169.png",300,169,true],"medium_large":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux-768x432.png",768,432,true],"large":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux-1024x576.png",1024,576,true],"1536x1536":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png",1280,720,false],"2048x2048":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png",1280,720,false],"pk-small":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux-80x80.png",80,80,true],"pk-thumbnail":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux-300x225.png",300,225,true]},"post_excerpt_stackable_v2":"<p>File handling is one of the most crucial responsibilities of a Linux System Administrator. One important concept in file handling is to copy files and directories to the same and other directories.\u00a0 If you have trouble copying directories or files in Linux or Unix-based OS like macOS, this post will guide you. Let\u2019s begin with the first one! How to Copy a File Using the cp Command in Linux The cp \u201ccopy\u201d command is used to copy files and directories in Linux. To use this command, you need to follow the given syntax: cp source_file target_file Let\u2019s try some examples&hellip;<\/p>\n","category_list_v2":"<a href=\"https:\/\/draculaservers.com\/tutorials\/category\/getting-started\/\" rel=\"category tag\">Getting Started<\/a>, <a href=\"https:\/\/draculaservers.com\/tutorials\/category\/linux-basics\/\" rel=\"category tag\">Linux Basics<\/a>","author_info_v2":{"name":"Abdul Mannan","url":"https:\/\/draculaservers.com\/tutorials\/author\/abdul-mannan-tbgmail-com\/"},"comments_num_v2":"0 comments","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Copy Files and Directory in Linux? - Dracula Servers Tutorials<\/title>\n<meta name=\"description\" content=\"To copy files in Linux, you can use the built-in cp command by specifying sourceFilePath and destinationPath. For directory, add the -r Flag.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Copy Files and Directory in Linux? - Dracula Servers Tutorials\" \/>\n<meta property=\"og:description\" content=\"To copy files in Linux, you can use the built-in cp command by specifying sourceFilePath and destinationPath. For directory, add the -r Flag.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Dracula Servers Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-10T09:00:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-13T15:48:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abdul Mannan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abdul Mannan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ac89d0281f4fb596bfaa0bc1e746c8a6\"},\"headline\":\"How to Copy Files and Directory in Linux?\",\"datePublished\":\"2023-06-10T09:00:35+00:00\",\"dateModified\":\"2023-06-13T15:48:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/\"},\"wordCount\":908,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/How-to-Copy-a-Directory-in-Linux.png\",\"keywords\":[\"Copy Directory\",\"Copy Files\",\"copy in Unix\",\"cp command\",\"cp in macOS\"],\"articleSection\":[\"Getting Started\",\"Linux Basics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/\",\"name\":\"How to Copy Files and Directory in Linux? - Dracula Servers Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/How-to-Copy-a-Directory-in-Linux.png\",\"datePublished\":\"2023-06-10T09:00:35+00:00\",\"dateModified\":\"2023-06-13T15:48:54+00:00\",\"description\":\"To copy files in Linux, you can use the built-in cp command by specifying sourceFilePath and destinationPath. For directory, add the -r Flag.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#primaryimage\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/How-to-Copy-a-Directory-in-Linux.png\",\"contentUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/How-to-Copy-a-Directory-in-Linux.png\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/copy-files-and-directory-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Copy Files and Directory in Linux?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\",\"name\":\"Dracula Servers Tutorials\",\"description\":\"Dedicated Servers\",\"publisher\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\",\"name\":\"Dracula Servers\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/06\\\/dracula_full_logo_smaller.png\",\"contentUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/06\\\/dracula_full_logo_smaller.png\",\"width\":1625,\"height\":200,\"caption\":\"Dracula Servers\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ac89d0281f4fb596bfaa0bc1e746c8a6\",\"name\":\"Abdul Mannan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"caption\":\"Abdul Mannan\"},\"description\":\"An individual trying to decipher the enigmas of technology by the sheer driving force of curiosity. Interested in learning new skills and being better at those skills than the lot.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Copy Files and Directory in Linux? - Dracula Servers Tutorials","description":"To copy files in Linux, you can use the built-in cp command by specifying sourceFilePath and destinationPath. For directory, add the -r Flag.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Copy Files and Directory in Linux? - Dracula Servers Tutorials","og_description":"To copy files in Linux, you can use the built-in cp command by specifying sourceFilePath and destinationPath. For directory, add the -r Flag.","og_url":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/","og_site_name":"Dracula Servers Tutorials","article_published_time":"2023-06-10T09:00:35+00:00","article_modified_time":"2023-06-13T15:48:54+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png","type":"image\/png"}],"author":"Abdul Mannan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abdul Mannan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#article","isPartOf":{"@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/person\/ac89d0281f4fb596bfaa0bc1e746c8a6"},"headline":"How to Copy Files and Directory in Linux?","datePublished":"2023-06-10T09:00:35+00:00","dateModified":"2023-06-13T15:48:54+00:00","mainEntityOfPage":{"@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/"},"wordCount":908,"commentCount":0,"publisher":{"@id":"https:\/\/draculaservers.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png","keywords":["Copy Directory","Copy Files","copy in Unix","cp command","cp in macOS"],"articleSection":["Getting Started","Linux Basics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/","url":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/","name":"How to Copy Files and Directory in Linux? - Dracula Servers Tutorials","isPartOf":{"@id":"https:\/\/draculaservers.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#primaryimage"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png","datePublished":"2023-06-10T09:00:35+00:00","dateModified":"2023-06-13T15:48:54+00:00","description":"To copy files in Linux, you can use the built-in cp command by specifying sourceFilePath and destinationPath. For directory, add the -r Flag.","breadcrumb":{"@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#primaryimage","url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png","contentUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2023\/06\/How-to-Copy-a-Directory-in-Linux.png","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/draculaservers.com\/tutorials\/copy-files-and-directory-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/draculaservers.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to Copy Files and Directory in Linux?"}]},{"@type":"WebSite","@id":"https:\/\/draculaservers.com\/tutorials\/#website","url":"https:\/\/draculaservers.com\/tutorials\/","name":"Dracula Servers Tutorials","description":"Dedicated Servers","publisher":{"@id":"https:\/\/draculaservers.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/draculaservers.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/draculaservers.com\/tutorials\/#organization","name":"Dracula Servers","url":"https:\/\/draculaservers.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2016\/06\/dracula_full_logo_smaller.png","contentUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2016\/06\/dracula_full_logo_smaller.png","width":1625,"height":200,"caption":"Dracula Servers"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/person\/ac89d0281f4fb596bfaa0bc1e746c8a6","name":"Abdul Mannan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","caption":"Abdul Mannan"},"description":"An individual trying to decipher the enigmas of technology by the sheer driving force of curiosity. Interested in learning new skills and being better at those skills than the lot."}]}},"_links":{"self":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/2536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/comments?post=2536"}],"version-history":[{"count":6,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/2536\/revisions"}],"predecessor-version":[{"id":2557,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/2536\/revisions\/2557"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/media\/2549"}],"wp:attachment":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/media?parent=2536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/categories?post=2536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/tags?post=2536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}