LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-06-2010, 10:33 PM   #1
mohit052
LQ Newbie
 
Registered: Nov 2008
Posts: 25

Rep: Reputation: 15
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 ... :-)
 
Old 03-06-2010, 10:44 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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?
 
Old 03-06-2010, 10:58 PM   #3
mohit052
LQ Newbie
 
Registered: Nov 2008
Posts: 25

Original Poster
Rep: Reputation: 15
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
 
Old 03-06-2010, 11:18 PM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by mohit052 View Post
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
 
Old 03-06-2010, 11:38 PM   #5
mohit052
LQ Newbie
 
Registered: Nov 2008
Posts: 25

Original Poster
Rep: Reputation: 15
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
 
Old 03-07-2010, 12:23 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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?
 
Old 03-07-2010, 12:34 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
An idea ... what's the output from
Code:
trap -p
 
Old 03-07-2010, 01:29 AM   #8
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
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.
 
1 members found this post helpful.
Old 03-07-2010, 02:32 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks Valery Reznic Good to learn about it and could be the cause.
 
Old 03-07-2010, 03:22 AM   #10
mohit052
LQ Newbie
 
Registered: Nov 2008
Posts: 25

Original Poster
Rep: Reputation: 15
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

##########################################
 
Old 03-07-2010, 03:37 AM   #11
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
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.
 
Old 03-07-2010, 04:02 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by mohit052 View Post
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?
 
Old 03-07-2010, 04:14 AM   #13
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Maybe this one passed unnoticed. Why this?
Code:
# file .o_cmd
Bus error
 
Old 03-07-2010, 11:22 PM   #14
mohit052
LQ Newbie
 
Registered: Nov 2008
Posts: 25

Original Poster
Rep: Reputation: 15
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...
 
Old 03-07-2010, 11:31 PM   #15
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by mohit052 View Post
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?

Last edited by catkin; 03-07-2010 at 11:32 PM. Reason: Improved to "on the network mounted file system that root's commands are logged to"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel Oops message has stack trace that does not correspond to the execution exactly schoi21c Linux - Kernel 2 10-02-2009 11:02 AM
Only execute 2nd command on successufl execution of 1st command kregec05 Linux - Newbie 3 08-19-2009 10:29 AM
Chinse character printed garbled when printing through lp command amit_pansuria Linux - General 1 07-29-2009 09:48 PM
Automated execution of a command on a remote system via SSH GUIPenguin Linux - General 1 02-28-2006 11:23 PM
command execution leonidas Linux - General 1 09-22-2004 12:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration