2

When I use su - fred the job is immediately moved to the background. Then, if I use fg it works normally:

wally@Machine:~$ su - fred
Password:

[1]+  Stopped                 su - fred
wally@Machine:~$ fg
su - fred
fred@Machine:~$

Why did it start in the background?


Output of type -a su (run as wally):

su is /usr/bin/su
su is /bin/su

Output of jobs -l (run as wally):

[1]+  9187 Stopped (signal)        su - fred

fred's startup file (.profile and .bashrc were deleted):

.bash_profile

exec env /bin/bash

I found a related question here.

wally
  • 175

1 Answers1

2

That happens because bash runs the startup files with job control disabled.

Add set -m at the beginning of your ~/.bash_profile.

See also this answer.

  • This worked. I wonder why it has worked in the past without this? I'm using Ubuntu, perhaps something was changed? Thanks for the answer. :) – wally Jan 15 '20 at 20:20
  • Afair, it has always been that way. I'll add more info to the answer when I get access to the source. –  Jan 15 '20 at 20:31