# Editing /etc/issue and /etc/motd to get a cooler login.

## Jeedo

Here are a cauple of cool tricks for customizing your login process.

1. Customizing /etc/issue

/etc/issue is the text that is displayed before any user is able to log on the system, the default output on Gentoo is:

```

This is \n.\O (\s \m \r) \t

```

Which translates to:

 *Quote:*   

> 
> 
> This is hostname.iso-domain (kernel arch version) HH:MM:SS
> 
> 

 

What i did there was add a ASCII picture to the file as well as changing the description line slightly

```

              ,:.:.:. . .    .H. "PA,           .:IHH:HHII::.

             ,:.::... ..     A:I:::";, .   .  ,ILIIIH:HI:I:I;

            ,;:.:.:.. . .   .H:TP"VB')..   .,;T;,,::I:HI:I:::

           ,::.:.:.. . .    AI:.":IAAT:.  .(':BB');V::IH:I:I;

          ,::.:.:.. . .    .H:. ' . . ..  .":;AITP;I:IIH:I::;,

         ,::.::.:. . . .   A::.   . ..:.  .  . ..:AI:IHII:I::;.

         ;:.::.:.. .  .   AM:I:.   ..:.   .: . .::HIIIHIIHII::.

        ,:::.:.:..  .    .MM:I:..  .:,    .:.  .::HHIIIHIHII::'

       ,::.:..:.. .   .  AMM:I:.  . .'"-""''. ..::HIHI:HI:III:

       ;:.::..:.. . .   AMMM::. . ,,,, '..   '.::IMHIHIHIIHI::;

      ,:::.:..:. .   .  MMMM:I:.  ':::;;;::;' .::AMHIHIHHIHHI:"

      ;::.:.:.. . .   .:VMMV:A:. .  ':;,,."  .::AMMMIHIHHIHHII

     ;::.:.:.. ..  .  .::VM:IHA:. .''   ' . ..:AMMMMHIHHHIHHII:

     ;:::.:.. .  .. . .::P::IHHAA.. .   .. .:AMMMMMMMIIHHIHHI::

     ;::.:.. .  . .  ..:.:VIHHHIHHA::,,,,,:AMMMMMMMMMHIIHHHHII;

     ;.::.. .    . .  ..:.:VHHIHI:IHIHHIHI:MMMMMMMMMMHIHHIHHII:

     ::.:.. .     ..  ...:.::VHI:IIVIHIHII:MMMMMMMMMMMIHHIHHII:,

     ;:..:. .    ..  . ..:.::::VAII:IIIIII:MMMMMMMMMMMIHHIIHIIHI

     ';:.. .        . .. ..:...:.VII::III:.VMMMMMMMMMHIHHHIHI::I,

      ;:. . .    ' . .. ... . .::.::V::II:..VMMMMMMMMHIHHHIHI::I;

      ;:.. . .     . .. ..:..  .::...:VIITPL:VMMMMMMMVIHHHIH:. :;

      ;:. .  .    . .. ... .   ..:.:.. .:IIIA:.MMMMMVI:HIHIH:. .:

      I:. . .   . .. . .. . . . . ..:.. ..::IIA.VMMMVIHIIHIV:. .'

      I:..    . . .. .... .  .   . .. ... .:.:IA:.VMVIMHIHIH:..:

      I.. .  .  . ..... .       .  . .. . .. .:IIAV:HIMHHIHII:.'

      :. ..   . . .:.. .          .  .. ... ..::.:CVI:MHHIHHI...

      :..  . . .. ..:.               . . ... .:.:::VHA.VIHHMI:..

      :. .. .  . ..:..        . .     . .  ..  .. ...:VIIHIHI: .

      ':.. .  . .::. .       .::,.      .    .  . .  ...V:IHII..

       ;:.. .. .:I:.        ..:T"::.     .  . .  .  . .  .VIIH:.

       ;:.:.. .:I:..        .::V:::.         . . . .  .    VIII..

       ;:.. ..::::. .        ..::. .      .  . .. . .  .    VIII.

       I:.:.. .:I:.           ..:.'        . . .. :. .  .    "VI:.

       I::......::.  .                    . .. .:.:.:. .       "I:

       II::.. ..::. .       .    .      . .. .. .::::.. .      .:.

       II::.:. ..::. .  . .   .    .     .:. . .:I:::. .       .::HD

       'I:::.. .: . .. ..  .. . .     .  .::. . .:I:. .         .:V:

        I:. .. .  . . ... ..  .. . .    .. ..  ..::.             .:.

        I:.. .. .  ..:.. .. .. ..  . .      .   .                . :

        ;:.... . ..:::I:.. ..:.. ... .::. . ... . ..              .I.

        ::.:....::.::I:III:I::::I:II:I::.. .:.. . .:. .     .  . .AI:

        '::.:...:..::::::III::II::::::.. ...::. .  .::. . .. .  .AMMI.

         :::.:.:. ..::::III:II:I:::.:. .. ..::.. ..  ..::,.  ..::HMMI:

         ':::.:.. ...::I:::I:I:::.:.. :. . ..::.. . . . .'PTIHI:IIHHI:.

          ::I::.:...:::II:I::.:....:.:. . ...::. .  . .  .AI:IHI'':'  '.

          ':::.:... ..I::I::.:....:. .: .. ...::. .  .   III:II:.  '

           'I:::..:...:.::I::.:..:. .: .. . ..:... .  .  III.I'

            VI:::.::.::...:II::...:...:. . . .:::. . .   :''

            'HI:I::.::.::..:II::.:..:.... . .:.:I:.. .   :

             VI:I:I::.::.:...:I:::I:::.... ..:.:I::...   :

This is \n (Gentoo GNU/\s \m \r) \t

```

