During a cleanup task, an administrator inspects /srv/backups and finds a directory named data_backup that holds dozens of compressed dump files and nested monthly snapshot folders. The directory has been confirmed obsolete and must be removed in a single command, without any interactive prompts, even if some files are write-protected. Which command should the administrator run to accomplish this?
The correct command is rm -rf data_backup. The -r (or --recursive) flag tells rm to descend into the directory and delete everything it contains, while the -f (or --force) flag suppresses all confirmation prompts and ignores non-existent files. Together they remove the directory hierarchy in one non-interactive step. Using rm data_backup fails because rm will not delete directories without -r. rmdir data_backup only works on empty directories. rm -i data_backup enables interactive prompts, defeating the requirement to run unattended.
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 does the `-r` option in the `rm` command do?
Open an interactive chat with Bash
Why is the `-f` option in `rm -rf` considered potentially dangerous?
Open an interactive chat with Bash
How does `rmdir` differ from `rm -r` when removing directories?