nerdexam
CompTIA

XK0-006 · Question #96

A systems administrator is working on configuration changes and needs to replace a hostname in a specific file. Which of the following commands should the administrator use to complete this task?

The correct answer is B. sed -i 's/oldhostname/newhostname/' /etc/configuration.file. This command performs an in-place substitution, replacing the specified hostname directly within the file, which is the correct and efficient method for modifying configuration values without creating intermediate files.

Automation and Scripting

Question

A systems administrator is working on configuration changes and needs to replace a hostname in a specific file. Which of the following commands should the administrator use to complete this task?

Options

  • Acut. -d oldhostname /etc/configuration.file | vi newhost.name
  • Bsed -i 's/oldhostname/newhostname/' /etc/configuration.file
  • Ccat /etc/configuration.file | grep oldhostname > newhost.name
  • Dgrep oldhostname /etc/configuration.file | awk '{print $1 newhostname}'

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    90% (28)
  • D
    6% (2)

Explanation

This command performs an in-place substitution, replacing the specified hostname directly within the file, which is the correct and efficient method for modifying configuration values without creating intermediate files.

Topics

#sed#text substitution#in-place editing#configuration files

Community Discussion

No community discussion yet for this question.

Full XK0-006 Practice