🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 143 (from laksa186)

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
2 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 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://runcloud.io/blog/copy-files-in-linux
Last Crawled2026-04-08 10:14:19 (2 days ago)
First Indexed2024-01-31 05:43:17 (2 years ago)
HTTP Status Code200
Meta TitleHow to Copy Files in Linux and Overwrite without Confirmation
Meta DescriptionAre you working on a bash script that needs to be executed without any human inputs? Do your scripts fail when the process of copying files encounters a
Meta Canonicalnull
Boilerpipe Text
Are you working on a bash script that needs to be executed without any human inputs? Do your scripts fail when the process of copying files encounters a problem? Table of Contents How to Copy Files in Linux CLI How to Overwrite Existing Files Changing the Default Behavior Checking For An Existing Alias Removing An Alias Temporarily Bypass An Alias Automatically Accepting All Prompts Wrapping Up If you answered “yes” to either of these questions then you’re in the right place. In this post, we will take a quick look at the cp command in Linux, and examine how it can be used in different scenarios. How to Copy Files in Linux CLI Copying files is one of the simplest actions that you can perform on a computer. To copy files via the command line you can use the cp command, which stands for ‘copy’. The general syntax for the cp command is: cp [ OPTIONS ] SOURCE ( s ) . . . DESTINATION The SOURCE(s) can be one or more files or directories , and the DESTINATION can be a single file or directory. If you’ve passed more than two parameters to the command, then the last one is always considered the destination, and all other parameters before it are considered the source(s). If the DESTINATION is a directory, the SOURCE files or directories are copied into it. If the DESTINATION is a file, the SOURCE file is copied and renamed as the DESTINATION file. Here is a simple example of how to copy a file named file.txt from the current directory to another directory named backup: cp file . txt backup / This will copy the file file.txt to the backup directory with the same name. If you want to copy the file with a different name, you can specify the new name after the backup directory: cp file . txt backup / new_file . txt This will copy the file file.txt to the backup directory as new_file.txt . How to Overwrite Existing Files By default, cp will overwrite any existing files in the destination without asking for confirmation. However, this behavior can be changed by using different flags or options with the cp command. Here are some of the common flags that can affect how cp handles overwriting: -f or --force : This option will force cp to overwrite any existing files in the destination, even if they cannot be opened or removed. This option will also ignore any -n option that is used before it. For example, cp -f source.txt destination.txt will overwrite destination.txt with source.txt , regardless of any permissions or errors. -i or --interactive : This option will make cp prompt the user before overwriting any existing files in the destination. You can choose to overwrite or skip the file by typing y or n and then pressing Enter. If you’re copying multiple files at once, you will be prompted for each file separately. If you don’t type anything and press Enter then the file will not be overwritten. This option will also override any -n option that is used before it. For example, cp -i source.txt destination.txt will ask the user if they want to overwrite destination.txt with source.txt , and proceed accordingly. -n or --no-clobber : This option will prevent cp from overwriting any existing files in the destination. If the destination file already exists, cp will skip it and move on to the next file. This option will also override any -i option that is used before it. For example, cp -n source.txt destination.txt will not overwrite destination.txt with source.txt , if destination.txt already exists. -u or --update : This option will make cp copy only when the source file is newer than the destination file, or when the destination file does not exist. This can be useful for updating or synchronizing files between different locations. For example, cp -u source.txt destination.txt will overwrite destination.txt with source.txt , only if source.txt is newer or destination.txt does not exist. Note that these flags can be combined to achieve different effects. For example, cp -uf source.txt destination.txt will force cp to overwrite destination.txt with source.txt , only if source.txt is newer or destination.txt does not exist. Changing the Default Behavior On some computers, the default behavior of the cp command can be affected by an alias . An alias is a way of creating a shortcut or a new name for a command, with some predefined options. For example, some Linux distributions come with the following alias pre-defined in their code: alias cp = 'cp -i' This means that whenever the user types cp , the shell will actually run cp -i , which will prompt the user before overwriting any files. Checking For An Existing Alias If you’re not sure whether your computer has a predefined alias, then you can run the following command to list all aliases, and then look to see whether the cp is present in the output: alias Removing An Alias To remove the alias for cp , you can run the command unalias cp , which will restore the default behavior of cp . In the above example, we can see that an alias was defined for the cp command. After executing the unalias command, the alias entry was removed from the list. Temporarily Bypass An Alias If you don’t want to permanently remove the alias, you have an option to use a backslash before the cp command to bypass the alias and run the original command. For example, \cp source.txt destination.txt will overwrite destination.txt with source.txt , without prompting the user. In the above example, we can see that the user was prompted for input when executing the copy operation, but not when the command was prefixed with the \ character. Automatically Accepting All Prompts In Linux there are multiple ways to do the same thing using different methods. If you don’t want to use the in-built -f option to overwrite files then you can use the copy command in conjunction with the yes command to automatically respond with y to all prompts. yes | cp - v source destination In the above example, we can see that the copy command prompted us for input before replacing each file, but the yes command responded ‘yes’ to each and every single one of them nearly instantaneously. Wrapping Up In this article, we have discussed how to copy files and directories in Linux via the command line. We have also explained different options and features of the copy command that are helpful in day-to-day usage. If you’re learning Linux to better manage your servers, we wish you all the best! However, you don’t need to be a Linux expert to host websites on the internet. RunCloud makes it extremely easy to deploy and manage websites using a user-friendly dashboard, and provides complete freedom to tinker under the hood. Whether you’re a beginner or a seasoned professional with decades of experience, sooner or later everyone makes a configuration change that completely renders websites useless. RunCloud has idiot-proofed many complex operations such as updating server configurations, installing SSL certificates, deleting applications, etc. – all of which makes it difficult for novice users to crash their website, and provides an extra set of guide-rails to advanced users. RunCloud is a versatile and reliable tool that can help you manage your server on your own, without the hassle and cost of hiring a system administrator. Don’t miss this opportunity to take your server management to the next level. Sign up for RunCloud today and enjoy the benefits of a cloud-based server management platform that is fast, secure, and easy to use.
Markdown
[Blog](https://runcloud.io/blog) Search... `Ctrl` `+` #### Start typing to begin search Enter a search term to find results in the blog. - [Products]() #### Modern server management panel The enterprise-grade platform for server management. [Server Management](https://runcloud.io/server-management) [Backup](https://runcloud.io/backup) [Atomic Deployment](https://runcloud.io/atomic-deployment) [Team](https://runcloud.io/team) [Arch](https://runcloud.io/arch) [RunCache](https://runcloud.io/runcache) [Migration](https://runcloud.io/migration) - [Resources]() #### Resources Get help and learn more about our products offering. [Blog](https://runcloud.io/blog) [Documentation](https://runcloud.io/docs) [API & Developers](https://runcloud.io/docs/api) [Changelog](https://runcloud.io/changelog) [Community](https://community.runcloud.io/) [Status Page](https://status.runcloud.io/) - [Pricing](https://runcloud.io/pricing) - [Company]() #### Company Get help and learn more about our products offering. [About Us](https://runcloud.io/company) [Ambassadors](https://runcloud.io/company/ambassador) [Career](https://runcloud.io/careers) [Legal](https://runcloud.io/legal/tos) [Newsroom](https://runcloud.io/company/newsroom) [Bug Bounty Programme](https://runcloud.io/bug-bounty-programme) [Trust & Security](https://runcloud.io/security) [Education](https://runcloud.io/education) [Contact Us](mailto:hello@runcloud.io?subject=[Hello]) - [Login](https://manage.runcloud.io/auth/login?utm_source=runcloudwebsite&utm_medium=blog&utm_campaign=blog-header) - [Get Started](https://manage.runcloud.io/auth/onboard?utm_source=runcloudwebsite&utm_medium=blog&utm_campaign=blog-header) - [All Posts](https://runcloud.io/blog) - [News](https://runcloud.io/blog/category/new) - [Server Management](https://runcloud.io/blog/category/server-management) - [WordPress](https://runcloud.io/blog/category/wordpress) - [Security](https://runcloud.io/blog/category/security) - [Laravel](https://runcloud.io/blog/category/laravel) - [Cloud Education](https://runcloud.io/blog/category/tutorial) - [Server Management](https://runcloud.io/blog/category/server-management) - • - [Tips & Tricks](https://runcloud.io/blog/category/tips-tricks) # How to Copy Files in Linux and Overwrite without Confirmation ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team - Last Updated Feb 29, 2024 - • - Reading Time 5 min read Are you working on a bash script that needs to be executed without any human inputs? Do your scripts fail when the process of copying files encounters a problem? Table of Contents - [How to Copy Files in Linux CLI](https://runcloud.io/blog/copy-files-in-linux#how-to-copy-files-in-linux-cli) - [How to Overwrite Existing Files](https://runcloud.io/blog/copy-files-in-linux#how-to-overwrite-existing-files) - [Changing the Default Behavior](https://runcloud.io/blog/copy-files-in-linux#changing-the-default-behavior) - [Checking For An Existing Alias](https://runcloud.io/blog/copy-files-in-linux#checking-for-an-existing-alias) - [Removing An Alias](https://runcloud.io/blog/copy-files-in-linux#removing-an-alias) - [Temporarily Bypass An Alias](https://runcloud.io/blog/copy-files-in-linux#temporarily-bypass-an-alias) - [Automatically Accepting All Prompts](https://runcloud.io/blog/copy-files-in-linux#automatically-accepting-all-prompts) - [Wrapping Up](https://runcloud.io/blog/copy-files-in-linux#wrapping-up) If you answered “yes” to either of these questions then you’re in the right place. In this post, we will take a quick look at the cp command in Linux, and examine how it can be used in different scenarios. ## **How to Copy Files in Linux CLI** Copying files is one of the simplest actions that you can perform on a computer. To copy files via the command line you can use the cp command, which stands for ‘copy’. The general syntax for the cp command is: ``` cp [OPTIONS] SOURCE(s)... DESTINATIONCopy ``` The `SOURCE(s)` can be **one or more files or directories**, and the `DESTINATION` can be a single file or directory. If you’ve passed more than two parameters to the command, then the last one is always considered the destination, and all other parameters before it are considered the source(s). - If the `DESTINATION` is a directory, the `SOURCE` **files or directories** are copied into it. - If the `DESTINATION` is a file, the `SOURCE` **file** is copied and renamed as the `DESTINATION` file. Here is a simple example of how to copy a file named `file.txt` from the current directory to another directory named backup: ``` cp file.txt backup/Copy ``` This will copy the file `file.txt` to the `backup` directory with the same name. If you want to copy the file with a different name, you can specify the new name after the backup directory: ``` cp file.txt backup/new_file.txtCopy ``` This will copy the file `file.txt` to the backup directory as `new_file.txt`. ## **How to Overwrite Existing Files** By default, `cp` will overwrite any existing files in the destination without asking for confirmation. However, this behavior can be changed by using different flags or options with the `cp` command. Here are some of the common flags that can affect how `cp` handles overwriting: - **`-f` or `--force`**: This option will force cp to **overwrite any existing files** in the destination, even if they cannot be opened or removed. This option will also ignore any `-n` option that is used before it. For example, `cp -f source.txt destination.txt` will overwrite *destination.txt* with *source.txt*, regardless of any permissions or errors. - **`-i` or `--interactive`**: This option will make cp **prompt the user** before overwriting any existing files in the destination. You can choose to overwrite or skip the file by typing `y` or `n` and then pressing Enter. If you’re copying multiple files at once, you will be prompted for each file separately. If you don’t type anything and press Enter then the file will not be overwritten. This option will also override any `-n` option that is used before it. For example, `cp -i source.txt destination.txt` will ask the user if they want to overwrite *destination.txt* with *source.txt*, and proceed accordingly. - **`-n` or `--no-clobber`**: This option will **prevent cp from overwriting** any existing files in the destination. If the destination file already exists, cp will skip it and move on to the next file. This option will also override any `-i` option that is used before it. For example, `cp -n source.txt destination.txt` will **not** overwrite *destination.txt* with *source.txt*, if *destination.txt* already exists. - **`-u` or `--update`**: This option will make cp **copy only when the source file is newer** than the destination file, or when the destination file does not exist. This can be useful for updating or synchronizing files between different locations. For example, `cp -u source.txt destination.txt` will overwrite *destination.txt* with *source.txt*, only if *source.txt* is newer or *destination.txt* does not exist. Note that these flags can be combined to achieve different effects. For example, `cp -uf source.txt destination.txt` will force cp to overwrite *destination.txt* with *source.txt*, only if *source.txt* is newer or *destination.txt* does not exist. ## **Changing the Default Behavior** On some computers, the default behavior of the cp command can be affected by an **alias**. An alias is a way of creating a shortcut or a new name for a command, with some predefined options. For example, some Linux distributions come with the following alias pre-defined in their code: ``` alias cp='cp -i'Copy ``` This means that whenever the user types `cp`, the shell will actually run `cp -i`, which will prompt the user before overwriting any files. ### **Checking For An Existing Alias** If you’re not sure whether your computer has a predefined alias, then you can run the following command to list all aliases, and then look to see whether the cp is present in the output: ``` aliasCopy ``` ![](https://blog.runcloud.io/wp-content/uploads/2024/01/image1-1024x544.png) ### **Removing An Alias** To remove the alias for `cp`, you can run the command `unalias cp`, which will restore the default behavior of `cp`. ![Removing alias of copy command](https://blog.runcloud.io/wp-content/uploads/2024/01/image3-1024x544.png) In the above example, we can see that an alias was defined for the `cp` command. After executing the `unalias` command, the alias entry was removed from the list. ### **Temporarily Bypass An Alias** If you don’t want to permanently remove the alias, you have an option to use a backslash before the cp command to bypass the alias and run the original command. For example, `\cp source.txt destination.txt` will overwrite *destination.txt* with *source.txt*, without prompting the user. ![bypassing alias of copy commands](https://blog.runcloud.io/wp-content/uploads/2024/01/image2-1024x544.png) In the above example, we can see that the user was prompted for input when executing the copy operation, but not when the command was prefixed with the \\ character. ### **Automatically Accepting All Prompts** In Linux there are multiple ways to do the same thing using different methods. If you don’t want to use the in-built `-f` option to overwrite files then you can use the **copy** command in conjunction with the **yes** command to automatically respond with y to all prompts. ``` yes | cp -v source destinationCopy ``` ![](https://blog.runcloud.io/wp-content/uploads/2024/01/image4-1024x544.png) In the above example, we can see that the copy command prompted us for input before replacing each file, but the yes command responded ‘yes’ to each and every single one of them nearly instantaneously. ## **Wrapping Up** In this article, we have discussed how to copy files and directories in Linux via the command line. We have also explained different options and features of the copy command that are helpful in day-to-day usage. If you’re learning Linux to better manage your servers, we wish you all the best! However, you don’t need to be a Linux expert to host websites on the internet. RunCloud makes it extremely easy to deploy and manage websites **using a user-friendly dashboard,** and provides **complete freedom** to tinker under the hood. Whether you’re a beginner or a seasoned professional with decades of experience, sooner or later everyone makes a configuration change that completely renders websites useless. RunCloud has **idiot-proofed many complex operations** such as updating server configurations, installing SSL certificates, deleting applications, etc. – all of which makes it difficult for novice users to crash their website, and provides an extra set of guide-rails to advanced users. RunCloud is a versatile and reliable tool that can help you manage your server on your own, without the hassle and cost of hiring a system administrator. Don’t miss this opportunity to take your server management to the next level. [Sign up for RunCloud today](https://manage.runcloud.io/auth/onboard) and enjoy the benefits of a cloud-based server management platform that is fast, secure, and easy to use. ## About the author(s) ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud TeamAuthor ### Deploy & manage production-grade cloud infrastructure. Trusted by brands from startup to enterprise. With everything from backups, staging, cloning, atomic deployments, and more – RunCloud makes it easy to manage your own production-grade infrastructure. [Get Started Now](https://manage.runcloud.io/auth/onboard?utm_source=runcloudwebsite&utm_medium=blog&utm_campaign=blog-sidebar) Posts you may like [![23 Best Chrome Extensions To Protect Your Privacy](https://blog.runcloud.io/wp-content/uploads/2022/01/Chrome-Extensions-To-Protect-Your-Privacy-featured-image.png)Security ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team Jan 25, 2022 14 min read 23 Best Chrome Extensions To Protect Your PrivacyAre you looking for extensions to enhance your security and privacy? Although Incognito Mode aims at making your browsing experience secure, sometimes it just isn’t enough. Chrome may be the world’s most popular web browser, but it isn’t the most private one. It does, however, provide a number of Chrome extensions that you can freely …](https://runcloud.io/blog/best-chrome-privacy-extensions) [![How to Fix the “ERR\_NAME\_NOT\_RESOLVED” Error](https://blog.runcloud.io/wp-content/uploads/2025/09/blog-10.png)Server Management ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team Oct 12, 2025 • 12 min read How to Fix the “ERR\_NAME\_NOT\_RESOLVED” ErrorThe ERR\_NAME\_NOT\_RESOLVED is a frustrating error message that prevents you from browsing the web. The good news is that this error is almost always fixable, and you don’t need to be a tech expert to do it. This post will show you exactly how to fix the ERR\_NAME\_NOT\_RESOLVED error. We will walk you through a …](https://runcloud.io/blog/fix-err_name_not_resolved-error) [![Cheat Sheet To All Bash Shortcuts You Should Know](https://blog.runcloud.io/wp-content/uploads/2022/08/bash-shortcuts-featured-image.png)Server Management ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team Aug 23, 2022 • 2 min read Cheat Sheet To All Bash Shortcuts You Should KnowThe Linux Bash is commonly used by developers, though it may seem fairly difficult to navigate at first. The use of arrow keys to navigate between commands is obviously a hassle and often becomes a major challenge. However, in general, Bash is quite easy to use. If you’re going to use it on a VPS, …](https://runcloud.io/blog/bash-shortcuts-cheat-sheet) [![How to Check Running Processes in Linux Using ps, top, htop, and atop Commands](https://blog.runcloud.io/wp-content/uploads/2024/09/Running-Processes-header.png)Server Management ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team Sep 19, 2024 • 6 min read How to Check Running Processes in Linux Using ps, top, htop, and atop CommandsIf you’re involved with managing servers, then you’ll already be aware of how little servers offer as far as user interfaces are concerned. Most of the work necessitates the use of the command line interface. When monitoring servers, you often need to track multiple things simultaneously, such as disk usage, network, CPU temperatures, etc. While …](https://runcloud.io/blog/running-processes-in-linux) [![Fix “This Site Can’t Be Reached” Error (5+ Reliable Solutions That Actually Work)](https://blog.runcloud.io/wp-content/uploads/2026/01/Blog-04-03.jpg)Server Management ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team Jan 23, 2026 • 7 min read Fix “This Site Can’t Be Reached” Error (5+ Reliable Solutions That Actually Work)Are you seeing the “This site can’t be reached” error on your site? This error is frustrating and can have multiple underlying causes, which makes troubleshooting harder. In this guide, we break those causes down and show you how to fix them. By the end of this guide, you’ll know how to flush DNS cache, …](https://runcloud.io/blog/fix-this-site-cant-be-reached-error) [![How To Host Matomo Analytics On A RunCloud Server](https://blog.runcloud.io/wp-content/uploads/2024/03/matomo-Header.png)Server Management ![RunCloud Team](https://blog.runcloud.io/wp-content/uploads/2025/11/runcloud-square.png) RunCloud Team Mar 08, 2024 • 5 min read How To Host Matomo Analytics On A RunCloud ServerIf you answered ‘Yes!’ to either of these questions, then you’re in the right place. Matomo is a free and open source web analytics platform that gives you insights into your website’s visitors, behavior, and conversions. In this post, we will show you how to host Matomo analytics on a RunCloud server and enjoy the …](https://runcloud.io/blog/host-matomo-analytics) ## Comments ### Add to discussion Your email address will not be published © 2026 RunCloud Sdn Bhd - [Terms of Service](https://runcloud.io/legal/tos) - [Privacy Policy](https://runcloud.io/legal/privacy-policy) - [Cookie Policy](https://runcloud.io/legal/cookie-policy)
Readable Markdown
Are you working on a bash script that needs to be executed without any human inputs? Do your scripts fail when the process of copying files encounters a problem? Table of Contents - [How to Copy Files in Linux CLI](https://runcloud.io/blog/copy-files-in-linux#how-to-copy-files-in-linux-cli) - [How to Overwrite Existing Files](https://runcloud.io/blog/copy-files-in-linux#how-to-overwrite-existing-files) - [Changing the Default Behavior](https://runcloud.io/blog/copy-files-in-linux#changing-the-default-behavior) - [Checking For An Existing Alias](https://runcloud.io/blog/copy-files-in-linux#checking-for-an-existing-alias) - [Removing An Alias](https://runcloud.io/blog/copy-files-in-linux#removing-an-alias) - [Temporarily Bypass An Alias](https://runcloud.io/blog/copy-files-in-linux#temporarily-bypass-an-alias) - [Automatically Accepting All Prompts](https://runcloud.io/blog/copy-files-in-linux#automatically-accepting-all-prompts) - [Wrapping Up](https://runcloud.io/blog/copy-files-in-linux#wrapping-up) If you answered “yes” to either of these questions then you’re in the right place. In this post, we will take a quick look at the cp command in Linux, and examine how it can be used in different scenarios. ## **How to Copy Files in Linux CLI** Copying files is one of the simplest actions that you can perform on a computer. To copy files via the command line you can use the cp command, which stands for ‘copy’. The general syntax for the cp command is: ``` cp [OPTIONS] SOURCE(s)... DESTINATION ``` The `SOURCE(s)` can be **one or more files or directories**, and the `DESTINATION` can be a single file or directory. If you’ve passed more than two parameters to the command, then the last one is always considered the destination, and all other parameters before it are considered the source(s). - If the `DESTINATION` is a directory, the `SOURCE` **files or directories** are copied into it. - If the `DESTINATION` is a file, the `SOURCE` **file** is copied and renamed as the `DESTINATION` file. Here is a simple example of how to copy a file named `file.txt` from the current directory to another directory named backup: ``` cp file.txt backup/ ``` This will copy the file `file.txt` to the `backup` directory with the same name. If you want to copy the file with a different name, you can specify the new name after the backup directory: ``` cp file.txt backup/new_file.txt ``` This will copy the file `file.txt` to the backup directory as `new_file.txt`. ## **How to Overwrite Existing Files** By default, `cp` will overwrite any existing files in the destination without asking for confirmation. However, this behavior can be changed by using different flags or options with the `cp` command. Here are some of the common flags that can affect how `cp` handles overwriting: - **`-f` or `--force`**: This option will force cp to **overwrite any existing files** in the destination, even if they cannot be opened or removed. This option will also ignore any `-n` option that is used before it. For example, `cp -f source.txt destination.txt` will overwrite *destination.txt* with *source.txt*, regardless of any permissions or errors. - **`-i` or `--interactive`**: This option will make cp **prompt the user** before overwriting any existing files in the destination. You can choose to overwrite or skip the file by typing `y` or `n` and then pressing Enter. If you’re copying multiple files at once, you will be prompted for each file separately. If you don’t type anything and press Enter then the file will not be overwritten. This option will also override any `-n` option that is used before it. For example, `cp -i source.txt destination.txt` will ask the user if they want to overwrite *destination.txt* with *source.txt*, and proceed accordingly. - **`-n` or `--no-clobber`**: This option will **prevent cp from overwriting** any existing files in the destination. If the destination file already exists, cp will skip it and move on to the next file. This option will also override any `-i` option that is used before it. For example, `cp -n source.txt destination.txt` will **not** overwrite *destination.txt* with *source.txt*, if *destination.txt* already exists. - **`-u` or `--update`**: This option will make cp **copy only when the source file is newer** than the destination file, or when the destination file does not exist. This can be useful for updating or synchronizing files between different locations. For example, `cp -u source.txt destination.txt` will overwrite *destination.txt* with *source.txt*, only if *source.txt* is newer or *destination.txt* does not exist. Note that these flags can be combined to achieve different effects. For example, `cp -uf source.txt destination.txt` will force cp to overwrite *destination.txt* with *source.txt*, only if *source.txt* is newer or *destination.txt* does not exist. ## **Changing the Default Behavior** On some computers, the default behavior of the cp command can be affected by an **alias**. An alias is a way of creating a shortcut or a new name for a command, with some predefined options. For example, some Linux distributions come with the following alias pre-defined in their code: ``` alias cp='cp -i' ``` This means that whenever the user types `cp`, the shell will actually run `cp -i`, which will prompt the user before overwriting any files. ### **Checking For An Existing Alias** If you’re not sure whether your computer has a predefined alias, then you can run the following command to list all aliases, and then look to see whether the cp is present in the output: ``` alias ``` ![](https://blog.runcloud.io/wp-content/uploads/2024/01/image1-1024x544.png) ### **Removing An Alias** To remove the alias for `cp`, you can run the command `unalias cp`, which will restore the default behavior of `cp`. ![Removing alias of copy command](https://blog.runcloud.io/wp-content/uploads/2024/01/image3-1024x544.png) In the above example, we can see that an alias was defined for the `cp` command. After executing the `unalias` command, the alias entry was removed from the list. ### **Temporarily Bypass An Alias** If you don’t want to permanently remove the alias, you have an option to use a backslash before the cp command to bypass the alias and run the original command. For example, `\cp source.txt destination.txt` will overwrite *destination.txt* with *source.txt*, without prompting the user. ![bypassing alias of copy commands](https://blog.runcloud.io/wp-content/uploads/2024/01/image2-1024x544.png) In the above example, we can see that the user was prompted for input when executing the copy operation, but not when the command was prefixed with the \\ character. ### **Automatically Accepting All Prompts** In Linux there are multiple ways to do the same thing using different methods. If you don’t want to use the in-built `-f` option to overwrite files then you can use the **copy** command in conjunction with the **yes** command to automatically respond with y to all prompts. ``` yes | cp -v source destination ``` ![](https://blog.runcloud.io/wp-content/uploads/2024/01/image4-1024x544.png) In the above example, we can see that the copy command prompted us for input before replacing each file, but the yes command responded ‘yes’ to each and every single one of them nearly instantaneously. ## **Wrapping Up** In this article, we have discussed how to copy files and directories in Linux via the command line. We have also explained different options and features of the copy command that are helpful in day-to-day usage. If you’re learning Linux to better manage your servers, we wish you all the best! However, you don’t need to be a Linux expert to host websites on the internet. RunCloud makes it extremely easy to deploy and manage websites **using a user-friendly dashboard,** and provides **complete freedom** to tinker under the hood. Whether you’re a beginner or a seasoned professional with decades of experience, sooner or later everyone makes a configuration change that completely renders websites useless. RunCloud has **idiot-proofed many complex operations** such as updating server configurations, installing SSL certificates, deleting applications, etc. – all of which makes it difficult for novice users to crash their website, and provides an extra set of guide-rails to advanced users. RunCloud is a versatile and reliable tool that can help you manage your server on your own, without the hassle and cost of hiring a system administrator. Don’t miss this opportunity to take your server management to the next level. [Sign up for RunCloud today](https://manage.runcloud.io/auth/onboard) and enjoy the benefits of a cloud-based server management platform that is fast, secure, and easy to use.
Shard143 (laksa)
Root Hash15992561546915991943
Unparsed URLio,runcloud!/blog/copy-files-in-linux s443