more pictures can be found here: http://212.30.222.56/tmp/ascii-pics.tar.gz (temp url) and http://www.simnet.is/velfag/tmp/ascii-pics.tar.gz (will be up once my isp is up again.)

2. Making /etc/motd dynamic

/etc/motd is message of the day, it is displayed right after the user has entered his or her password.

This is just one of many things that can be done:

First,

```

emerge -s fortune

```

and then

```

emerge fortune-mod cowsay

```

as well as any quote archives you want

Then

```

ls /etc/runlevels/default/

```

If the runlevel "local" is not on that list then do

```

rc-update add local default

```

and

```

echo "fortune | cowsay -f bunny > /etc/motd" >> /etc/conf.d/local.start

```

This is presuming you want the "bunny-cow" by cowsay,

Another way to do this, especially if you don't reboot every day like i do is to add the same line to an executable script in /etc/cron.daily

Anyway if you did it right you should get something like:

```

Rancorwe login:

Password:

Last login: Sun Oct 19 19:41:58 2003 from goongsang

 

----------

## Headhunter123

Hi!

Cool tips, thanks  :Smile: 

One improvement for your cowsay thing, what about showing a random cow each time?

Try this script (it isn't mine, I have it from some guy from #gentoo.de, don't ask me who it was, anyway, he deserves the credits, not me)

#!/bin/sh

cowsay -f $(perl -le 'opendir COWS, "/usr/share/cowsay-3.03/cows/";push @a, $_ foreach readdir COWS;closedir COWS;$a[int rand $#a]=~/(.*)\.cow/;print $1') $1joj

----------

## dub.wav

Another suggestion:

```

emerge linux-logo

linux_logo -L 3 > /etc/issue (back up /etc/issue first)

