CompTIA Linux+ XK0-006 (V8) Practice Question

After adding the line below to her ~/.bashrc and opening a new terminal session,

alias backup='tar -czf $1.tgz $1'

a junior administrator tries to run the command

backup project

but receives the error message:

tar: .tgz: Cannot stat: No such file or directory

Which action will correctly create a reusable shortcut that accepts the directory name as an argument?

  • Replace the alias with a shell function, for example:

    backup() { tar -czf "$1.tgz" "$1"; }
    
  • Move the alias definition to /etc/profile so it is processed earlier during shell start-up.

  • Use an imaginary -E option with alias to enable parameter expansion:

    alias -E backup='tar -czf $1.tgz $1'
    
  • Escape the positional parameters in the alias definition:

    alias backup='tar -czf \$1.tgz \$1'
    
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot