nerdexam
Linux_Foundation

LFCS · Question #789

Bob accidentally created the subdirectory \bobsdir in his home directory. He tried to remove the subdirectory with the command rmdir \bobsfile only to receive the error: "No such file or directory."…

The correct answer is E. rmdir ~bob/\\bobsdir. To remove a directory named \bobsdir containing a literal backslash, the backslash must be escaped using another backslash in the rmdir command.

Submitted by rachelw· Apr 18, 2026Essential Commands

Question

Bob accidentally created the subdirectory \bobsdir in his home directory. He tried to remove the subdirectory with the command rmdir \bobsfile only to receive the error: "No such file or directory." Which of the following commands will remove the directory?

Options

  • Armdir '~bob/\bobsdir'
  • Brmdir "~bob/\bobsdir"
  • Crmdir ~bob/'bobsdir'
  • Drmdir ~bob/\bobsdir
  • Ermdir ~bob/\bobsdir

How the community answered

(21 responses)
  • A
    10% (2)
  • B
    5% (1)
  • D
    5% (1)
  • E
    81% (17)

Why each option

To remove a directory named `\bobsdir` containing a literal backslash, the backslash must be escaped using another backslash in the `rmdir` command.

Armdir '~bob/\bobsdir'

`rmdir '~bob/\bobsdir'` would prevent `~bob` from expanding to the home directory and might not correctly interpret the literal backslash within the path, depending on the exact shell behavior.

Brmdir "~bob/\bobsdir"

`rmdir "~bob/\bobsdir"` would expand `~bob`, but the single backslash `\` within double quotes would still be interpreted as an escape character, likely not preserving the literal backslash in the directory name.

Crmdir ~bob/'bobsdir'

`rmdir ~bob/'bobsdir'` would attempt to remove a directory literally named `bobsdir` (without the leading backslash), which is not the directory Bob created.

Drmdir ~bob/\bobsdir

`rmdir ~bob/\bobsdir` would interpret `\b` as an escape sequence for a backspace character or simply strip the backslash, searching for `obsdir` in Bob's home directory.

Ermdir ~bob/\\bobsdirCorrect

The `\` sequence in the shell represents a literal backslash. Therefore, `rmdir ~bob/\bobsdir` correctly targets the directory named `\bobsdir` within Bob's home directory.

Concept tested: Shell escaping special characters in paths

Source: https://man7.org/linux/man-pages/man1/bash.1.html

Topics

#Shell Escaping#Directory Management#rmdir command#File Paths

Community Discussion

No community discussion yet for this question.

Full LFCS Practice