Find the answer to your Linux question:
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 ...
  1. #1
    Just 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.

  2. #2
    Linux 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?
    Code:
    ssh user@<IP_ADDRESS> date
    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.

    Or are you logging in some other way?

  3. #3
    Just 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)

  4. #4
    Linux Guru
    Join Date
    May 2011
    Posts
    1,855
    how about this then?

    whip up a script that just prints the time and exits:
    Code:
    vi /usr/local/bin/datetime
    in this script put:
    Code:
    #!/bin/sh
    date
    exit 0
    make it executable:
    Code:
    chmod +x /usr/local/bin/datetime
    now add the user, specifying this script as the shell
    Code:
    useradd -s /usr/local/bin/datetime dateuser
    now try it, as root:
    Code:
    su - 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.

  5. #5
    Just 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).

  6. #6
    Just 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...

  7. #7
    Just 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).

  8. #8
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...