During a deployment, a Jenkins pipeline opens an interactive Bash shell on a RHEL server whose /etc/bashrc sets several safety aliases such as cp='cp -i' and rm='rm -i'. These prompts break the pipeline. You cannot edit any profile files, but you can add one line at the very beginning of the script before any commands run. Which built-in Bash command will immediately disable all aliases for the remainder of the script without relying on external utilities?
The unalias builtin removes alias definitions that exist in the current shell. Supplying the -a option erases every alias, so subsequent commands in the script execute with their standard, un-aliased behavior.
alias -p only lists the current aliases and does not disable them.
shopt -u expand_aliases turns off alias expansion, but the aliases themselves remain defined and the option is already unset by default in non-interactive scripts.
hash -r clears Bash's command-lookup hash table and has no effect on aliases.
Therefore the single command that guarantees no alias will interfere with the script is unalias -a.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the `unalias` command in Bash?
Open an interactive chat with Bash
Why is `unalias -a` better than `shopt -u expand_aliases` for this scenario?
Open an interactive chat with Bash
How do aliases typically get set in Bash environments?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access