Results 1 to 8 of 8
I'm trying to set up my computer to have a password-less account that simply prints out the date and time, and then exits . However the motd keeps getting in ...
- 11-29-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 52
how do I turn of the motd for a user with no home directory?
I'm trying to set up my computer to have a password-less account that simply prints out the date and time, and then exits
. However the motd keeps getting in the way.
- 11-29-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,855
Is this user logging in via SSH? If so, can you not just run the command to print date/time like this?
This will just print the date/time and immediately disconnect the SSH session. If I were to not pass any command, but start an interactive session, I would indeed get my MOTD.Code:ssh user@<IP_ADDRESS> date
Or are you logging in some other way?
- 11-29-2011 #3Just Joined!
- Join Date
- Mar 2011
- Posts
- 52
I'm logging in from the text only mode. The idea was that you shouldn't need to have a user password simply to get the time (yes I know the gui already has something for this, but I just wanted to see if I could do this)
- 11-29-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,855
how about this then?
whip up a script that just prints the time and exits:
in this script put:Code:vi /usr/local/bin/datetime
make it executable:Code:#!/bin/sh date exit 0
now add the user, specifying this script as the shellCode:chmod +x /usr/local/bin/datetime
now try it, as root:Code:useradd -s /usr/local/bin/datetime dateuser
To log in with no password is probably not a good idea. You could either create a password that will be easy to remember, or set up ssh keys so that passwords are not required at all.Code:su - dateuser
- 11-29-2011 #5Just Joined!
- Join Date
- Mar 2011
- Posts
- 52
smart, except I don't need to edit any files at all. apparently I can just set the shell to "/bin/date" and it will display the date and then logout (apparently whenever the last program of a user dies, the user is assumed to be logged out). The problem is that the motd tried to write itself at the same time as the date. I could probably solve this with a shell script and the sleep command, but I like the idea better of it just printing out the date and time (this way it seems like this was a built-in feature the whole time, and not just something thrown in at the end).
- 11-29-2011 #6Just Joined!
- Join Date
- Mar 2011
- Posts
- 52
Something odd just happened. I just logged in as the time user, and it said something about time's home directory, and so I checked my /etc/passwd and found that somehow time had gotten a home directory (even though I remember specifying NOT to give him a home directory). So then I deleted that, and now when I log in as time it doesn't have an motd. weird...

wait a minute, apparently that only works when using the su command.
Last edited by rm-rf; 11-29-2011 at 08:44 PM. Reason: wait a minute...
- 11-29-2011 #7Just Joined!
- Join Date
- Mar 2011
- Posts
- 52
ok here is what I am probably going to do: I'll create one user named "command" for inputting built-in commands (its shell will be a script that take certain commands and executes them). It will have a hidden home directory with a .hushlogin file. Also I'm going to tell canonical about this and hopefully they might be able to patch this (although I doubt it will get fixed anytime soon or ever).
- 11-29-2011 #8Just Joined!
- Join Date
- Mar 2011
- Posts
- 52
Well that didn't work so now I am going to just make a home dir in /etc. I hate that they didn't think to make such an obvious thing possible.


Reply With Quote