LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   System message getting printed after every command execution (https://www.linuxquestions.org/questions/linux-server-73/system-message-getting-printed-after-every-command-execution-793712/)

mohit052 03-06-2010 10:33 PM

System message getting printed after every command execution
 
Hi,

I am getting this error message after every command i type in


#######################
$ls
file1 file2
-bash: /root/.o_cmd: Read-only file system
#######################


now i figure that there is some background process(lets say P) that is always running after each command i execute . the file in /root/.o_cmd is not set with executable permissions, hence i am getting prompted with that error.

Now i wanted to look up the options as what this process "P" is.
i would really appreciate if some one could throw in some suggestion like


smpp?
PAM ?

or any methods of finding out the "P" process..

thanks to all off you ... :-)

catkin 03-06-2010 10:44 PM

The same message for ANY command?

Does the command work and then you get that message?

What is the value of $PS1?

What is the 7th field of the affected user(s) /etc/passwd line?

Does this affect all users?

If only one user, have you tried renaming the shell initialisation files for this user in the user's home directory?

mohit052 03-06-2010 10:58 PM

Q.The same message for ANY command?
The same message for any command

Q.Does the command work and then you get that message?
the commands work without any problem

Q.What is the value of $PS1?
#echo $PS1
[\u@\h \W]\$
-bash: /root/.o_cmd: Read-only file system

by the way what is $PS1


Q.What is the 7th field of the affected user(s) /etc/passwd line?
The seventh field in the passwd file is /bin/bash
"root:x:0:0:root:/root:/bin/bash"


Q.Does this affect all users?
No, only the root user

Q.If only one user, have you tried renaming the shell initialisation files for this user in the user's home directory?
The only shell intialization file there is .bashrc and that thing is the default .bashrc that every other user has.


Thanks for the reply

catkin 03-06-2010 11:18 PM

Quote:

Originally Posted by mohit052 (Post 3888843)
by the way what is $PS1

Thanks for info.

PS1 defines the command line interface prompt.

What happens if you rename .o_cmd? Do you know where .o_cmd came from?

What is the output of
Code:

file ~/.o_cmd
/bin/ls -ld /bin/bash
/bin/bash --version
cksum /bin/bash
/bin/bash -c ls


mohit052 03-06-2010 11:38 PM

This is the only command that actually looked weird of the bunch

# file .o_cmd
Bus error
-bash: /root/.o_cmd: Read-only file system

#cksum /bin/bash
659698809 616248 /bin/bash
-bash: /root/.o_cmd: Read-only file system

# /bin/bash --version
GNU bash, version 3.00.15(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
-bash: /root/.o_cmd: Read-only file system

/bin/ls -ld /bin/bash
-rwxr-xr-x 1 root root 616248 Apr 12 2006 /bin/bash
-bash: /root/.o_cmd: Read-only file system

catkin 03-07-2010 12:23 AM

Thanks for more info.

This is, so far, very puzzling. I have no idea why /bin/bash is trying to run /root/.o_cmd after every command or how it could be configured to do so.

Perhaps this is normal for /bin/bash on your system or perhaps /bin/bash is modified. It would be nice to compare the checksum from an identical system. Let's look for a call to .o_cmd in bash. What is the output from
Code:

strings /bin/bash | grep cmd
Here's how it looks on Slackware 13.0
Code:

cmd_init
xtrace_print_arith_cmd
make_cmd.c
print_cmd.c
dispose_cmd.c
execute_cmd.c
copy_cmd.c
hashcmd.c
findcmd.c
fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
                onecmd      same as -t
onecmd
cmdhist
no_empty_cmd_completion

Let's also dig a little deeper into the what and where of /root and /root/.o_cmd. What is the output of
Code:

/usr/bin/df -hT
/bin/ls -ld /
/bin/ls -ld /root
/bin/ls -ld /root/.o_cmd

It's odd that root's prompt ($PS1) ends in $. Conventionally it ends in #. This (and other root-specific things) are usually set in /etc/profile and (distro-dependent?) in files sourced by /etc/profile from /etc/profile.d/*.sh. Can you post any root-specific sections from those files?

catkin 03-07-2010 12:34 AM

An idea ... what's the output from
Code:

trap -p

Valery Reznic 03-07-2010 01:29 AM

What is output of
Code:

echo "$PROMPT_COMMAND"
?

From bash manual:
Code:

      PROMPT_COMMAND
              If set, the value is executed as a command prior to issuing each
              primary prompt.


catkin 03-07-2010 02:32 AM

Thanks Valery Reznic :) Good to learn about it and could be the cause.

