Solved

Urgent! Motd not working !!

Posted on 1998-12-04
23
430 Views
Last Modified: 2007-12-19
I have some texts in the motd file. It used to work properly, showing text when user login through telnet. But now it's not working.. the texts still in the motd file, and the file still there.... but user cannot see those texts anymore. Could anyone help me on this? Thanks.
0
Comment
Question by:louisalex
  • 14
  • 9
23 Comments
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587765
 What are the file permissions on the /etc/motd file?  Is it possible just a   chmod 644 /etc/motd   will do the trick?
  Do the users have a .hushlogin file in their directories, which will suppress /etc/motd?
0
 

Author Comment

by:louisalex
ID: 1587766
nope... actually I even set the permission to 755 to test but still not working.
Nope..... no .hushlogin in any directories.
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587767
 Do your login files clear the screen in any way?  What happens if you temporarily disable your login files (.cshrc, .login, .profile, .bash_profile, .bashrc ... these sort of things) - just by renaming them with .bak at the end, or moving them to another directory (don't actually delete them!).
  Also, are you logging in via X-Windows, or this a terminal based login?
0
 

Author Comment

by:louisalex
ID: 1587768
I logged in through telnet. Nope, the login files didn't clear the screen.
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587769
 Can you kindly copy all the output you get from the telnet command through to the Unix prompt?
  Also, once logged in, can you do an ls -l /etc/motd and then a cat /etc/motd ?

Thanks.
0
 

Author Comment

by:louisalex
ID: 1587770
hmm... I think probably my server got hacked. Something new come in...in the past, when I telnet in the server, it should look like
Welcome.
login:
password:
motd messages
servername:~$

now it become

Welcome:
servername.domain.com login:
password:
servername:~$

weird...

ls -l /etc/motd
-rw-r--r--   root  root  
cat /etc/motd
**********
Policies:
blah.....blah...blah....
**********
something like that...


0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587771
 Ok, hmm
  Check /etc/profile and see if the line to cat /etc/motd is still in there.  It should look something like this -

        if [ ! -f .hushlogin ]
        then
                /usr/sbin/quota
                trap "trap '' 2"  2
                /bin/cat -s /etc/motd

   etc. ...

 or  /etc/.login if using a csh type shell, in which case the lines should look something like this ...

if (! -e .hushlogin ) then
        /usr/sbin/quota
        /bin/cat -s /etc/motd

  etc ....

  If these lines are missing, then I'd expect this is the problem - because /etc/motd is not displayed 'automatically' per se, it is displayed as a consequence of the lines in these files which get executed when people log in, before their own startup files.
  If there is nothing to cat /etc/motd in those files, then check their modification times with

  ls -l /etc/profile /etc/.login

  and see if they have been modified recently, and if so, if it is about the same time you stopped getting the motd.
0
 

Author Comment

by:louisalex
ID: 1587772
I never have those things in my /etc/profile but it used to show up those motd messages. Just few weeks ago it stopped showing. Don't know why.
Could you please write me the complete lines of that cat /etc/motd for me so that I can try whether it works or not. And where should I put it in /etc/profile? end or beginning? Thanks very much for your comment. I really appreciate your help. Thanks.
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587773
 Here's my complete /etc/profile -- you can find the lines to cat /etc/motd in the middle.
  If your /etc/profile does not contain these lines, do you know if it has been edited recently?  What is the date stamp on it?
  Perhaps your login shell has changed, and the shell you were using did cat /etc/motd in its startup file?
  Anyway -- see if adding these lines to your /etc/profile does the trick for you.  Do keep me informed.


#ident  "@(#)profile    1.17    95/03/28 SMI"   /* SVr4.0 1.3  */

# The profile that all logins get before using their own .profile.

trap ""  2 3
PATH=/opt/SUNWspro/bin:/bin:/usr/bin:/usr/ucb:/usr/sbin:/ust/dt/bin:/usr/openwin/bin:/usr/local/bin:/usr/local/java/bin:/usr/ccs/bin:/usr/X11R6/bin:/opt/texmf/bin:/opt/netscape:/usr/local/microsoft/bin
export LOGNAME PATH

if [ "$TERM" = "" ]
then
        if /bin/i386
        then
                TERM=AT386
        else
                TERM=sun
        fi
        export TERM
fi

#       Login and -su shells get /etc/profile services.
#       -rsh is given its environment in its .profile.

case "$0" in
-sh | -ksh | -jsh)

        if [ ! -f .hushlogin ]
        then
                /usr/sbin/quota
                #       Allow the user to break the Message-Of-The-Day only.
                trap "trap '' 2"  2
                /bin/cat -s /etc/motd
                trap "" 2

                /bin/mail -E
                case $? in
                0)
                        echo "You have new mail."
                        ;;
                2)
                        echo "You have mail."
                        ;;
                esac
        fi
esac

MANPATH=/usr/man:/usr/local/man:/usr/X11R6/man:/usr/openwin/man:/usr/dt/man:/opt/texmf/doc/man
LD_LIBRARY_PATH=/usr/openwin/lib:/usr/X11R6/lib:/usr/dt/lib
CLASSPATH=/usr/local/java/lib/classes.zip
MOZILLA_HOME=/opt/netscape
PRINTER=mailroom
LPDEST=mailroom
EDITOR=vi
export MANPATH LD_LIBRARY_PATH CLASSPATH MOZILLA_HOME
export PRINTER LPDEST EDITOR

