nerdexam
Linux_Foundation

LFCS · Question #828

In Bash, inserting 1>&2 after a command redirects

The correct answer is C. standard output to standard error. In Bash, the redirection 1>&2 directs standard output (file descriptor 1) to the same destination as standard error (file descriptor 2).

Submitted by carlos_mx· Apr 18, 2026Essential Commands

Question

In Bash, inserting 1>&2 after a command redirects

Options

  • Astandard error to standard input.
  • Bstandard input to standard error.
  • Cstandard output to standard error.
  • Dstandard error to standard output.
  • Estandard output to standard input.

How the community answered

(55 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    89% (49)
  • D
    7% (4)

Why each option

In Bash, the redirection `1>&2` directs standard output (file descriptor 1) to the same destination as standard error (file descriptor 2).

Astandard error to standard input.

`1>&2` redirects standard output to standard error, not standard error to standard input.

Bstandard input to standard error.

`1>&2` redirects standard output to standard error, not standard input to standard error.

Cstandard output to standard error.Correct

The `1>&2` redirection explicitly redirects file descriptor 1 (standard output) to file descriptor 2 (standard error). This means any output that would normally go to standard output will instead be sent to standard error, often used for logging both regular and error messages to the same error stream.

Dstandard error to standard output.

To redirect standard error to standard output, the syntax would be `2>&1`.

Estandard output to standard input.

To redirect standard output to standard input is generally not a direct or useful operation in this context; `1>&0` would be the syntax if that were possible, but standard input is for reading, not writing.

Concept tested: Bash standard I/O redirection

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Redirections

Topics

#Bash#Redirection#File Descriptors#Command Line

Community Discussion

No community discussion yet for this question.

Full LFCS Practice