🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 169 (from laksa006)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
24 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.8 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://builtin.com/articles/linux-cp-command
Last Crawled2026-03-17 09:07:32 (24 days ago)
First Indexed2024-08-29 08:51:22 (1 year ago)
HTTP Status Code200
Meta TitleLinux cp Command: How to Copy a File or Directory | Built In
Meta DescriptionThe cp command allows you to duplicate files or directories from one part of the file system to another.
Meta Canonicalnull
Boilerpipe Text
In Linux, tasks like efficient navigation through file systems and certain operations like copying, moving or deleting files rely on the terminal . This tool gives users access to the core functionalities of the operating system. Unlike graphical interfaces , which can sometimes be limiting or slow, the Linux terminal provides an interface for quick and efficient execution of certain tasks that interact directly with the underlying system. By running commands, users can quickly execute tasks that would otherwise require multiple steps through a graphical interface. One of the most useful and commonly used commands is  cp . Short for “ copy, ” the command is used to duplicate files or entire directories from one location of the file system to another. Linux cp Command Syntax cp source_file target_file More From Giorgos Myrianthous How to Fix AttributeError: ‘DataFrame’ Object Has No Attribute ‘Append’ The cp Command Syntax Before looking into the details, the basic synopsis of the cp command is as follows: cp source_file target_file Features and Options of the cp C ommand  The capabilities and customization options of the cp command extend far beyond its basic syntax, however. This versatility make it adaptable to a wide range of use cases. Some of the most useful options are outlined below.  -R   This option allows you to copy directories, along with their contents, into the specified destination location. The newly created destination directories will also have the same mode as the corresponding source directory. cp -R folder_with_files new_folder_with_the_same_files -p This option preserves the attributes of each source file in the copy, including modification time, access time, file flags and file mode. cp -p my_file.txt /home/my_file_copy.txt -i This option is particularly useful when you want to have some additional control over the process of copying file(s) or directories. Short for “interactive,” it will prompt the user before overwriting any existing files. In order for the operation to proceed, the user will have to type y (or Y). Alternatively, the copy operation is canceled.  cp -i my_file.txt /home/my_file.txt -v   This option, short for “verbose,” will cause the command to show the progress of the files being copied. This is particularly useful when the copy operation involves multiple files. cp -v my_file.txt /home/my_file_copy.txt -n Finally, this option will prevent any file overwrites. This flag will override the -i  option and, if the destination file or directory already exists, it will prevent any resources from getting overwritten. Note, however, this is a small subset of all possible options that you can use with the cp command. For the full list of available options, you can refer to the General Commands Manual, which is accessible by running the following command in the terminal: man cp Video: YouTube How to Use the cp Command to Copy Files and Directories in Linux Now that we’ve covered the basics and features of the cp command, let ’ s dive into more practical examples. In this section, we ’ ll explore how to use the cp command to copy files and directories in various scenarios, ranging from simple file copies to more complex operations involving multiple files and directories. How to Copy a File in Linux Copying a single file with the cp command is simple. The following command will simply copy the my_file.txt file and store it under the same (current working) directory, with the name my_file_copy.txt . cp my_file.txt my_file_copy.txt If you’d like to create a copy of the file and store it in a directory other than the current one, you can simply specify the desired location in the destination.  cp my_file.txt /home/Desktop/my_file_copy.txt If you want to keep the same name while copying the file into a different directory, you can even omit the file name itself . cp my_file.txt /home/Desktop/ This command will create a copy of my_file.txt file under /home/Desktop/ directory and retain the destination file name. How to Copy Multiple Files in Linux To copy multiple files at once, list each file as a source , followed by the destination directory: cp file1.txt file2.txt /path/to/destination This command will copy both file1.txt and file2.txt into the specified destination directory. How to Copy Files That Match a Glob Pattern in Linux You can use wildcard characters to copy files that match a specific pattern. For example, to copy all .txt files from one directory to another: cp *.txt /path/to/destination This command copies all files with a .txt extension to the destination directory. How to Copy Directories in Linux To copy a directory and all of its contents, use the -R (recursive) option: cp -r / path / to /source_directory / path / to /destination/ This command copies the entire source_directory and all its subdirectories and files to the specified destination directory. How to Prevent Overwriting Files With cp Command When working directly in the terminal and executing commands, you always need to be careful since you can’t reverse most operations. So, when it comes to creating copies of files or directories, you should ensure that you won’t accidentally overwrite existing files.  Fortunately, a few different options that come along with the cp command can help you mitigate this risk.  By default, the cp command will overwrite files in the destination if they already exist. To prevent this, you can use the -i option, which will prompt you before overwriting: cp -i file .txt /path/ to /destination/ If the file already exists, you will be asked whether you want to overwrite it. Alternatively, you can use the -n option to prevent overwriting without a prompt: cp -n file .txt /path/ to /destination/ This ensures that existing files are not overwritten, and the command will silently skip any files that already exist in the destination. The scp Command for Secure Remote Copying Although the cp command is a great tool for copying files and directories within your local system, there are times when you need to transfer files between different machines securely.  That’s where the scp command comes in. The term  scp , short for “ secure copy, ” is a command-line command that allows you to securely transfer files and directories between a local and remote host or between two remote hosts. The basic syntax of the scp command is: scp [ options ] source user@hos t:destination where source  is the file or directory you want to copy user@host  specifies the remote user and host (e.g. user@127.0.0.1 ) Destination  is the path on the remote host where the file or directory will be copied For instance, the following command copies file.txt from your local machine to the specified directory on the remote server. scp file.txt user @remotehost :/path/to/destination/ Likewise, if you would like to copy a directory, the -R  option should do the trick: scp -R /home/contacts user @remotehost :/home You can even copy a file from a remote server into your local machine by switching source and destination specification:  scp user @remotehost :/home/file .txt /local/destination/ More on the scp Command How to Use the SCP Command in Linux to Securely Transfer Files Master the cp Command Mastering the cp command is a crucial skill for any Linux user, providing the ability to efficiently manage and organize files and directories. From basic copying to more advanced operations with various options, the cp command is simple, yet powerful. Additionally, understanding related commands like scp further enhances your ability to securely transfer files across different machines.  Short for “ copy, ” the cp command is used in Linux to duplicate files or entire directories from one location of the file system to another. You can use the cp command to copy a file in Linux. Its syntax is  cp source_file target_file .
Markdown
[![Built In Logo](https://static.builtin.com/dist/images/bi-header-logo.svg) ![Built In Logo](https://static.builtin.com/dist/images/bi-header-logo.svg)](https://builtin.com/) [In Jobs](https://builtin.com/jobs?search=) [![Company Photo]()]() [Can't find your company? Create a company profile.](https://builtin.com/node/add/company) [View All Jobs](https://builtin.com/jobs) [For Employers](https://employers.builtin.com/?utm_medium=BIReferral&utm_source=foremployers) [Join](https://builtin.com/auth/signup?destination=%2Farticles%2Flinux-cp-command) [Log In](https://builtin.com/auth/login?destination=%2Farticles%2Flinux-cp-command) - [Jobs](https://builtin.com/jobs) - [Companies](https://builtin.com/companies) - [Remote](https://builtin.com/jobs/remote) - [Articles](https://builtin.com/tech-topics) - [Best Places To Work](https://builtin.com/awards/us/2026/best-places-to-work) - [Job Application Tracker](https://builtin.com/auth/login?destination=%2Fhome%23application-tracker-section) - [Software Engineering Perspectives](https://builtin.com/tag/software-engineering-perspectives "Software Engineering Perspectives") - [Expert Contributors](https://builtin.com/tag/expert-contributors "Expert Contributors") - [Software](https://builtin.com/tag/software "Software") - \+2 - [Software Engineering](https://builtin.com/tag/software-engineering "Software Engineering") - [Linux](https://builtin.com/tag/linux "Linux") - \+4 # Linux cp Command: How to Copy a File or Directory The cp command allows you to duplicate files or directories from one part of the file system to another. ![Giorgos Myrianthous](https://cdn.builtin.com/cdn-cgi/image/f=auto,w=96,h=96,q=100/sites/www.builtin.com/files/2022-10/Giorgos_Myrianthous.png) Written by [Giorgos Myrianthous](https://builtin.com/authors/giorgos-myrianthous) Published on Aug. 28, 2024 ![The word "Linux" spelled out in keyboard keys above a keyboard](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=cover,w=320,h=200,q=80/sites/www.builtin.com/files/2024-08/linux-cp-command.png) Image: Shutterstock / Built In ![Brand Studio Logo](https://static.builtin.com/dist/images/expert-badge.svg) In Linux, tasks like efficient navigation through file systems and certain operations like copying, moving or deleting files rely on the [terminal](https://builtin.com/software-engineering-perspectives/terminal-commands). This tool gives users access to the core functionalities of the operating system. Unlike [graphical interfaces](https://builtin.com/software-engineering-perspectives/graphical-user-interface), which can sometimes be limiting or slow, the Linux terminal provides an interface for quick and efficient execution of certain tasks that interact directly with the underlying system. By running commands, users can quickly execute tasks that would otherwise require multiple steps through a graphical interface. One of the most useful and commonly used commands is `cp`. Short for “copy,” the command is used to duplicate files or entire directories from one location of the file system to another. ## Linux cp Command Syntax ``` cp source_file target_file ``` More From Giorgos Myrianthous[How to Fix AttributeError: ‘DataFrame’ Object Has No Attribute ‘Append’](https://builtin.com/articles/attributeerror-dataframe-object-has-no-attribute-append) ## The cp Command Syntax Before looking into the details, the basic synopsis of the `cp` command is as follows: ``` cp source_file target_file ``` ## Features and Options of the cp Command The capabilities and customization options of the `cp` command extend far beyond its basic syntax, however. This versatility make it adaptable to a wide range of use cases. Some of the most useful options are outlined below. ### \-R This option allows you to copy directories, along with their contents, into the specified destination location. The newly created destination directories will also have the same mode as the corresponding source directory. ``` cp -R folder_with_files new_folder_with_the_same_files ``` ### \-p This option preserves the attributes of each source file in the copy, including modification time, access time, file flags and file mode. ``` cp -p my_file.txt /home/my_file_copy.txt ``` ### \-i This option is particularly useful when you want to have some additional control over the process of copying file(s) or directories. Short for “interactive,” it will prompt the user before overwriting any existing files. In order for the operation to proceed, the user will have to type y (or Y). Alternatively, the copy operation is canceled. ``` cp -i my_file.txt /home/my_file.txt ``` ### \-v This option, short for “verbose,” will cause the command to show the progress of the files being copied. This is particularly useful when the copy operation involves multiple files. ``` cp -v my_file.txt /home/my_file_copy.txt ``` ### \-n Finally, this option will prevent any file overwrites. This flag will override the `-i` option and, if the destination file or directory already exists, it will prevent any resources from getting overwritten. Note, however, this is a small subset of all possible options that you can use with the `cp` command. For the full list of available options, you can refer to the General Commands Manual, which is accessible by running the following command in the terminal: ``` man cp ``` Video: YouTube ## How to Use the cp Command to Copy Files and Directories in Linux Now that we’ve covered the basics and features of the `cp` command, let’s dive into more practical examples. In this section, we’ll explore how to use the `cp` command to copy files and directories in various scenarios, ranging from simple file copies to more complex operations involving multiple files and directories. ### How to Copy a File in Linux Copying a single file with the `cp` command is simple. The following command will simply copy the `my_file.txt` file and store it under the same (current working) directory, with the name `my_file_copy.txt`. ``` cp my_file.txt my_file_copy.txt ``` If you’d like to create a copy of the file and store it in a directory other than the current one, you can simply specify the desired location in the destination. ``` cp my_file.txt /home/Desktop/my_file_copy.txt ``` If you want to keep the same name while copying the file into a different directory, you can even omit the file name itself. ``` cp my_file.txt /home/Desktop/ ``` This command will create a copy of `my_file.txt` file under `/home/Desktop/` directory and retain the destination file name. ### How to Copy Multiple Files in Linux To copy multiple files at once, list each file as a source, followed by the destination directory: ``` cp file1.txt file2.txt /path/to/destination ``` This command will copy both `file1.txt` and `file2.txt` into the specified destination directory. ### How to Copy Files That Match a Glob Pattern in Linux You can use wildcard characters to copy files that match a specific pattern. For example, to copy all `.txt` files from one directory to another: ``` cp *.txt /path/to/destination ``` This command copies all files with a `.txt` extension to the destination directory. ### How to Copy Directories in Linux To copy a directory and all of its contents, use the `-R` (recursive) option: ``` cp -r /path/to/source_directory /path/to/destination/ ``` This command copies the entire `source_directory` and all its subdirectories and files to the specified destination directory. ## How to Prevent Overwriting Files With cp Command When working directly in the terminal and executing commands, you always need to be careful since you can’t reverse most operations. So, when it comes to creating copies of files or directories, you should ensure that you won’t accidentally overwrite existing files. Fortunately, a few different options that come along with the `cp` command can help you mitigate this risk. By default, the `cp` command will overwrite files in the destination if they already exist. To prevent this, you can use the `-i` option, which will prompt you before overwriting: ``` cp -i file.txt /path/to/destination/ ``` If the file already exists, you will be asked whether you want to overwrite it. Alternatively, you can use the `-n` option to prevent overwriting without a prompt: ``` cp -n file.txt /path/to/destination/ ``` This ensures that existing files are not overwritten, and the command will silently skip any files that already exist in the destination. ## The scp Command for Secure Remote Copying Although the `cp` command is a great tool for copying files and directories within your local system, there are times when you need to transfer files between different machines securely. That’s where the [scp command](https://builtin.com/articles/scp-command) comes in. The term `scp`, short for “secure copy,” is a [command-line](https://builtin.com/software-engineering-perspectives/command-line-interface) command that allows you to securely transfer files and directories between a local and remote host or between two remote hosts. The basic syntax of the `scp` command is: ``` scp [options] source user@host:destination ``` where - **source** is the file or directory you want to copy - **user@host** specifies the remote user and host (e.g. user@127.0.0.1) - **Destination** is the path on the remote host where the file or directory will be copied For instance, the following command copies `file.txt` from your local machine to the specified directory on the remote server. ``` scp file.txt user@remotehost:/path/to/destination/ ``` Likewise, if you would like to copy a directory, the `-R` option should do the trick: ``` scp -R /home/contacts user@remotehost:/home ``` You can even copy a file from a remote server into your local machine by switching source and destination specification: ``` scp user@remotehost:/home/file.txt /local/destination/ ``` More on the scp Command[How to Use the SCP Command in Linux to Securely Transfer Files](https://builtin.com/articles/scp-command) ## Master the cp Command Mastering the `cp` command is a crucial skill for any Linux user, providing the ability to efficiently manage and organize files and directories. From basic copying to more advanced operations with various options, the cp command is simple, yet powerful. Additionally, understanding related commands like `scp` further enhances your ability to securely transfer files across different machines. ## Frequently Asked Questions ### What is the cp command in Linux? Short for “copy,” the `cp` command is used in Linux to duplicate files or entire directories from one location of the file system to another. ### How do you copy a file in Linux? You can use the `cp` command to copy a file in Linux. Its syntax is `cp source_file target_file`. ### Recent Software Engineering Perspectives Articles [![84 Companies Hiring Developers](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=contain,w=120,h=70,q=80/sites/www.builtin.com/files/2024-05/companies%20hiring%20developers.png) 84 Companies Hiring Developers](https://builtin.com/articles/companies-hiring-developers) [![100 Software Development Companies Innovating Tech](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=contain,w=120,h=70,q=80/sites/www.builtin.com/files/software-development-companies_3.jpg) 100 Software Development Companies Innovating Tech](https://builtin.com/articles/software-development-companies) [![The Computer Science Degree Is Losing its Luster in the Age of AI](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=contain,w=120,h=70,q=80/sites/www.builtin.com/files/2026-03/college-grad-degrees-ai.jpg) The Computer Science Degree Is Losing its Luster in the Age of AI](https://builtin.com/articles/computer-science-degree-decline-ai) Explore Job Matches. Job Title or Keyword Clear search Location Fully Remote, Hybrid, On Site Fully Remote Hybrid On Site Clear Apply See Jobs - [Jobs](https://builtin.com/jobs) - [Companies](https://builtin.com/companies) - [Articles](https://builtin.com/tech-topics) - [Tracker](https://builtin.com/auth/login?destination=%2Fhome%23application-tracker-section) - More ![Built In](https://static.builtin.com/dist/images/midnight_9.svg) [Join](https://builtin.com/auth/signup?destination=%2Farticles%2Flinux-cp-command) [Log In](https://builtin.com/auth/login?destination=%2Farticles%2Flinux-cp-command) - [Tech Jobs](https://builtin.com/jobs) - [Companies](https://builtin.com/companies) - [Articles](https://builtin.com/tech-topics) - [Remote](https://builtin.com/jobs/remote) - [Best Places To Work](https://builtin.com/awards/us/2026/best-places-to-work) - [Tech Hubs](https://builtin.com/tech-hubs) [Post Job](https://employers.builtin.com/membership?utm_medium=BIReferral&utm_source=foremployers) [![BuiltIn](https://static.builtin.com/dist/images/builtin-logo.svg)](https://builtin.com/) ![United We Tech](https://static.builtin.com/dist/images/united-we-tech.svg) Built In is the online community for startups and tech companies. Find startup jobs, tech news and events. About [Our Story](https://builtin.com/our-story) [Careers](https://employers.builtin.com/careers/) [Our Staff Writers](https://builtin.com/our-staff) [Content Descriptions](https://builtin.com/content-descriptions) *** Get Involved [Recruit With Built In](https://employers.builtin.com/membership?utm_medium=BIReferral&utm_source=foremployers) [Become an Expert Contributor](https://builtin.com/expert-contributors) *** Resources [Customer Support](https://knowledgebase.builtin.com/s/) [Share Feedback](https://form.jotform.com/223044927257054) [Report a Bug](https://knowledgebase.builtin.com/s/contactsupport) [Tech Job Tools + Career Resources](https://builtin.com/articles/grow-your-career) [Browse Jobs](https://builtin.com/browse-jobs) [Tech A-Z](https://builtin.com/tech-dictionary) *** Tech Hubs [Our Sites](https://builtin.com/our-sites) *** [Learning Lab User Agreement](https://builtin.com/learning-lab-user-agreement) [Accessibility Statement](https://builtin.com/accessibility-statement) [Copyright Policy](https://builtin.com/copyright-policy) [Privacy Policy](https://builtin.com/privacy-policy) [Terms of Use](https://builtin.com/community-terms-of-use) [Your Privacy Choices/Cookie Settings](https://builtin.com/california-do-not-sell-my-information) [CA Notice of Collection](https://builtin.com/ca-notice-collection) © Built In 2026
Readable Markdown
In Linux, tasks like efficient navigation through file systems and certain operations like copying, moving or deleting files rely on the [terminal](https://builtin.com/software-engineering-perspectives/terminal-commands). This tool gives users access to the core functionalities of the operating system. Unlike [graphical interfaces](https://builtin.com/software-engineering-perspectives/graphical-user-interface), which can sometimes be limiting or slow, the Linux terminal provides an interface for quick and efficient execution of certain tasks that interact directly with the underlying system. By running commands, users can quickly execute tasks that would otherwise require multiple steps through a graphical interface. One of the most useful and commonly used commands is `cp`. Short for “copy,” the command is used to duplicate files or entire directories from one location of the file system to another. ## Linux cp Command Syntax ``` cp source_file target_file ``` More From Giorgos Myrianthous[How to Fix AttributeError: ‘DataFrame’ Object Has No Attribute ‘Append’](https://builtin.com/articles/attributeerror-dataframe-object-has-no-attribute-append) ## The cp Command Syntax Before looking into the details, the basic synopsis of the `cp` command is as follows: ``` cp source_file target_file ``` ## Features and Options of the cp Command The capabilities and customization options of the `cp` command extend far beyond its basic syntax, however. This versatility make it adaptable to a wide range of use cases. Some of the most useful options are outlined below. ### \-R This option allows you to copy directories, along with their contents, into the specified destination location. The newly created destination directories will also have the same mode as the corresponding source directory. ``` cp -R folder_with_files new_folder_with_the_same_files ``` ### \-p This option preserves the attributes of each source file in the copy, including modification time, access time, file flags and file mode. ``` cp -p my_file.txt /home/my_file_copy.txt ``` ### \-i This option is particularly useful when you want to have some additional control over the process of copying file(s) or directories. Short for “interactive,” it will prompt the user before overwriting any existing files. In order for the operation to proceed, the user will have to type y (or Y). Alternatively, the copy operation is canceled. ``` cp -i my_file.txt /home/my_file.txt ``` ### \-v This option, short for “verbose,” will cause the command to show the progress of the files being copied. This is particularly useful when the copy operation involves multiple files. ``` cp -v my_file.txt /home/my_file_copy.txt ``` ### \-n Finally, this option will prevent any file overwrites. This flag will override the `-i` option and, if the destination file or directory already exists, it will prevent any resources from getting overwritten. Note, however, this is a small subset of all possible options that you can use with the `cp` command. For the full list of available options, you can refer to the General Commands Manual, which is accessible by running the following command in the terminal: ``` man cp ``` Video: YouTube ## How to Use the cp Command to Copy Files and Directories in Linux Now that we’ve covered the basics and features of the `cp` command, let’s dive into more practical examples. In this section, we’ll explore how to use the `cp` command to copy files and directories in various scenarios, ranging from simple file copies to more complex operations involving multiple files and directories. ### How to Copy a File in Linux Copying a single file with the `cp` command is simple. The following command will simply copy the `my_file.txt` file and store it under the same (current working) directory, with the name `my_file_copy.txt`. ``` cp my_file.txt my_file_copy.txt ``` If you’d like to create a copy of the file and store it in a directory other than the current one, you can simply specify the desired location in the destination. ``` cp my_file.txt /home/Desktop/my_file_copy.txt ``` If you want to keep the same name while copying the file into a different directory, you can even omit the file name itself. ``` cp my_file.txt /home/Desktop/ ``` This command will create a copy of `my_file.txt` file under `/home/Desktop/` directory and retain the destination file name. ### How to Copy Multiple Files in Linux To copy multiple files at once, list each file as a source, followed by the destination directory: ``` cp file1.txt file2.txt /path/to/destination ``` This command will copy both `file1.txt` and `file2.txt` into the specified destination directory. ### How to Copy Files That Match a Glob Pattern in Linux You can use wildcard characters to copy files that match a specific pattern. For example, to copy all `.txt` files from one directory to another: ``` cp *.txt /path/to/destination ``` This command copies all files with a `.txt` extension to the destination directory. ### How to Copy Directories in Linux To copy a directory and all of its contents, use the `-R` (recursive) option: ``` cp -r /path/to/source_directory /path/to/destination/ ``` This command copies the entire `source_directory` and all its subdirectories and files to the specified destination directory. ## How to Prevent Overwriting Files With cp Command When working directly in the terminal and executing commands, you always need to be careful since you can’t reverse most operations. So, when it comes to creating copies of files or directories, you should ensure that you won’t accidentally overwrite existing files. Fortunately, a few different options that come along with the `cp` command can help you mitigate this risk. By default, the `cp` command will overwrite files in the destination if they already exist. To prevent this, you can use the `-i` option, which will prompt you before overwriting: ``` cp -i file.txt /path/to/destination/ ``` If the file already exists, you will be asked whether you want to overwrite it. Alternatively, you can use the `-n` option to prevent overwriting without a prompt: ``` cp -n file.txt /path/to/destination/ ``` This ensures that existing files are not overwritten, and the command will silently skip any files that already exist in the destination. ## The scp Command for Secure Remote Copying Although the `cp` command is a great tool for copying files and directories within your local system, there are times when you need to transfer files between different machines securely. That’s where the [scp command](https://builtin.com/articles/scp-command) comes in. The term `scp`, short for “secure copy,” is a [command-line](https://builtin.com/software-engineering-perspectives/command-line-interface) command that allows you to securely transfer files and directories between a local and remote host or between two remote hosts. The basic syntax of the `scp` command is: ``` scp [options] source user@host:destination ``` where - **source** is the file or directory you want to copy - **user@host** specifies the remote user and host (e.g. user@127.0.0.1) - **Destination** is the path on the remote host where the file or directory will be copied For instance, the following command copies `file.txt` from your local machine to the specified directory on the remote server. ``` scp file.txt user@remotehost:/path/to/destination/ ``` Likewise, if you would like to copy a directory, the `-R` option should do the trick: ``` scp -R /home/contacts user@remotehost:/home ``` You can even copy a file from a remote server into your local machine by switching source and destination specification: ``` scp user@remotehost:/home/file.txt /local/destination/ ``` More on the scp Command[How to Use the SCP Command in Linux to Securely Transfer Files](https://builtin.com/articles/scp-command) ## Master the cp Command Mastering the `cp` command is a crucial skill for any Linux user, providing the ability to efficiently manage and organize files and directories. From basic copying to more advanced operations with various options, the cp command is simple, yet powerful. Additionally, understanding related commands like `scp` further enhances your ability to securely transfer files across different machines. Short for “copy,” the `cp` command is used in Linux to duplicate files or entire directories from one location of the file system to another. You can use the `cp` command to copy a file in Linux. Its syntax is `cp source_file target_file`.
Shard169 (laksa)
Root Hash7607033694470393769
Unparsed URLcom,builtin!/articles/linux-cp-command s443