LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   why do I see this? (https://www.linuxquestions.org/questions/linux-newbie-8/why-do-i-see-this-4175442363/)

yaximik 12-20-2012 04:24 PM

why do I see this?
 
Hi,

Out of nowhere, but now every time I log-in as root I get this output to stdout:

Code:

[yaximik@G5NNJN1 ~]$ su -
Password:
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
+ '[' -f /root/.bashrc ']'
+ . /root/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
++ alias 'rm=rm -i'
alias cp='cp -i'
++ alias 'cp=cp -i'
alias mv='mv -i'
++ alias 'mv=mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
++ '[' -f /etc/bashrc ']'
++ . /etc/bashrc
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# are we an interactive shell?
if [ "$PS1" ]; then
  if [ -z "$PROMPT_COMMAND" ]; then
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
  fi
  # Turn on checkwinsize
  shopt -s checkwinsize
  [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi
+++ '[' '\s-\v\$ ' ']'
+++ '[' -z '' ']'
+++ case $TERM in
+++ '[' -e /etc/sysconfig/bash-prompt-xterm ']'
+++ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
+++ shopt -s checkwinsize
+++ '[' '\s-\v\$ ' = '\s-\v\$ ' ']'
+++ PS1='[\u@\h \W]\$ '

if ! shopt -q login_shell ; then # We're not a login shell
        # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
                if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
                        if [ "$2" = "after" ] ; then
                                PATH=$PATH:$1
                        else
                                PATH=$1:$PATH
                        fi
                fi
        }

    # By default, we want umask to get set. This sets it for non-login shell.
    # You could check uidgid reservation validity in
    # /usr/share/doc/setup-*/uidgid file
    if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
      umask 002
    else
      umask 022
    fi

        # Only display echos from profile.d scripts if we are no login shell
    # and interactive - otherwise just process them to set envvars
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . $i
            else
                . $i >/dev/null 2>&1
            fi
        fi
    done

        unset i
        unset pathmunge
fi
+++ shopt -q login_shell
# vim:ts=4:sw=4

# User specific environment and startup programs

export PATH=$PATH:$HOME/bin:/opt/454/bin
+ export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/454/bin
+ PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/454/bin

export PATH
+ export PATH
unset USERNAME
+ unset USERNAME
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
++ printf '\033]0;%s@%s:%s\007' root G5NNJN1 '~'
[root@G5NNJN1 ~]#

Also, every command outputs something like:

Code:

[root@G5NNJN1 ~]# ls
ls
+ ls --color=tty
6                firstboot.1281463738.13  NVIDIA-Linux-x86_64-295.59.run
anaconda-ks.cfg  install.log
Desktop          install.log.syslog
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
++ printf '\033]0;%s@%s:%s\007' root G5NNJN1 '~'
[root@G5NNJN1 ~]#

it does not happen in user mode or after just "su", only after "su -" or login into root account. I realize that something has happened to root configuration files, but cannot quite find which one is affected as .bashrc and .bash_profile look normal.

Kustom42 12-20-2012 04:31 PM

I'm thinking its your default shell for root? What shell does root have set on the /etc/passwd file? The "-" part of su - means to take on the settings of the users profile as if you logged in to that account directly, so it sources the .bashrc .bash_profile and so on, without the - it retains the current users shell, variables, etc..

Kustom42 12-20-2012 04:34 PM

After looking at the output more it looks like root might, for some reason, have /bin/bash set in debug mode. This is usually done with the -x option to debug shell scripts. Try the following as the root user:

Code:


set +x



---------- Post added 12-20-12 at 03:34 PM ----------

http://tldp.org/LDP/Bash-Beginners-G...ect_02_03.html

rknichols 12-20-2012 05:08 PM

Looks more like "-v" than "-x" ("-x" would not have printed comment lines), and "set +v" would clear it up. But, you will still need to track down where that "-v" option is getting set in the first place.

Kustom42 12-20-2012 05:41 PM

Good catch on the comments, I never use debug or verbose with Bash. The +v is the correct answer it looks like.

shivaa 12-20-2012 09:39 PM

It's clearly because somewhere shell debug command i.e. set is set in root's shell initialization file. In order to avoid this, simply comment (put a # against the entry) the line containing set -vx (or either option associated with set) from corresponding file, as:
Code:

grep 'set' .bashrc .profile .login
Then exit from the shell and login again.

yaximik 12-30-2012 09:07 AM

[SOLVED] Why do I see this?
 
:) Thanks everyone who responded. Indeed, it was as simple as commenting out 'set -xv' in root's .bash_profile. I guess the issue was I do not remember setting this to on, otherwise I would know how to set it back to off. It got to be a goblin in my box, I hope it will not do something more malicious next time.


All times are GMT -5. The time now is 09:52 PM.