umask 022
trap  2 3
0
 

Author Comment

by:louisalex
ID: 1587774
and no one modified the /etc/profile recently.
0
 

Author Comment

by:louisalex
ID: 1587775
wow.. you are fast... I am not so sure about the /etc/profile. Here is my /etc/profile. Please have a look and see where can I put it in. And what os you are using because yours looks a lot different than mine. Just curious.. My login shell is /bin/bash.

# /etc/profile

# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc

PATH="$PATH:/usr/X11R6/bin:/usr/bin:usr/sbin"
PS1='\h:\w\$ '
PS2='> '
ulimit -c 1000000
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
      umask 022
else
      umask 022
fi

#USER=`id -un`
USER=`whoami`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
HISTFILESIZE=1000
export PATH PS1 PS2 HOSTNAME HISTSIZE HISTFILESIZE USER LOGNAME MAIL

for i in /etc/profile.d/*.sh ; do
      if [ -x $i ]; then
            . $i
      fi
done

unset i

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587776
 I'm using Solaris.
  I don't think there's probably any place to put the cat /etc/motd that is particularly better than anywhere else.
Let's go for this ...

# /etc/profile

# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc

PATH="$PATH:/usr/X11R6/bin:/usr/bin:usr/sbin"
PS1='\h:\w\$ '
PS2='> '
ulimit -c 1000000
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
   umask 022
else
   umask 022
fi

if [ ! -f .hushlogin ]; then
   cat -s /etc/motd
fi

#USER=`id -un`
USER=`whoami`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
HISTFILESIZE=1000
export PATH PS1 PS2 HOSTNAME HISTSIZE HISTFILESIZE USER LOGNAME MAIL

for i in /etc/profile.d/*.sh ; do
if [ -x $i ]; then
    . $i
fi
done

unset i


  As an aside, the lines to set the umask can all be replaced with just a   umask 022   because the same value is being used, regardless of the if condition.
0
 

Author Comment

by:louisalex
ID: 1587777
wow.. you are fast... I am not so sure about the /etc/profile. Here is my /etc/profile. Please have a look and see where can I put it in. And what os you are using because yours looks a lot different than mine. Just curious.. My login shell is /bin/bash.

# /etc/profile

# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc

PATH="$PATH:/usr/X11R6/bin:/usr/bin:usr/sbin"
PS1='\h:\w\$ '
PS2='> '
ulimit -c 1000000
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
      umask 022
else
      umask 022
fi

#USER=`id -un`
USER=`whoami`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
HISTFILESIZE=1000
export PATH PS1 PS2 HOSTNAME HISTSIZE HISTFILESIZE USER LOGNAME MAIL

for i in /etc/profile.d/*.sh ; do
      if [ -x $i ]; then
            . $i
      fi
done

unset i

0
 

Author Comment

by:louisalex
ID: 1587778
well, error message come to

bash :[!: command not found

but without those if thing, just type cat -s /etc/motd
it shows up the messages...

0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587779
 Excellent, so you are seeing the message now, upon login?
You need to just make sure there is a space between the [ and the ! in the if line, like so

  if [ ! -f .hushlogin ]; then

.

  However, this if statement is just to suppress /etc/motd being displayed if the user has a .hushlogin file in their account, which you may not need to worry about.  That is, you can certainly delete the if statement and just have the cat -s /etc/motd
0
 

Author Comment

by:louisalex
ID: 1587780
but without the if thing.. now even when I su -l
the /etc/motd message also come out... it used to won't show up again when I su -l

0
 

Author Comment

by:louisalex
ID: 1587781
and how about the servername appear infront of the login. That really piss me off....
yup.. got it.... I leave a space infront of ! then it worked... now it is the login stuff.... please help me on this.... Thanks..

0
 

Author Comment

by:louisalex
ID: 1587782
and how about the servername appear infront of the login. That really piss me off....
yup.. got it.... I leave a space infront of ! then it worked... now it is the login stuff.... please help me on this.... Thanks..

0
 

Author Comment

by:louisalex
ID: 1587783
and how about the servername appear infront of the login. That really piss me off....
yup.. got it.... I leave a space infront of ! then it worked... now it is the login stuff.... please help me on this.... Thanks..

0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1587784
 Ok, so, what are we up to now?
  You get the motd being shown when you login, as you wanted, but it is also being displayed when you su - ?
  That, actually, is the correct behaviour because the - tells su to act like you've just logged in as root (or some other user).  If you use just su by itself (without the -) then you will become the superuser but without executing the login files.
0
 

Author Comment

by:louisalex
ID: 1587785
Oh I see, thanks very much. So, do you know how to fix the login thing? It used to just have login: but now is servername login: . Anyway, please answer the question, simply write something so that I can give you the points you deserve. Thanks very much.
0
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 50 total points
ID: 1587786
 It's been nice dealing with you.
  As to the login thing, hmm, I'd have to experiment, but you may find some success by looking at /etc/*tty* files.  I'm fairly sure there is a file in there somewhere (maybe something to do with getty - maybe a man getty will reveal the right filenames) which defines the prompts to give.  If you can find the right file I'm pretty confident that you can just edit the text there.
0
 

Author Comment

by:louisalex
ID: 1587787
It's been nice dealing with you too. Thanks very much for your answers. I really appreciate your help. Thanks. Talk to you next time. Seeya. I will look into the tty thing, hope will get something out.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now