LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 04-19-2007, 10:25 AM   #1
btaylor1988
Member
 
Registered: Nov 2005
Location: England
Distribution: CentOS, Fedora
Posts: 79

Rep: Reputation: 15
login script


Hi,

Just a quick question, I’m running CentOS machine and have multiple friends who log into the server via SSH. Is there a way so when they log onto the system I can set personal welcome messages unlike the global motd witch does it for everyone?
 
Old 04-19-2007, 11:00 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Sure just add it to one of the individual start file(s) such as .bash_profile or .profile or .bashrc in the user's home directory.

vi ~user/.bashrc
Go to the end of the file and add a simple echo statement:
echo "Welcome to my world, Bill. Try not to trash it up much."
Save the file. On next login it will echo the line.

Where "user" is the login name you've given the user.
 
Old 04-19-2007, 12:52 PM   #3
btaylor1988
Member
 
Registered: Nov 2005
Location: England
Distribution: CentOS, Fedora
Posts: 79

Original Poster
Rep: Reputation: 15
thanks alot pal, worked out great.
 
Old 04-19-2007, 01:31 PM   #4
djjoshuad
Member
 
Registered: Apr 2007
Location: Corinth, TX
Distribution: CentOS, RHEL, SLES, ubuntu
Posts: 44

Rep: Reputation: 15
one suggestion: use a file like /etc/MOTD or something similar to contain your message, then put "cat /etc/MOTD" in their profile instead of "echo blah". This way, you can change the message in one place for all users rather than in one place for each user. If you want to personalize it, there are lots of options there... This was a very popular thing some years ago
 
Old 04-19-2007, 01:59 PM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
He wanted personalized messages so a single file wouldn't help unless he was just doing it like mail list where he's inserting the user's name and/or other information in the text.

vi /etc/motd.sh

Code:
#!/bin/bash
echo "Hi ${FRIEND}, welcome to my system.  Try not to trash the place up."
Save the file then "chmod 755 /etc/motd.sh".

He could then set "export FRIEND=Bill" in Bill's bashrc/profile and "export FRIEND=Sara" in Sara's bashrc/profile. Then instead of cat as you say he would simply put "/etc/motd.sh" after the FRIEND line in bashrc/profile. It would get the variable ${FRIEND} and insert the line so that:

Bill would see:
"Hi Bill, welcome to my system. Try not to trash the place up."

But Sara would see:
Hi Sara, welcome to my system. Try not to trash the place up.

Later he could modify /etc/motd.sh so that it said
echo "Hi ${FRIEND}, just wanted you to know that the wife and I are going to see Cirque de Soleil tonight so won't be able to help you if you have issues with your login."
 
Old 04-19-2007, 04:13 PM   #6
djjoshuad
Member
 
Registered: Apr 2007
Location: Corinth, TX
Distribution: CentOS, RHEL, SLES, ubuntu
Posts: 44

Rep: Reputation: 15
you're right, I missed his original comment "unlike the global motd".

i've seen some admins get really nutso with their MOTDs. Everything from a scenario like the one described above to a database-driven mini-app that gave people their horoscope
 
Old 04-19-2007, 04:58 PM   #7
btaylor1988
Member
 
Registered: Nov 2005
Location: England
Distribution: CentOS, Fedora
Posts: 79

Original Poster
Rep: Reputation: 15
used method works well and as for going nuts ive used askii in my motd. mabye im mad oh well thanks anyways.
 
Old 09-11-2007, 09:07 PM   #8
pcardout
Member
 
Registered: Jun 2003
Location: Socorro, New Mexico
Distribution: Debian ("jessie", "squeeze"), Linux Mint (Serena), XUbuntu
Posts: 221

Rep: Reputation: 24
Hi -- My enthusiasm for Linux and computational physics has
lead me to start a small lab in which all the clients have
nfs-mounted the same server drive. This gives the students
visibility to their files and configuration files no matter which
client they log into. I have some cute routines for
propagating password changes -- and they also propagate an motd
file. Problem is, most of students login through gdm, so they
never see an motd.

I have two questions

1) Is there a comparable facility for gdm?
(I see there is a "postlogin" feature)
http://www.gnome.org/projects/gdm/docs/gdmtalk.pdf

2) Even if students log in through GDM -- many of them will eventually launch a
terminal. I could edit their .bashrc as follows:

Code:
if test -f /etc/motd
   then
   cat /etc/motd
fi
The problem is that if they login remotely (ssh), they'll see the motd twice --
not elegant. So I need to check something. There are some posts about shopt.
Is that they way to go? I welcome suggestions.

Last edited by pcardout; 09-18-2007 at 12:27 AM. Reason: Copied to a new thread per suggestion of jlightner
 
Old 09-12-2007, 08:22 AM   #9
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Rather than piggy backing on an old and off topic thread you should open a new thread for your questions because:

1) Only the people that subscribed to this thread originally will see it and only if they choose to look at it again.
2) There is no guarantee that the folks that saw this original thread will be able to assist with your new question.
3) Posting a new thread makes it go to "zero replies" meaning lots of people will see it and you're more likely to get a helpful response.
 
  


Reply



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
How to check in a script whether the shell is login or non login? frankie_DJ Programming 7 10-21-2015 10:09 AM
login script nin881 Slackware 3 06-11-2005 02:21 AM
Login Script meenalborkar Red Hat 1 02-18-2005 05:37 AM
login-script thermite_1033 Linux - Security 2 09-28-2004 04:54 PM
login script notREALly Linux - General 6 11-29-2003 08:23 AM

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

All times are GMT -5. The time now is 04:45 AM.

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