```

You'll then have a gentoo logo in your /etc/issue. There are a few different logos in linux_logo...linux_logo -L 1 gives you a linux penguin with a white/grey background, -L 2 a penguin with a black background, etc.

----------

## zeky

You have to love that pretty ASCII login pic :p

----------

## cybe

Why not ANSI graphics to give you that; "uh is it 1994 and I'm logging in to a BBS" feeling? grab some .ANS files and cat them (an ANSI font is needed)

----------

## Jeedo

 *Headhunter123 wrote:*   

> Hi!
> 
> Cool tips, thanks :)
> 
> One improvement for your cowsay thing, what about showing a random cow each time?
> ...

 

I was going to do that, however i didnt know how, but you've just helpfully told me;)

----------

## ecatmur

If you don't want to fire up perl,

```
cows=(/usr/share/cowsay*/cows/*.cow)

cowsay -f ${cows[$(($RANDOM%${#cows}))]}
```

will work in a bash script, e.g. my /etc/cron.hourly/motd-maker:

```
#! /bin/bash

 

if [ -x "$(which cowsay)" ]; then

        cows=(/usr/share/cowsay*/cows/*.cow)

        modes=("-b" "-d" "-g" "-s" "-t" "-w" "-y" "")

        filter="cowsay -f ${cows[$(($RANDOM%${#cows}))]} ${modes[$(($RANDOM%${#modes}))]}"

else

        filter="cat"

fi

 

if [ -x "$(which fortune)" ]; then

        producer="fortune"

else

        producer="uname -a"

fi

 

$producer | $filter > /etc/motd
```

----------

## Neelix

Together with a friend of mine I went in and finally made a real script to do this. There's two seperate ones in here, do with it what you will, but it works for me  :Smile: 

The script that does the job (put it in /usr/local/bin/fortuned):

```

#! /usr/bin/env perl

# Fortune Daemon

# Variable setup

$myPipe="/etc/motd";

$myFortune="/usr/bin/fortune";

$myPidFile="/var/run/fortuned.pid";

# Make the pipe or die trying.

if (! -p $myPipe) {

   !`mkfifo $myPipe` or die "could not create $myPipe, stopped at";

}

# Fork, child goes on to become a fortune daemon

# Parent writes the PID to the pid-file and terminates.

if (! ($myPid=fork()) ) {

  while(1) {

    open(PIPE,">$myPipe") or die "could not open $myPipe, stopped at";

    print PIPE `$myFortune`."\n";

    close(PIPE);

    sleep(1);

}}

# Before the parent dies, it cleans up after its child.

else {

    open(OUTFILE, "> $myPidFile");

    print OUTFILE "$myPid";

    close(OUTFILE);

}

```

This script runs in the background and writes a new fortune to /etc/motd.

To turn this all on and off at will, there's this init.d script:

```

#!/sbin/runscript

# This is some belony info, but for some reason something needs

depend() {

    use logger

    need net

}

checkconfig() {

    if [ ! -e /usr/local/bin/fortuned ] ; then

        eerror "no fortuned present"

        return 1

    fi

}

start() {

    checkconfig || return 1

    ebegin "Starting fortuned"

    start-stop-daemon --start --quiet --exec /usr/local/bin/fortuned

    eend $?

}

stop() {

    ebegin "Stopping fortuned"

    start-stop-daemon --stop --quiet --pidfile /var/run/fortuned.pid

    rm /etc/motd

    eend $?

}

```

Known issue:

The generating part takes a second off before sending a new fortune to the pipe. This is so that the receiving end knows when to stop.

The effect of this is that you can't log in simultaneously, but one of you would have to wait just a second.

----------

## Neelix

One word of caution if you go experimenting wit this:

Be really sure that something comes out of the pipe at /etc/motd.

If nothing comes out and you reboot, you've just succesfully locked yourself out of your box. So then it's time to get your LiveCD out again and fix it, or find some other means to do it.

----------

## b1nd3n14l

The perl script for the pipe of /etc/motd rocks!

Thanks dude...

----------

## ett_gramse_nap

Lovely! I've never thought about this! Really cool to be offended by a cow everytime one logs on!   :Very Happy: 

----------

## monotux

I think someone should take a look how slackware does their random quote @ login - thats the only thing I miss with slackware :-/

----------

## pYrania

Guess this might be the right thread to ask..  :Smile: 

I've the following /etc/issue file on all my boxes, but as you might notice, the box end pipes are not aligned by default, because of different hostname and kernel version lenghts.

I thought about hacking up a script that dynamically draws the box and fills it with whatever needed number of whitespaces. The script could be called from local.start so it's always up to date. however i didn't have the time to hack this script up yet. Any volunteers?  :Smile: 

```
^[[H^[[J

^[[1;33;40m

                          oooo$$$$$$$$$$$$oooo

                      oo$$$$$$$$$$$$$$$$$$$$$$$$o

                   oo$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$o         o$   $$ o$

   o $ oo        o$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$o       $$ $$ $$o$

oo $ $ "$      o$$$$$$$$$    $$$$$$$$$$$$$    $$$$$$$$$o       $$$o$$o$

"$$$$$$o$     o$$$$$$$$$      $$$$$$$$$$$      $$$$$$$$$$o    $$$$$$$$

  $$$$$$$    $$$$$$$$$$$      $$$$$$$$$$$      $$$$$$$$$$$$$$$$$$$$$$$

  $$$$$$$$$$$$$$$$$$$$$$$    $$$$$$$$$$$$$    $$$$$$$$$$$$$$  """$$$

   "$$$""""$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$     "$$$

    $$$   o$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$     "$$$o

   o$$"   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       $$$o

   $$$    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" "$$$$$$ooooo$$$$o

  o$$$oooo$$$$$  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   o$$$$$$$$$$$$$$$$$

  $$$$$$$$"$$$$   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$     $$$$""""""""

 """"       $$$$    "$$$$$$$$$$$$$$$$$$$$$$$$$$$$"      o$$$

            "$$$o     """$$$$$$$$$$$$$$$$$$"$$"         $$$

              $$$o          "$$""$$$$$$""""           o$$$

               $$$$o                                o$$$"

                "$$$$o      ^[[0;31;40mo$$$$$$o"$$$$o^[[1;33;40m        o$$$$

                  "$$$$$oo     ^[[0;31;40m""$$$$o$$$$$o^[[1;33;40m   o$$$$""

                     ""$$$$$oooo  ^[[0;31;40m"$$$o$$$$$^[[1;33;40m$$$$"""

                        ""$$$$$$$oo ^[[0;31;40m$$$$$$$$$$^[[1;33;40m

                                """"^[[0;31;40m$$$$$$$$$$$^[[1;33;40m

                                    ^[[0;31;40m$$$$$$$$$$$$^[[1;33;40m

                                     ^[[0;31;40m$$$$$$$$$$"^[[1;33;40m

                                      ^[[0;31;40m"$$$""""^[[1;37;40m

,-----------------------------------------------.

| System OS: Gentoo Linux                       |

| Kernel...: \s-\r                    |

| FQDN.....: \n.\O          |

| Admin....: Markus Nigbur <pYrania@gentoo.org> |

`-----------------------------------------------'

^[[0;37;40m

```

----------

## linux_girl

 *furiorc wrote:*   

> I think someone should take a look how slackware does their random quote @ login - thats the only thing I miss with slackware :-/

 

may be because they moded the /bin/login to use fortune with is prety bas idea (buffer overflow ....)

----------

## blue.sca

 *pYrania wrote:*   

> Any volunteers? :)

 

No way!!! :)

----------

## tom56

Am I the only one who thinks the picture at the top of this is page is inappropriate? IMO the fact that it is in ASCII doesn't make it any more or less suitable.

----------

## j-m

 *tom56 wrote:*   

> Am I the only one who thinks the picture at the top of this is page is inappropriate? IMO the fact that it is in ASCII doesn't make it any more or less suitable.

 

Yes, probably you are the only one...  :Rolling Eyes: 

----------

## NeddySeagoon

ecatmur,

Thats hard work, why not add 

```
# run fortune at login

echo

fortune

echo
```

to the end of /etc/bash/bashrc ?

Every login gets a new fortune

----------

## tom56

 *j-m wrote:*   

>  *tom56 wrote:*   Am I the only one who thinks the picture at the top of this is page is inappropriate? IMO the fact that it is in ASCII doesn't make it any more or less suitable. 
> 
> Yes, probably you are the only one... 

 

That's what I thought  :Very Happy: 

Personally I don't find it offensive, I'm just aware that there are other people who might.

----------

## elchino

 *NeddySeagoon wrote:*   

> ecatmur,
> 
> Thats hard work, why not add 
> 
> ```
> ...

 

When you mess with ~/.bashrc, you put scp's in jeopardy. 

I used to do what you suggested, but scping where it required me to give my Gentoo-box's login info failed every time.  

/etc/motd is definitely the way to go.

I currently have a cronjob that refreshes /etc/motd every 60 seconds. You don't necessarily get a new fortune every login, but I don't usually start new sessions that frequently.

[edit] added an apostrophe in the first line of my post [/edit]

----------

## NeddySeagoon

elchino,

I didn't suggest ~/.bashrc  and yes, you can mess up ssh. I have a few headless boxes wth that /etc/bash/bashrc modification. ssh is fine here.

----------

## raccoon

Great tutorial! Just thought I'd let you know about a typo;

 *Quote:*   

> If the runlevel "local" is not on that list then do...

 

"local" is the script name, and "default" is the runlevel - not the other way around :)

----------

## nonas

Does somebody have any details about [colors/bold/italic/whatever] codes used in these files ?

I saw this information once but can't find it again...

----------

## raccoon

http://advbash.activeventure.net/colorizing.html

----------

## nonas

Thanks a lot   :Wink: 

*bookmarked*

----------

## nichocouk

 *ecatmur wrote:*   

> 
> 
> ```
> #! /bin/bash
> 
> ...

 

Ecatmur,

Thanks for a nice tip, but I've got some problems I don't understand:

In the script, the command 

```
echo ${#modes}
```

 always return 2, and the selected modes are "-b" or "-d" only. What could be the reason?

Thanks!

----------

## nichocouk

OK, I found the problem, I had to add [*] so that the number of elements in the array is returned:

```
filter="cowsay -f ${cows[$(($RANDOM%${#cows[*]}))]} ${modes[$(($RANDOM%${#modes[*]}))]}"
```

For some reason this problem does not occur for the cows array, but I added the [*] for consistency.

Cheers,

----------

## Akkara

 *Quote:*   

> dynamically draws the box and fills it with whatever needed number of whitespaces

 

A quick way to output fixed-length lines using sed:

```
sed -e 's/$/                /' -e 's/^\(................\).*/| \1 |/'
```

(Adjust the number of spaces in the 1st expression and the number of dots in the second expression to equal the desired line length)

Or, for right-justified:

```
sed -e 's/^/                /' -e 's/.*\(................\)$/| \1 |/'
```

----------

## eyoung100

 *dub.wav wrote:*   

> Another suggestion:
> 
> ```
> emerge linux-logo
> 
> ...

 

 *Headhunter123 wrote:*   

> Hi!
> 
> Cool tips, thanks 
> 
> One improvement for your cowsay thing, what about showing a random cow each time?
> ...

 

 *NeddySeagoon wrote:*   

> 
> 
> ```
> # run fortune at login
> 
> ...

 

I took all three of the above ideas, and added this to my /etc/bash/bashrc:

```
# Run fortune from random cowsay for everyone at new login

echo

fortune | cowsay -f $(perl -le 'opendir COWS, "/usr/share/cowsay-3.03/cows/";push @a, $_ foreach readdir COWS;closedir COWS;$a[int rand $#a]=~/(.*)\.cow/;print $1') $1

echo
```

  The joj was removed as I would get the diferrent .cow files, but they were all returning joj.  I then added this to /etc/conf.d/linux-logo (I'd leave out the comments but you need them to decipher the meaning):

```
# Seq   Description             Output

# ----------------------------------------------------------------

# ##                            #

# #B    Bogomips                374.37

# #C    Compiled Date           #47 Fri Jan 8 10:37:09 EST 1999

# #E    User Text               My Favorite Linux Distribution

#       Displayed with -t

# #H    Hostname                deranged

# #L    Load average            Load average 0.04, 0.01, 0.01

# #M    Megahertz               188Mhz

#       where supported

# #N    Number of CPU's         Two

# #O    OS Name                 Linux

# #P    Processor or Processors Processor

# #R    Ram                     64M

#       in Megabytes

# #S    Plural                  s

# #T    Type of CPU             K6

# #U    Uptime                  Uptime 10 hours 59 minutes

# #V    Version of OS           2.2.0-pre5

# #X    CPU Vendor              AMD

# \\n   carriage return

FORMAT="Gentoo #O `cat /etc/gentoo-release | awk '{ print $5,$6 }'`\n#O #V, Compiled #C\n#N #X #T #M CPU#S, #R RAM, #B Bogomips\nHost: #H  / Login Terminal: \l\nToday's Date: \d\n        Local Time: \t\n"

FORMATNET="Gentoo #O `cat /etc/gentoo-release | awk '{ print $5,$6 }'`\n#O #V, Compiled #C\n#N #X #T #M CPU#S, #R RAM, #B Bogomips\nHost: #H / Today's Date: \d\n        Local Time: \t\n"

OPTIONS="-L 2 -f -u"
```

2 is passed to /usr/bin/linux_logo which is the word gentoo in purple.  Also note the extra spaces in the Time Section.  Those are there to somewhat center evenly the time under the date.  Notice also that some of our original  pieces of /etc/issue can be added from the original as Jeedo decoded:

 *Jeedo wrote:*   

> 
> 
> 1. Customizing /etc/issue
> 
> /etc/issue is the text that is displayed before any user is able to log on the system, the default output on Gentoo is:
> ...

 

I'm sure theres a fancy way to code to put them in the center, but I'm lazy   :Rolling Eyes:   This will give you both login art and a fortune without the need for /etc/motd as that can only be a plain text file.

----------

## zzxop

COOL TIPS!  :Very Happy: 

THANKS && Bookmarked  :Laughing: 

----------

## logical_guy

 *tom56 wrote:*   

> Am I the only one who thinks the picture at the top of this is page is inappropriate? IMO the fact that it is in ASCII doesn't make it any more or less suitable.

 

+1 on this one.  Just because most gentoo users are geeks, it doesn't mean what's appropriate in a chan4 forum is appropriate here.

Please keep gentoo forums clean and minors-friendly.

----------

## coolzxbin

 *nichocouk wrote:*   

>  *ecatmur wrote:*   
> 
> ```
> #! /bin/bash
> 
> ...

 

try 

echo ${#modes[*]}

----------

## P.Kosunen

```
cat /etc/issue > /etc/motd
```

At (ssh) login i see this:

```
This is \n.\O (\s \m \r) \t
```

How can i get these escape sequences to show up correctly?

Edit: /etc/login.defs might be correct place to set this.

----------

