System message getting printed after every command execution
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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
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
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?
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 !
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?
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...
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
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"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.