set -x
Last updated
What is set -x?
set -x is a debugging tool used in shell scripts to trace the execution of commands. When enabled, the shell will print each command to standard error (stderr) before it is executed, preceded by a + symbol. This allows you to see exactly what commands are being run and in what order, making it easier to identify errors or unexpected behavior in your scripts.
Free resources to learn set -x
- ArticleMastering Selective Debugging in Bash/Shell Scripts with set -x and set +x
- ArticleDifference between bash -x and set -x
- ArticleUsing set -x and set -e in Shell Scripting: A Guide for Enhanced Debugging and Error Handling
- VideoHow to Debug Bash - Using bash -x or set -x in bash - You Suck at Programming #044
More in stage 26: Debugging
set -x: common questions
Can I learn set -x in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain set -x in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this set -x tutorial for beginners?
It is lesson 120 of 166 in the free Shell / Bash roadmap, in stage 26, Debugging. If you are new to Shell / Bash, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.