mohit052 03-07-2010 03:22 AM

Got it
 
Valery Reznic, thanks,, i got that .. awesome.. now i know where to look from here ; "logme" being the culprit..

and catkin, thanks for all the help..



###########################################

# echo $PROMPT_COMMAND
echo -n $(logme)
-bash: /root/.o_cmd: Read-only file system
# echo $(logme)
-bash: /root/.o_cmd: Read-only file system

-bash: /root/.o_cmd: Read-only file system
# trap -p
-bash: /root/.o_cmd: Read-only file system

##########################################

Valery Reznic 03-07-2010 03:37 AM

You are welcome. Some time ago I was burned pretty bad by PROMPT_COMMAND -
some command didn't return correct exit status. After a lot of digging it's turns out that someone wanted to do something funny with prompt and used PROMPT_COMMAND. And in this setup, if you run command and then

Code:

command
echo $?

then instead of command's exits status you get $PROMPT_COMMAND's exit status !

After that I decided that I never will use it.

catkin 03-07-2010 04:02 AM

Quote:

Originally Posted by mohit052 (Post 3888987)
Valery Reznic, thanks,, i got that .. awesome.. now i know where to look from here ; "logme" being the culprit..

Glad you identified why the problem is happening :)

But where is $PROMPT_COMMAND set? If root's "personal" bash initialisation files are the same as the other users' then root's shell is being customised in the same way as the other users so there must be something in the bash initialisation files specific to root such as (example from /etc/profile)
Code:

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

And why/how was $PROMPT_COMMAND set, apparently for root only?

What is logme and why how does running it invoke /root/.o_cmd which results in a message about a read-only file system?

colucix 03-07-2010 04:14 AM

Maybe this one passed unnoticed. Why this?
Code:

# file .o_cmd
Bus error


mohit052 03-07-2010 11:22 PM

hi colucix,

yeah ,, still no idea why that bus error occured ?? :-/

and hi catkin,

As it turns out this linux machine is a heavely customised linux IVR voice server. This server is used together with a bunch of infra server(a cluster actually). This server has to connect to these clusters as soon as it boots up. As these are critical systems, some one thought that it would be a good idea to keep checking from time to time if its connection with the cluster are good or not(This messages-one liner-was supposed to be printed after each command executed ), and also log everything that the root user types in..

that o_cmd that we have is actually a script that does the logging thing..

hence its being called... how its does the logging for root is another story i guess.. would love to share that script here,, but have to get permissions from my overlords .. :-) ... If that fails then i will print the important part of the code some time later...

catkin 03-07-2010 11:31 PM

Quote:

Originally Posted by mohit052 (Post 3889778)
As these are critical systems, some one thought that it would be a good idea to keep checking from time to time if its connection with the cluster are good or not(This messages-one liner-was supposed to be printed after each command executed ), and also log everything that the root user types in..

that o_cmd that we have is actually a script that does the logging thing.

Good to know we don't have to worry about malfeasance and to know a little more about why the symptoms are happening.

It still looks as if something is broken, though, and the .o_cmd script is not working as intended. Regards the bus error tha colucix pointed out and other error messages it might be helpful to have the output of
Code:

/usr/bin/df -hT
/bin/ls -ld /
/bin/ls -ld /root
/bin/ls -ld /root/.o_cmd

Presumably this .o_cmd system used to work OK. What has changed since? A tightening up of security on the network mounted file system that root's commands are logged to?


All times are GMT -5. The time now is 11:41 PM.