In AlmaLinux (like other RHEL-based distributions), the cp
command is typically aliased to run in interactive mode by default, which means it prompts before overwriting files. This guide shows how to bypass the confirmation and force overwrites.
๐ Check if cp
is Aliased (Common on AlmaLinux)
Run this command:
alias
You will likely see:
alias cp='cp -i'
This means every time you run cp
, it runs as cp -i
(interactive), asking for confirmation before overwriting.
โ Incorrect Method: Using yes
Pipe
Trying:
yes | cp -r bin/ test/
Does not bypass the alias or confirmation.
โ Recommended Options
Option 1: Use a Backslash (\
) to Bypass the Alias
\cp -r bin/ test/
The backslash tells the shell to use the actual binary (/bin/cp
) instead of the aliased version.
Option 2: Temporarily Unalias cp
for the Session
unalias cp
cp -r bin/ test/
This disables the cp -i
alias only for your current session or script.
๐งน Optional: Remove the Alias Permanently
If you prefer not to have cp
aliased at all, you can remove or comment it from your shell config:
Edit your shell profile (for example, if you’re using bash
):
nano ~/.bashrc
Look for a line like:
alias cp='cp -i'
And comment it out:
# alias cp='cp -i'
Then reload your shell:
source ~/.bashrc
๐งพ Summary Table (AlmaLinux)
Action | Command |
---|---|
Check alias | alias |
Force overwrite with backslash | \cp -r source/ dest/ |
Unalias temporarily | unalias cp |
Remove alias permanently | Edit ~/.bashrc and remove alias |
Help | man cp |