I'm using a Ubuntu Linux system, and every command I enter is displayed on the next line, followed by the output of the command. For example:

root@dpkube165:~# ls
ls  <--- why is this here?
Desktop  Documents  Downloads 

root@dpkube165:~# date
date  <--- or this?
Mon Mar 19 11:24:59 EDT 2018

root@dpkube165:~# echo "Hello, world!"
echo "Hello, world!" <--- or this?
Hello, world!

I thought it might have to do with the prompt, which is as follows (PS1):

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

but reviewing online guides to prompt escape sequences didn't turn up anything obvious.

  • 20
    You also appear to be logged in as root. Don't do that! – Toby Speight Mar 20 '18 at 13:42
  • 5
    Yes, I know to avoid root most of the time. This is on a VM in a throwaway testing environment where root is required. – Chad Mar 20 '18 at 19:16
  • 9
    @TobySpeight this is hackneyed, rote advice. – rackandboneman Mar 21 '18 at 11:17
  • 2
    @TobySpeight Seriously, don't push that as an absolute rule. Tell me, what's wrong with using sudo -i to run a series of root-level commands? Especially when I'm debugging something? – Duncan X Simpson Mar 21 '18 at 21:06
  • 2
    @TobySpeight if you don’t have time to explain, don’t give blanket “advice” which is often unhelpful. – Tim Mar 22 '18 at 9:11

It looks like you have -v set (something is running set -v).

To reverse this, run set +v.

set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]
set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
       Without  options, the name and value of each shell variable are displayed in a
       format that can be reused as input for setting or resetting the currently-set
       variables. Read-only variables cannot be reset. In posix mode, only shell
       variables are  listed. The output is sorted according to the current locale.
       When options are specified, they set or unset shell attributes. Any arguments
       remaining after option processing are treated as values for the positional
       parameters and are assigned, in order, to $1, $2, ...  $n.  Options, if
       specified, have the following meanings:


-v      Print shell input lines as they are read.

See the bash manpage (under the "Shell Builtin Commands" section) for more information on the set built-in command.

Alternatively run help set from within bash for more direct access to the help text.

  • 11
    Yep! As a slightly more convenient alternative to digging through man bash, you can also help set. – ravron Mar 19 '18 at 19:59
  • 5
    You legend... The time I've spent scrolling in the bash manpage... thanks! – Attie Mar 20 '18 at 10:11
  • 1
    My very first command after starting a bash that I don't own is always set -o vi. Mistype that as set -ovi and you'll get the above behaviour. – Guntram Blohm Mar 20 '18 at 22:45
  • as to the Why - I would suspect there's a script being sourced (i.e. ". ./srciptname" instead of just "./scriptname") which then exits before it unsets -v, i.e. at end it should "set +v" – jmullee Mar 21 '18 at 0:16
  • 2
    BTW, I find set -x more useful for logging, or debugging of things other than control-flow, because it expands variables to show what commands are actually being run, e.g. echo foo instead of echo $my_string – Peter Cordes Mar 21 '18 at 6:13

At least on Bash 4.3, this command has a similar effect to set -v:

trap 'echo "$BASH_COMMAND"' DEBUG

To check if this affects you, run

trap -p DEBUG

To unset it, run

trap - DEBUG

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.